Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sherckuith 0:479ce5546098 1 /*****************************************************************************
sherckuith 0:479ce5546098 2 * ppp.h - Network Point to Point Protocol header file.
sherckuith 0:479ce5546098 3 *
sherckuith 0:479ce5546098 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
sherckuith 0:479ce5546098 5 * portions Copyright (c) 1997 Global Election Systems Inc.
sherckuith 0:479ce5546098 6 *
sherckuith 0:479ce5546098 7 * The authors hereby grant permission to use, copy, modify, distribute,
sherckuith 0:479ce5546098 8 * and license this software and its documentation for any purpose, provided
sherckuith 0:479ce5546098 9 * that existing copyright notices are retained in all copies and that this
sherckuith 0:479ce5546098 10 * notice and the following disclaimer are included verbatim in any
sherckuith 0:479ce5546098 11 * distributions. No written agreement, license, or royalty fee is required
sherckuith 0:479ce5546098 12 * for any of the authorized uses.
sherckuith 0:479ce5546098 13 *
sherckuith 0:479ce5546098 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
sherckuith 0:479ce5546098 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
sherckuith 0:479ce5546098 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
sherckuith 0:479ce5546098 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
sherckuith 0:479ce5546098 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
sherckuith 0:479ce5546098 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
sherckuith 0:479ce5546098 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
sherckuith 0:479ce5546098 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
sherckuith 0:479ce5546098 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
sherckuith 0:479ce5546098 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sherckuith 0:479ce5546098 24 *
sherckuith 0:479ce5546098 25 ******************************************************************************
sherckuith 0:479ce5546098 26 * REVISION HISTORY
sherckuith 0:479ce5546098 27 *
sherckuith 0:479ce5546098 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
sherckuith 0:479ce5546098 29 * Ported to lwIP.
sherckuith 0:479ce5546098 30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
sherckuith 0:479ce5546098 31 * Original derived from BSD codes.
sherckuith 0:479ce5546098 32 *****************************************************************************/
sherckuith 0:479ce5546098 33
sherckuith 0:479ce5546098 34 #ifndef PPP_H
sherckuith 0:479ce5546098 35 #define PPP_H
sherckuith 0:479ce5546098 36
sherckuith 0:479ce5546098 37 #include "lwip/opt.h"
sherckuith 0:479ce5546098 38
sherckuith 0:479ce5546098 39 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
sherckuith 0:479ce5546098 40
sherckuith 0:479ce5546098 41 #include "lwip/def.h"
sherckuith 0:479ce5546098 42 #include "lwip/sio.h"
sherckuith 0:479ce5546098 43 #include "lwip/stats.h"
sherckuith 0:479ce5546098 44 #include "lwip/mem.h"
sherckuith 0:479ce5546098 45 #include "lwip/netif.h"
sherckuith 0:479ce5546098 46 #include "lwip/sys.h"
sherckuith 0:479ce5546098 47 #include "lwip/timers.h"
sherckuith 0:479ce5546098 48
sherckuith 0:479ce5546098 49 /** Some defines for code we skip compared to the original pppd.
sherckuith 0:479ce5546098 50 * These are just here to minimise the use of the ugly "#if 0". */
sherckuith 0:479ce5546098 51 #define PPP_ADDITIONAL_CALLBACKS 0
sherckuith 0:479ce5546098 52
sherckuith 0:479ce5546098 53 /** Some error checks to test for unsupported code */
sherckuith 0:479ce5546098 54 #if CBCP_SUPPORT
sherckuith 0:479ce5546098 55 #error "CBCP is not supported in lwIP PPP"
sherckuith 0:479ce5546098 56 #endif
sherckuith 0:479ce5546098 57 #if CCP_SUPPORT
sherckuith 0:479ce5546098 58 #error "CCP is not supported in lwIP PPP"
sherckuith 0:479ce5546098 59 #endif
sherckuith 0:479ce5546098 60
sherckuith 0:479ce5546098 61 /*
sherckuith 0:479ce5546098 62 * pppd.h - PPP daemon global declarations.
sherckuith 0:479ce5546098 63 *
sherckuith 0:479ce5546098 64 * Copyright (c) 1989 Carnegie Mellon University.
sherckuith 0:479ce5546098 65 * All rights reserved.
sherckuith 0:479ce5546098 66 *
sherckuith 0:479ce5546098 67 * Redistribution and use in source and binary forms are permitted
sherckuith 0:479ce5546098 68 * provided that the above copyright notice and this paragraph are
sherckuith 0:479ce5546098 69 * duplicated in all such forms and that any documentation,
sherckuith 0:479ce5546098 70 * advertising materials, and other materials related to such
sherckuith 0:479ce5546098 71 * distribution and use acknowledge that the software was developed
sherckuith 0:479ce5546098 72 * by Carnegie Mellon University. The name of the
sherckuith 0:479ce5546098 73 * University may not be used to endorse or promote products derived
sherckuith 0:479ce5546098 74 * from this software without specific prior written permission.
sherckuith 0:479ce5546098 75 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
sherckuith 0:479ce5546098 76 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
sherckuith 0:479ce5546098 77 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
sherckuith 0:479ce5546098 78 *
sherckuith 0:479ce5546098 79 */
sherckuith 0:479ce5546098 80 /*
sherckuith 0:479ce5546098 81 * ppp_defs.h - PPP definitions.
sherckuith 0:479ce5546098 82 *
sherckuith 0:479ce5546098 83 * Copyright (c) 1994 The Australian National University.
sherckuith 0:479ce5546098 84 * All rights reserved.
sherckuith 0:479ce5546098 85 *
sherckuith 0:479ce5546098 86 * Permission to use, copy, modify, and distribute this software and its
sherckuith 0:479ce5546098 87 * documentation is hereby granted, provided that the above copyright
sherckuith 0:479ce5546098 88 * notice appears in all copies. This software is provided without any
sherckuith 0:479ce5546098 89 * warranty, express or implied. The Australian National University
sherckuith 0:479ce5546098 90 * makes no representations about the suitability of this software for
sherckuith 0:479ce5546098 91 * any purpose.
sherckuith 0:479ce5546098 92 *
sherckuith 0:479ce5546098 93 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
sherckuith 0:479ce5546098 94 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
sherckuith 0:479ce5546098 95 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
sherckuith 0:479ce5546098 96 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
sherckuith 0:479ce5546098 97 * OF SUCH DAMAGE.
sherckuith 0:479ce5546098 98 *
sherckuith 0:479ce5546098 99 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
sherckuith 0:479ce5546098 100 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
sherckuith 0:479ce5546098 101 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
sherckuith 0:479ce5546098 102 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
sherckuith 0:479ce5546098 103 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
sherckuith 0:479ce5546098 104 * OR MODIFICATIONS.
sherckuith 0:479ce5546098 105 */
sherckuith 0:479ce5546098 106
sherckuith 0:479ce5546098 107 #define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
sherckuith 0:479ce5546098 108 #define UNTIMEOUT(f, a) sys_untimeout((f), (a))
sherckuith 0:479ce5546098 109
sherckuith 0:479ce5546098 110
sherckuith 0:479ce5546098 111 #ifndef __u_char_defined
sherckuith 0:479ce5546098 112
sherckuith 0:479ce5546098 113 /* Type definitions for BSD code. */
sherckuith 0:479ce5546098 114 typedef unsigned long u_long;
sherckuith 0:479ce5546098 115 typedef unsigned int u_int;
sherckuith 0:479ce5546098 116 typedef unsigned short u_short;
sherckuith 0:479ce5546098 117 typedef unsigned char u_char;
sherckuith 0:479ce5546098 118
sherckuith 0:479ce5546098 119 #endif
sherckuith 0:479ce5546098 120
sherckuith 0:479ce5546098 121 /*
sherckuith 0:479ce5546098 122 * Constants and structures defined by the internet system,
sherckuith 0:479ce5546098 123 * Per RFC 790, September 1981, and numerous additions.
sherckuith 0:479ce5546098 124 */
sherckuith 0:479ce5546098 125
sherckuith 0:479ce5546098 126 /*
sherckuith 0:479ce5546098 127 * The basic PPP frame.
sherckuith 0:479ce5546098 128 */
sherckuith 0:479ce5546098 129 #define PPP_HDRLEN 4 /* octets for standard ppp header */
sherckuith 0:479ce5546098 130 #define PPP_FCSLEN 2 /* octets for FCS */
sherckuith 0:479ce5546098 131
sherckuith 0:479ce5546098 132
sherckuith 0:479ce5546098 133 /*
sherckuith 0:479ce5546098 134 * Significant octet values.
sherckuith 0:479ce5546098 135 */
sherckuith 0:479ce5546098 136 #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
sherckuith 0:479ce5546098 137 #define PPP_UI 0x03 /* Unnumbered Information */
sherckuith 0:479ce5546098 138 #define PPP_FLAG 0x7e /* Flag Sequence */
sherckuith 0:479ce5546098 139 #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
sherckuith 0:479ce5546098 140 #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
sherckuith 0:479ce5546098 141
sherckuith 0:479ce5546098 142 /*
sherckuith 0:479ce5546098 143 * Protocol field values.
sherckuith 0:479ce5546098 144 */
sherckuith 0:479ce5546098 145 #define PPP_IP 0x21 /* Internet Protocol */
sherckuith 0:479ce5546098 146 #define PPP_AT 0x29 /* AppleTalk Protocol */
sherckuith 0:479ce5546098 147 #define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
sherckuith 0:479ce5546098 148 #define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
sherckuith 0:479ce5546098 149 #define PPP_COMP 0xfd /* compressed packet */
sherckuith 0:479ce5546098 150 #define PPP_IPCP 0x8021 /* IP Control Protocol */
sherckuith 0:479ce5546098 151 #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
sherckuith 0:479ce5546098 152 #define PPP_CCP 0x80fd /* Compression Control Protocol */
sherckuith 0:479ce5546098 153 #define PPP_LCP 0xc021 /* Link Control Protocol */
sherckuith 0:479ce5546098 154 #define PPP_PAP 0xc023 /* Password Authentication Protocol */
sherckuith 0:479ce5546098 155 #define PPP_LQR 0xc025 /* Link Quality Report protocol */
sherckuith 0:479ce5546098 156 #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
sherckuith 0:479ce5546098 157 #define PPP_CBCP 0xc029 /* Callback Control Protocol */
sherckuith 0:479ce5546098 158
sherckuith 0:479ce5546098 159 /*
sherckuith 0:479ce5546098 160 * Values for FCS calculations.
sherckuith 0:479ce5546098 161 */
sherckuith 0:479ce5546098 162 #define PPP_INITFCS 0xffff /* Initial FCS value */
sherckuith 0:479ce5546098 163 #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
sherckuith 0:479ce5546098 164 #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
sherckuith 0:479ce5546098 165
sherckuith 0:479ce5546098 166 /*
sherckuith 0:479ce5546098 167 * Extended asyncmap - allows any character to be escaped.
sherckuith 0:479ce5546098 168 */
sherckuith 0:479ce5546098 169 typedef u_char ext_accm[32];
sherckuith 0:479ce5546098 170
sherckuith 0:479ce5546098 171 /*
sherckuith 0:479ce5546098 172 * What to do with network protocol (NP) packets.
sherckuith 0:479ce5546098 173 */
sherckuith 0:479ce5546098 174 enum NPmode {
sherckuith 0:479ce5546098 175 NPMODE_PASS, /* pass the packet through */
sherckuith 0:479ce5546098 176 NPMODE_DROP, /* silently drop the packet */
sherckuith 0:479ce5546098 177 NPMODE_ERROR, /* return an error */
sherckuith 0:479ce5546098 178 NPMODE_QUEUE /* save it up for later. */
sherckuith 0:479ce5546098 179 };
sherckuith 0:479ce5546098 180
sherckuith 0:479ce5546098 181 /*
sherckuith 0:479ce5546098 182 * Inline versions of get/put char/short/long.
sherckuith 0:479ce5546098 183 * Pointer is advanced; we assume that both arguments
sherckuith 0:479ce5546098 184 * are lvalues and will already be in registers.
sherckuith 0:479ce5546098 185 * cp MUST be u_char *.
sherckuith 0:479ce5546098 186 */
sherckuith 0:479ce5546098 187 #define GETCHAR(c, cp) { \
sherckuith 0:479ce5546098 188 (c) = *(cp)++; \
sherckuith 0:479ce5546098 189 }
sherckuith 0:479ce5546098 190 #define PUTCHAR(c, cp) { \
sherckuith 0:479ce5546098 191 *(cp)++ = (u_char) (c); \
sherckuith 0:479ce5546098 192 }
sherckuith 0:479ce5546098 193
sherckuith 0:479ce5546098 194
sherckuith 0:479ce5546098 195 #define GETSHORT(s, cp) { \
sherckuith 0:479ce5546098 196 (s) = *(cp); (cp)++; (s) <<= 8; \
sherckuith 0:479ce5546098 197 (s) |= *(cp); (cp)++; \
sherckuith 0:479ce5546098 198 }
sherckuith 0:479ce5546098 199 #define PUTSHORT(s, cp) { \
sherckuith 0:479ce5546098 200 *(cp)++ = (u_char) ((s) >> 8); \
sherckuith 0:479ce5546098 201 *(cp)++ = (u_char) (s & 0xff); \
sherckuith 0:479ce5546098 202 }
sherckuith 0:479ce5546098 203
sherckuith 0:479ce5546098 204 #define GETLONG(l, cp) { \
sherckuith 0:479ce5546098 205 (l) = *(cp); (cp)++; (l) <<= 8; \
sherckuith 0:479ce5546098 206 (l) |= *(cp); (cp)++; (l) <<= 8; \
sherckuith 0:479ce5546098 207 (l) |= *(cp); (cp)++; (l) <<= 8; \
sherckuith 0:479ce5546098 208 (l) |= *(cp); (cp)++; \
sherckuith 0:479ce5546098 209 }
sherckuith 0:479ce5546098 210 #define PUTLONG(l, cp) { \
sherckuith 0:479ce5546098 211 *(cp)++ = (u_char) ((l) >> 24); \
sherckuith 0:479ce5546098 212 *(cp)++ = (u_char) ((l) >> 16); \
sherckuith 0:479ce5546098 213 *(cp)++ = (u_char) ((l) >> 8); \
sherckuith 0:479ce5546098 214 *(cp)++ = (u_char) (l); \
sherckuith 0:479ce5546098 215 }
sherckuith 0:479ce5546098 216
sherckuith 0:479ce5546098 217
sherckuith 0:479ce5546098 218 #define INCPTR(n, cp) ((cp) += (n))
sherckuith 0:479ce5546098 219 #define DECPTR(n, cp) ((cp) -= (n))
sherckuith 0:479ce5546098 220
sherckuith 0:479ce5546098 221 #define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l))
sherckuith 0:479ce5546098 222 #define BCOPY(s, d, l) MEMCPY((d), (s), (l))
sherckuith 0:479ce5546098 223 #define BZERO(s, n) memset(s, 0, n)
sherckuith 0:479ce5546098 224
sherckuith 0:479ce5546098 225 #if PPP_DEBUG
sherckuith 0:479ce5546098 226 #define PRINTMSG(m, l) { m[l] = '\0'; LWIP_DEBUGF(LOG_INFO, ("Remote message: %s\n", m)); }
sherckuith 0:479ce5546098 227 #else /* PPP_DEBUG */
sherckuith 0:479ce5546098 228 #define PRINTMSG(m, l)
sherckuith 0:479ce5546098 229 #endif /* PPP_DEBUG */
sherckuith 0:479ce5546098 230
sherckuith 0:479ce5546098 231 /*
sherckuith 0:479ce5546098 232 * MAKEHEADER - Add PPP Header fields to a packet.
sherckuith 0:479ce5546098 233 */
sherckuith 0:479ce5546098 234 #define MAKEHEADER(p, t) { \
sherckuith 0:479ce5546098 235 PUTCHAR(PPP_ALLSTATIONS, p); \
sherckuith 0:479ce5546098 236 PUTCHAR(PPP_UI, p); \
sherckuith 0:479ce5546098 237 PUTSHORT(t, p); }
sherckuith 0:479ce5546098 238
sherckuith 0:479ce5546098 239 /*************************
sherckuith 0:479ce5546098 240 *** PUBLIC DEFINITIONS ***
sherckuith 0:479ce5546098 241 *************************/
sherckuith 0:479ce5546098 242
sherckuith 0:479ce5546098 243 /* Error codes. */
sherckuith 0:479ce5546098 244 #define PPPERR_NONE 0 /* No error. */
sherckuith 0:479ce5546098 245 #define PPPERR_PARAM -1 /* Invalid parameter. */
sherckuith 0:479ce5546098 246 #define PPPERR_OPEN -2 /* Unable to open PPP session. */
sherckuith 0:479ce5546098 247 #define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */
sherckuith 0:479ce5546098 248 #define PPPERR_ALLOC -4 /* Unable to allocate resources. */
sherckuith 0:479ce5546098 249 #define PPPERR_USER -5 /* User interrupt. */
sherckuith 0:479ce5546098 250 #define PPPERR_CONNECT -6 /* Connection lost. */
sherckuith 0:479ce5546098 251 #define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */
sherckuith 0:479ce5546098 252 #define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */
sherckuith 0:479ce5546098 253
sherckuith 0:479ce5546098 254 /*
sherckuith 0:479ce5546098 255 * PPP IOCTL commands.
sherckuith 0:479ce5546098 256 */
sherckuith 0:479ce5546098 257 /*
sherckuith 0:479ce5546098 258 * Get the up status - 0 for down, non-zero for up. The argument must
sherckuith 0:479ce5546098 259 * point to an int.
sherckuith 0:479ce5546098 260 */
sherckuith 0:479ce5546098 261 #define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */
sherckuith 0:479ce5546098 262 #define PPPCTLS_ERRCODE 101 /* Set the error code */
sherckuith 0:479ce5546098 263 #define PPPCTLG_ERRCODE 102 /* Get the error code */
sherckuith 0:479ce5546098 264 #define PPPCTLG_FD 103 /* Get the fd associated with the ppp */
sherckuith 0:479ce5546098 265
sherckuith 0:479ce5546098 266 /************************
sherckuith 0:479ce5546098 267 *** PUBLIC DATA TYPES ***
sherckuith 0:479ce5546098 268 ************************/
sherckuith 0:479ce5546098 269
sherckuith 0:479ce5546098 270 /*
sherckuith 0:479ce5546098 271 * The following struct gives the addresses of procedures to call
sherckuith 0:479ce5546098 272 * for a particular protocol.
sherckuith 0:479ce5546098 273 */
sherckuith 0:479ce5546098 274 struct protent {
sherckuith 0:479ce5546098 275 u_short protocol; /* PPP protocol number */
sherckuith 0:479ce5546098 276 /* Initialization procedure */
sherckuith 0:479ce5546098 277 void (*init) (int unit);
sherckuith 0:479ce5546098 278 /* Process a received packet */
sherckuith 0:479ce5546098 279 void (*input) (int unit, u_char *pkt, int len);
sherckuith 0:479ce5546098 280 /* Process a received protocol-reject */
sherckuith 0:479ce5546098 281 void (*protrej) (int unit);
sherckuith 0:479ce5546098 282 /* Lower layer has come up */
sherckuith 0:479ce5546098 283 void (*lowerup) (int unit);
sherckuith 0:479ce5546098 284 /* Lower layer has gone down */
sherckuith 0:479ce5546098 285 void (*lowerdown) (int unit);
sherckuith 0:479ce5546098 286 /* Open the protocol */
sherckuith 0:479ce5546098 287 void (*open) (int unit);
sherckuith 0:479ce5546098 288 /* Close the protocol */
sherckuith 0:479ce5546098 289 void (*close) (int unit, char *reason);
sherckuith 0:479ce5546098 290 #if PPP_ADDITIONAL_CALLBACKS
sherckuith 0:479ce5546098 291 /* Print a packet in readable form */
sherckuith 0:479ce5546098 292 int (*printpkt) (u_char *pkt, int len,
sherckuith 0:479ce5546098 293 void (*printer) (void *, char *, ...),
sherckuith 0:479ce5546098 294 void *arg);
sherckuith 0:479ce5546098 295 /* Process a received data packet */
sherckuith 0:479ce5546098 296 void (*datainput) (int unit, u_char *pkt, int len);
sherckuith 0:479ce5546098 297 #endif /* PPP_ADDITIONAL_CALLBACKS */
sherckuith 0:479ce5546098 298 int enabled_flag; /* 0 if protocol is disabled */
sherckuith 0:479ce5546098 299 char *name; /* Text name of protocol */
sherckuith 0:479ce5546098 300 #if PPP_ADDITIONAL_CALLBACKS
sherckuith 0:479ce5546098 301 /* Check requested options, assign defaults */
sherckuith 0:479ce5546098 302 void (*check_options) (u_long);
sherckuith 0:479ce5546098 303 /* Configure interface for demand-dial */
sherckuith 0:479ce5546098 304 int (*demand_conf) (int unit);
sherckuith 0:479ce5546098 305 /* Say whether to bring up link for this pkt */
sherckuith 0:479ce5546098 306 int (*active_pkt) (u_char *pkt, int len);
sherckuith 0:479ce5546098 307 #endif /* PPP_ADDITIONAL_CALLBACKS */
sherckuith 0:479ce5546098 308 };
sherckuith 0:479ce5546098 309
sherckuith 0:479ce5546098 310 /*
sherckuith 0:479ce5546098 311 * The following structure records the time in seconds since
sherckuith 0:479ce5546098 312 * the last NP packet was sent or received.
sherckuith 0:479ce5546098 313 */
sherckuith 0:479ce5546098 314 struct ppp_idle {
sherckuith 0:479ce5546098 315 u_short xmit_idle; /* seconds since last NP packet sent */
sherckuith 0:479ce5546098 316 u_short recv_idle; /* seconds since last NP packet received */
sherckuith 0:479ce5546098 317 };
sherckuith 0:479ce5546098 318
sherckuith 0:479ce5546098 319 struct ppp_settings {
sherckuith 0:479ce5546098 320
sherckuith 0:479ce5546098 321 u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */
sherckuith 0:479ce5546098 322 u_int auth_required : 1; /* Peer is required to authenticate */
sherckuith 0:479ce5546098 323 u_int explicit_remote : 1; /* remote_name specified with remotename opt */
sherckuith 0:479ce5546098 324 u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */
sherckuith 0:479ce5546098 325 u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */
sherckuith 0:479ce5546098 326 u_int usehostname : 1; /* Use hostname for our_name */
sherckuith 0:479ce5546098 327 u_int usepeerdns : 1; /* Ask peer for DNS adds */
sherckuith 0:479ce5546098 328
sherckuith 0:479ce5546098 329 u_short idle_time_limit; /* Shut down link if idle for this long */
sherckuith 0:479ce5546098 330 int maxconnect; /* Maximum connect time (seconds) */
sherckuith 0:479ce5546098 331
sherckuith 0:479ce5546098 332 char user [MAXNAMELEN + 1]; /* Username for PAP */
sherckuith 0:479ce5546098 333 char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
sherckuith 0:479ce5546098 334 char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */
sherckuith 0:479ce5546098 335 char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
sherckuith 0:479ce5546098 336 };
sherckuith 0:479ce5546098 337
sherckuith 0:479ce5546098 338 struct ppp_addrs {
sherckuith 0:479ce5546098 339 ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
sherckuith 0:479ce5546098 340 };
sherckuith 0:479ce5546098 341
sherckuith 0:479ce5546098 342 /*****************************
sherckuith 0:479ce5546098 343 *** PUBLIC DATA STRUCTURES ***
sherckuith 0:479ce5546098 344 *****************************/
sherckuith 0:479ce5546098 345
sherckuith 0:479ce5546098 346 /* Buffers for outgoing packets. */
sherckuith 0:479ce5546098 347 extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN];
sherckuith 0:479ce5546098 348
sherckuith 0:479ce5546098 349 extern struct ppp_settings ppp_settings;
sherckuith 0:479ce5546098 350
sherckuith 0:479ce5546098 351 extern struct protent *ppp_protocols[]; /* Table of pointers to supported protocols */
sherckuith 0:479ce5546098 352
sherckuith 0:479ce5546098 353
sherckuith 0:479ce5546098 354 /***********************
sherckuith 0:479ce5546098 355 *** PUBLIC FUNCTIONS ***
sherckuith 0:479ce5546098 356 ***********************/
sherckuith 0:479ce5546098 357
sherckuith 0:479ce5546098 358 /* Initialize the PPP subsystem. */
sherckuith 0:479ce5546098 359 void pppInit(void);
sherckuith 0:479ce5546098 360
sherckuith 0:479ce5546098 361 /* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
sherckuith 0:479ce5546098 362 * RFC 1994 says:
sherckuith 0:479ce5546098 363 *
sherckuith 0:479ce5546098 364 * In practice, within or associated with each PPP server, there is a
sherckuith 0:479ce5546098 365 * database which associates "user" names with authentication
sherckuith 0:479ce5546098 366 * information ("secrets"). It is not anticipated that a particular
sherckuith 0:479ce5546098 367 * named user would be authenticated by multiple methods. This would
sherckuith 0:479ce5546098 368 * make the user vulnerable to attacks which negotiate the least secure
sherckuith 0:479ce5546098 369 * method from among a set (such as PAP rather than CHAP). If the same
sherckuith 0:479ce5546098 370 * secret was used, PAP would reveal the secret to be used later with
sherckuith 0:479ce5546098 371 * CHAP.
sherckuith 0:479ce5546098 372 *
sherckuith 0:479ce5546098 373 * Instead, for each user name there should be an indication of exactly
sherckuith 0:479ce5546098 374 * one method used to authenticate that user name. If a user needs to
sherckuith 0:479ce5546098 375 * make use of different authentication methods under different
sherckuith 0:479ce5546098 376 * circumstances, then distinct user names SHOULD be employed, each of
sherckuith 0:479ce5546098 377 * which identifies exactly one authentication method.
sherckuith 0:479ce5546098 378 *
sherckuith 0:479ce5546098 379 */
sherckuith 0:479ce5546098 380 enum pppAuthType {
sherckuith 0:479ce5546098 381 PPPAUTHTYPE_NONE,
sherckuith 0:479ce5546098 382 PPPAUTHTYPE_ANY,
sherckuith 0:479ce5546098 383 PPPAUTHTYPE_PAP,
sherckuith 0:479ce5546098 384 PPPAUTHTYPE_CHAP
sherckuith 0:479ce5546098 385 };
sherckuith 0:479ce5546098 386
sherckuith 0:479ce5546098 387 void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
sherckuith 0:479ce5546098 388
sherckuith 0:479ce5546098 389 /*
sherckuith 0:479ce5546098 390 * Open a new PPP connection using the given serial I/O device.
sherckuith 0:479ce5546098 391 * This initializes the PPP control block but does not
sherckuith 0:479ce5546098 392 * attempt to negotiate the LCP session.
sherckuith 0:479ce5546098 393 * Return a new PPP connection descriptor on success or
sherckuith 0:479ce5546098 394 * an error code (negative) on failure.
sherckuith 0:479ce5546098 395 */
sherckuith 0:479ce5546098 396 int pppOverSerialOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx);
sherckuith 0:479ce5546098 397
sherckuith 0:479ce5546098 398 /*
sherckuith 0:479ce5546098 399 * Open a new PPP Over Ethernet (PPPOE) connection.
sherckuith 0:479ce5546098 400 */
sherckuith 0:479ce5546098 401 int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx);
sherckuith 0:479ce5546098 402
sherckuith 0:479ce5546098 403 /* for source code compatibility */
sherckuith 0:479ce5546098 404 #define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
sherckuith 0:479ce5546098 405
sherckuith 0:479ce5546098 406 /*
sherckuith 0:479ce5546098 407 * Close a PPP connection and release the descriptor.
sherckuith 0:479ce5546098 408 * Any outstanding packets in the queues are dropped.
sherckuith 0:479ce5546098 409 * Return 0 on success, an error code on failure.
sherckuith 0:479ce5546098 410 */
sherckuith 0:479ce5546098 411 int pppClose(int pd);
sherckuith 0:479ce5546098 412
sherckuith 0:479ce5546098 413 /*
sherckuith 0:479ce5546098 414 * Indicate to the PPP process that the line has disconnected.
sherckuith 0:479ce5546098 415 */
sherckuith 0:479ce5546098 416 void pppSigHUP(int pd);
sherckuith 0:479ce5546098 417
sherckuith 0:479ce5546098 418 /*
sherckuith 0:479ce5546098 419 * Get and set parameters for the given connection.
sherckuith 0:479ce5546098 420 * Return 0 on success, an error code on failure.
sherckuith 0:479ce5546098 421 */
sherckuith 0:479ce5546098 422 int pppIOCtl(int pd, int cmd, void *arg);
sherckuith 0:479ce5546098 423
sherckuith 0:479ce5546098 424 /*
sherckuith 0:479ce5546098 425 * Return the Maximum Transmission Unit for the given PPP connection.
sherckuith 0:479ce5546098 426 */
sherckuith 0:479ce5546098 427 u_short pppMTU(int pd);
sherckuith 0:479ce5546098 428
sherckuith 0:479ce5546098 429 /*
sherckuith 0:479ce5546098 430 * Write n characters to a ppp link.
sherckuith 0:479ce5546098 431 * RETURN: >= 0 Number of characters written, -1 Failed to write to device.
sherckuith 0:479ce5546098 432 */
sherckuith 0:479ce5546098 433 int pppWrite(int pd, const u_char *s, int n);
sherckuith 0:479ce5546098 434
sherckuith 0:479ce5546098 435 void pppInProcOverEthernet(int pd, struct pbuf *pb);
sherckuith 0:479ce5546098 436
sherckuith 0:479ce5546098 437 struct pbuf *pppSingleBuf(struct pbuf *p);
sherckuith 0:479ce5546098 438
sherckuith 0:479ce5546098 439 void pppLinkTerminated(int pd);
sherckuith 0:479ce5546098 440
sherckuith 0:479ce5546098 441 void pppLinkDown(int pd);
sherckuith 0:479ce5546098 442
sherckuith 0:479ce5546098 443 void pppos_input(int pd, u_char* data, int len);
sherckuith 0:479ce5546098 444
sherckuith 0:479ce5546098 445 /* Configure i/f transmit parameters */
sherckuith 0:479ce5546098 446 void ppp_send_config (int, u16_t, u32_t, int, int);
sherckuith 0:479ce5546098 447 /* Set extended transmit ACCM */
sherckuith 0:479ce5546098 448 void ppp_set_xaccm (int, ext_accm *);
sherckuith 0:479ce5546098 449 /* Configure i/f receive parameters */
sherckuith 0:479ce5546098 450 void ppp_recv_config (int, int, u32_t, int, int);
sherckuith 0:479ce5546098 451 /* Find out how long link has been idle */
sherckuith 0:479ce5546098 452 int get_idle_time (int, struct ppp_idle *);
sherckuith 0:479ce5546098 453
sherckuith 0:479ce5546098 454 /* Configure VJ TCP header compression */
sherckuith 0:479ce5546098 455 int sifvjcomp (int, int, u8_t, u8_t);
sherckuith 0:479ce5546098 456 /* Configure i/f down (for IP) */
sherckuith 0:479ce5546098 457 int sifup (int);
sherckuith 0:479ce5546098 458 /* Set mode for handling packets for proto */
sherckuith 0:479ce5546098 459 int sifnpmode (int u, int proto, enum NPmode mode);
sherckuith 0:479ce5546098 460 /* Configure i/f down (for IP) */
sherckuith 0:479ce5546098 461 int sifdown (int);
sherckuith 0:479ce5546098 462 /* Configure IP addresses for i/f */
sherckuith 0:479ce5546098 463 int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t);
sherckuith 0:479ce5546098 464 /* Reset i/f IP addresses */
sherckuith 0:479ce5546098 465 int cifaddr (int, u32_t, u32_t);
sherckuith 0:479ce5546098 466 /* Create default route through i/f */
sherckuith 0:479ce5546098 467 int sifdefaultroute (int, u32_t, u32_t);
sherckuith 0:479ce5546098 468 /* Delete default route through i/f */
sherckuith 0:479ce5546098 469 int cifdefaultroute (int, u32_t, u32_t);
sherckuith 0:479ce5546098 470
sherckuith 0:479ce5546098 471 /* Get appropriate netmask for address */
sherckuith 0:479ce5546098 472 u32_t GetMask (u32_t);
sherckuith 0:479ce5546098 473
sherckuith 0:479ce5546098 474 #if LWIP_NETIF_STATUS_CALLBACK
sherckuith 0:479ce5546098 475 void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback);
sherckuith 0:479ce5546098 476 #endif /* LWIP_NETIF_STATUS_CALLBACK */
sherckuith 0:479ce5546098 477 #if LWIP_NETIF_LINK_CALLBACK
sherckuith 0:479ce5546098 478 void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback);
sherckuith 0:479ce5546098 479 #endif /* LWIP_NETIF_LINK_CALLBACK */
sherckuith 0:479ce5546098 480
sherckuith 0:479ce5546098 481 #endif /* PPP_SUPPORT */
sherckuith 0:479ce5546098 482
sherckuith 0:479ce5546098 483 #endif /* PPP_H */