testing of combination of LCS and LAN

Dependencies:   mbed

Committer:
damir
Date:
Wed Jan 14 13:29:55 2015 +0000
Revision:
0:a7a6a692162f
Test of LAN

Who changed what in which revision?

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