Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:41:36 2011 +0000
Revision:
0:8f5825f330b0
setDataLen hacked to 180bytes

Who changed what in which revision?

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