I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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