KEIS

Dependents:   EthernetInterface

Fork of lwip by mbed official

Committer:
bogdanm
Date:
Tue Sep 10 15:14:39 2013 +0300
Revision:
13:931deec14b08
Parent:
0:51ac1d130fd4
Sync with git revision 171dda705c947bf910926a0b73d6a4797802554d

Who changed what in which revision?

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