Committer:
zoot661
Date:
Tue May 29 09:49:18 2012 +0000
Revision:
0:f993b6d8b1d8

        

Who changed what in which revision?

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