Dependents:   SNMPAgent HTTPServer think_speak_a cyassl-client ... more

Committer:
mamezu
Date:
Thu Dec 09 01:33:56 2010 +0000
Revision:
0:0f6c82fcde82

        

Who changed what in which revision?

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