Onenet

Dependents:   K64F_eCompass_OneNET_JW

Committer:
robert_jw
Date:
Mon Jun 20 01:40:20 2016 +0000
Revision:
0:b2805b6888dc
ADS

Who changed what in which revision?

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