WebSocketServer test

Dependencies:   mbed

Committer:
gtk2k
Date:
Sun Apr 29 03:58:08 2012 +0000
Revision:
0:74be48b504a5
WebSocketServer

Who changed what in which revision?

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