NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

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