TwitterExample with newer library (2012Aug)

Dependencies:   EthernetNetIf HTTPClient mbed

Committer:
nxpfan
Date:
Wed Aug 29 03:50:19 2012 +0000
Revision:
0:075157567b0c
simple twitter example with newer library

Who changed what in which revision?

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