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