Daniel Peter / Mbed 2 deprecated cig_httpclient2

Dependencies:   mbed

Committer:
mbed714
Date:
Mon May 30 12:11:59 2011 +0000
Revision:
0:55680e5cc478

        

Who changed what in which revision?

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