Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 10 19:56:45 2011 +0000
Revision:
1:b26ab2467b1a

        

Who changed what in which revision?

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