Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

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