Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Committer:
segundo
Date:
Tue Nov 09 20:54:15 2010 +0000
Revision:
0:ac1725ba162c

        

Who changed what in which revision?

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