This library is stripped down version of NetServices library. HTTP server and client function is NOT supported.

Dependents:   imu-daq-eth

Committer:
idinor
Date:
Wed Jul 20 11:45:39 2011 +0000
Revision:
0:dcf3c92487ca

        

Who changed what in which revision?

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