This is the firmware for the LaOS - Laser Open Source project. You can use it to drive a laser cutter. For hardware and more information, look at our wiki: http://wiki.laoslaser.org

Dependencies:   EthernetNetIf mbed

Committer:
fablabtruck
Date:
Fri Jun 08 09:26:40 2012 +0000
Revision:
0:3852426a5068
svn revision 379

Who changed what in which revision?

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