Trial code integration web page update with analogue data and ntp support

Dependencies:   NTPClient_NetServices mbed

Committer:
pmr1
Date:
Fri Aug 06 17:57:45 2010 +0000
Revision:
0:8cc2035bebfc

        

Who changed what in which revision?

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