HTTPClient using static IP

Dependencies:   mbed

Committer:
mr_q
Date:
Mon May 30 11:53:37 2011 +0000
Revision:
0:d8f2f7d5f31b
v0.01 Draft

Who changed what in which revision?

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