code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.

Dependencies:   mbed

Committer:
eqon
Date:
Thu Jun 07 05:44:29 2012 +0000
Revision:
0:0ce833f21e63

        

Who changed what in which revision?

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