Leest de waarde van een sensor binnen een maakt deze beschikbaar via internet

Dependencies:   NTPClient_NetServices mbed

Committer:
hendrikvincent
Date:
Mon Dec 02 09:01:23 2013 +0000
Revision:
0:05ccbd4f84f1
eerste programma;

Who changed what in which revision?

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