EthernetNetIf

Dependents:   XBee_WiFi_EA_LPC4088

Committer:
hmike
Date:
Wed Nov 19 12:00:42 2014 +0000
Revision:
0:62580107d20c
EthernetNetIf

Who changed what in which revision?

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