Experimental HTTPClient with proxy support

Committer:
igorsk
Date:
Wed Jun 29 16:01:58 2011 +0000
Revision:
0:b56b6a05cad4

        

Who changed what in which revision?

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