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