http://mbed.org/users/okini3939/notebook/logger/

Dependencies:   mbed

Committer:
okini3939
Date:
Sat Apr 16 15:15:48 2011 +0000
Revision:
0:a3c892f39cc1

        

Who changed what in which revision?

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