12Oct2012MbedLab

Dependents:   Lab3_VoiceMeter

Fork of EthernetNetIf by Donatien Garnier

Committer:
psawant9
Date:
Fri Oct 12 16:02:00 2012 +0000
Revision:
6:22ce63eddd2b
Parent:
0:422060928e37
Done

Who changed what in which revision?

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