japanese tweeting sample with newer version libraries

Dependencies:   TextLCD mbed

Committer:
nxpfan
Date:
Fri Aug 31 08:19:51 2012 +0000
Revision:
0:66c7c9c4f765
version with newer libraries

Who changed what in which revision?

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