Committer:
mbed714
Date:
Sat Sep 18 23:05:49 2010 +0000
Revision:
0:d616ece2d859

        

Who changed what in which revision?

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