Ethernet for Nucleo and Disco board STM32F746 works with gcc and arm. IAC is untested

Dependencies:   mbed-rtos

Dependents:   IMU_ethernet

Fork of F7_Ethernet by Dieter Graef

Committer:
rctaduio
Date:
Thu Oct 06 16:55:16 2016 +0000
Revision:
2:e0a4035b5cd1
Parent:
0:d26c1b55cfca
Ethernet library for F7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:d26c1b55cfca 1 /*****************************************************************************
DieterGraef 0:d26c1b55cfca 2 * ppp.h - Network Point to Point Protocol header file.
DieterGraef 0:d26c1b55cfca 3 *
DieterGraef 0:d26c1b55cfca 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
DieterGraef 0:d26c1b55cfca 5 * portions Copyright (c) 1997 Global Election Systems Inc.
DieterGraef 0:d26c1b55cfca 6 *
DieterGraef 0:d26c1b55cfca 7 * The authors hereby grant permission to use, copy, modify, distribute,
DieterGraef 0:d26c1b55cfca 8 * and license this software and its documentation for any purpose, provided
DieterGraef 0:d26c1b55cfca 9 * that existing copyright notices are retained in all copies and that this
DieterGraef 0:d26c1b55cfca 10 * notice and the following disclaimer are included verbatim in any
DieterGraef 0:d26c1b55cfca 11 * distributions. No written agreement, license, or royalty fee is required
DieterGraef 0:d26c1b55cfca 12 * for any of the authorized uses.
DieterGraef 0:d26c1b55cfca 13 *
DieterGraef 0:d26c1b55cfca 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
DieterGraef 0:d26c1b55cfca 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
DieterGraef 0:d26c1b55cfca 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
DieterGraef 0:d26c1b55cfca 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
DieterGraef 0:d26c1b55cfca 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
DieterGraef 0:d26c1b55cfca 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DieterGraef 0:d26c1b55cfca 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
DieterGraef 0:d26c1b55cfca 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
DieterGraef 0:d26c1b55cfca 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
DieterGraef 0:d26c1b55cfca 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
DieterGraef 0:d26c1b55cfca 24 *
DieterGraef 0:d26c1b55cfca 25 ******************************************************************************
DieterGraef 0:d26c1b55cfca 26 * REVISION HISTORY
DieterGraef 0:d26c1b55cfca 27 *
DieterGraef 0:d26c1b55cfca 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
DieterGraef 0:d26c1b55cfca 29 * Ported to lwIP.
DieterGraef 0:d26c1b55cfca 30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
DieterGraef 0:d26c1b55cfca 31 * Original derived from BSD codes.
DieterGraef 0:d26c1b55cfca 32 *****************************************************************************/
DieterGraef 0:d26c1b55cfca 33
DieterGraef 0:d26c1b55cfca 34 #ifndef PPP_IMPL_H
DieterGraef 0:d26c1b55cfca 35 #define PPP_IMPL_H
DieterGraef 0:d26c1b55cfca 36
DieterGraef 0:d26c1b55cfca 37 #include "lwip/opt.h"
DieterGraef 0:d26c1b55cfca 38
DieterGraef 0:d26c1b55cfca 39 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
DieterGraef 0:d26c1b55cfca 40
DieterGraef 0:d26c1b55cfca 41 #include "ppp.h"
DieterGraef 0:d26c1b55cfca 42 #include "lwip/def.h"
DieterGraef 0:d26c1b55cfca 43 #include "lwip/sio.h"
DieterGraef 0:d26c1b55cfca 44 #include "lwip/stats.h"
DieterGraef 0:d26c1b55cfca 45 #include "lwip/mem.h"
DieterGraef 0:d26c1b55cfca 46 #include "lwip/netif.h"
DieterGraef 0:d26c1b55cfca 47 #include "lwip/sys.h"
DieterGraef 0:d26c1b55cfca 48 #include "lwip/timers.h"
DieterGraef 0:d26c1b55cfca 49
DieterGraef 0:d26c1b55cfca 50 /** Some defines for code we skip compared to the original pppd.
DieterGraef 0:d26c1b55cfca 51 * These are just here to minimise the use of the ugly "#if 0". */
DieterGraef 0:d26c1b55cfca 52 #define PPP_ADDITIONAL_CALLBACKS 0
DieterGraef 0:d26c1b55cfca 53
DieterGraef 0:d26c1b55cfca 54 /** Some error checks to test for unsupported code */
DieterGraef 0:d26c1b55cfca 55 #if CBCP_SUPPORT
DieterGraef 0:d26c1b55cfca 56 #error "CBCP is not supported in lwIP PPP"
DieterGraef 0:d26c1b55cfca 57 #endif
DieterGraef 0:d26c1b55cfca 58 #if CCP_SUPPORT
DieterGraef 0:d26c1b55cfca 59 #error "CCP is not supported in lwIP PPP"
DieterGraef 0:d26c1b55cfca 60 #endif
DieterGraef 0:d26c1b55cfca 61
DieterGraef 0:d26c1b55cfca 62 /*
DieterGraef 0:d26c1b55cfca 63 * pppd.h - PPP daemon global declarations.
DieterGraef 0:d26c1b55cfca 64 *
DieterGraef 0:d26c1b55cfca 65 * Copyright (c) 1989 Carnegie Mellon University.
DieterGraef 0:d26c1b55cfca 66 * All rights reserved.
DieterGraef 0:d26c1b55cfca 67 *
DieterGraef 0:d26c1b55cfca 68 * Redistribution and use in source and binary forms are permitted
DieterGraef 0:d26c1b55cfca 69 * provided that the above copyright notice and this paragraph are
DieterGraef 0:d26c1b55cfca 70 * duplicated in all such forms and that any documentation,
DieterGraef 0:d26c1b55cfca 71 * advertising materials, and other materials related to such
DieterGraef 0:d26c1b55cfca 72 * distribution and use acknowledge that the software was developed
DieterGraef 0:d26c1b55cfca 73 * by Carnegie Mellon University. The name of the
DieterGraef 0:d26c1b55cfca 74 * University may not be used to endorse or promote products derived
DieterGraef 0:d26c1b55cfca 75 * from this software without specific prior written permission.
DieterGraef 0:d26c1b55cfca 76 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
DieterGraef 0:d26c1b55cfca 77 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
DieterGraef 0:d26c1b55cfca 78 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
DieterGraef 0:d26c1b55cfca 79 *
DieterGraef 0:d26c1b55cfca 80 */
DieterGraef 0:d26c1b55cfca 81 /*
DieterGraef 0:d26c1b55cfca 82 * ppp_defs.h - PPP definitions.
DieterGraef 0:d26c1b55cfca 83 *
DieterGraef 0:d26c1b55cfca 84 * Copyright (c) 1994 The Australian National University.
DieterGraef 0:d26c1b55cfca 85 * All rights reserved.
DieterGraef 0:d26c1b55cfca 86 *
DieterGraef 0:d26c1b55cfca 87 * Permission to use, copy, modify, and distribute this software and its
DieterGraef 0:d26c1b55cfca 88 * documentation is hereby granted, provided that the above copyright
DieterGraef 0:d26c1b55cfca 89 * notice appears in all copies. This software is provided without any
DieterGraef 0:d26c1b55cfca 90 * warranty, express or implied. The Australian National University
DieterGraef 0:d26c1b55cfca 91 * makes no representations about the suitability of this software for
DieterGraef 0:d26c1b55cfca 92 * any purpose.
DieterGraef 0:d26c1b55cfca 93 *
DieterGraef 0:d26c1b55cfca 94 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
DieterGraef 0:d26c1b55cfca 95 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
DieterGraef 0:d26c1b55cfca 96 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
DieterGraef 0:d26c1b55cfca 97 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
DieterGraef 0:d26c1b55cfca 98 * OF SUCH DAMAGE.
DieterGraef 0:d26c1b55cfca 99 *
DieterGraef 0:d26c1b55cfca 100 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
DieterGraef 0:d26c1b55cfca 101 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
DieterGraef 0:d26c1b55cfca 102 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
DieterGraef 0:d26c1b55cfca 103 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
DieterGraef 0:d26c1b55cfca 104 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
DieterGraef 0:d26c1b55cfca 105 * OR MODIFICATIONS.
DieterGraef 0:d26c1b55cfca 106 */
DieterGraef 0:d26c1b55cfca 107
DieterGraef 0:d26c1b55cfca 108 #define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
DieterGraef 0:d26c1b55cfca 109 #define UNTIMEOUT(f, a) sys_untimeout((f), (a))
DieterGraef 0:d26c1b55cfca 110
DieterGraef 0:d26c1b55cfca 111
DieterGraef 0:d26c1b55cfca 112 /*
DieterGraef 0:d26c1b55cfca 113 * Constants and structures defined by the internet system,
DieterGraef 0:d26c1b55cfca 114 * Per RFC 790, September 1981, and numerous additions.
DieterGraef 0:d26c1b55cfca 115 */
DieterGraef 0:d26c1b55cfca 116
DieterGraef 0:d26c1b55cfca 117 /*
DieterGraef 0:d26c1b55cfca 118 * The basic PPP frame.
DieterGraef 0:d26c1b55cfca 119 */
DieterGraef 0:d26c1b55cfca 120 #define PPP_HDRLEN 4 /* octets for standard ppp header */
DieterGraef 0:d26c1b55cfca 121 #define PPP_FCSLEN 2 /* octets for FCS */
DieterGraef 0:d26c1b55cfca 122
DieterGraef 0:d26c1b55cfca 123
DieterGraef 0:d26c1b55cfca 124 /*
DieterGraef 0:d26c1b55cfca 125 * Significant octet values.
DieterGraef 0:d26c1b55cfca 126 */
DieterGraef 0:d26c1b55cfca 127 #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
DieterGraef 0:d26c1b55cfca 128 #define PPP_UI 0x03 /* Unnumbered Information */
DieterGraef 0:d26c1b55cfca 129 #define PPP_FLAG 0x7e /* Flag Sequence */
DieterGraef 0:d26c1b55cfca 130 #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
DieterGraef 0:d26c1b55cfca 131 #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
DieterGraef 0:d26c1b55cfca 132
DieterGraef 0:d26c1b55cfca 133 /*
DieterGraef 0:d26c1b55cfca 134 * Protocol field values.
DieterGraef 0:d26c1b55cfca 135 */
DieterGraef 0:d26c1b55cfca 136 #define PPP_IP 0x21 /* Internet Protocol */
DieterGraef 0:d26c1b55cfca 137 #define PPP_AT 0x29 /* AppleTalk Protocol */
DieterGraef 0:d26c1b55cfca 138 #define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
DieterGraef 0:d26c1b55cfca 139 #define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
DieterGraef 0:d26c1b55cfca 140 #define PPP_COMP 0xfd /* compressed packet */
DieterGraef 0:d26c1b55cfca 141 #define PPP_IPCP 0x8021 /* IP Control Protocol */
DieterGraef 0:d26c1b55cfca 142 #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
DieterGraef 0:d26c1b55cfca 143 #define PPP_CCP 0x80fd /* Compression Control Protocol */
DieterGraef 0:d26c1b55cfca 144 #define PPP_LCP 0xc021 /* Link Control Protocol */
DieterGraef 0:d26c1b55cfca 145 #define PPP_PAP 0xc023 /* Password Authentication Protocol */
DieterGraef 0:d26c1b55cfca 146 #define PPP_LQR 0xc025 /* Link Quality Report protocol */
DieterGraef 0:d26c1b55cfca 147 #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
DieterGraef 0:d26c1b55cfca 148 #define PPP_CBCP 0xc029 /* Callback Control Protocol */
DieterGraef 0:d26c1b55cfca 149
DieterGraef 0:d26c1b55cfca 150 /*
DieterGraef 0:d26c1b55cfca 151 * Values for FCS calculations.
DieterGraef 0:d26c1b55cfca 152 */
DieterGraef 0:d26c1b55cfca 153 #define PPP_INITFCS 0xffff /* Initial FCS value */
DieterGraef 0:d26c1b55cfca 154 #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
DieterGraef 0:d26c1b55cfca 155 #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
DieterGraef 0:d26c1b55cfca 156
DieterGraef 0:d26c1b55cfca 157 /*
DieterGraef 0:d26c1b55cfca 158 * Extended asyncmap - allows any character to be escaped.
DieterGraef 0:d26c1b55cfca 159 */
DieterGraef 0:d26c1b55cfca 160 typedef u_char ext_accm[32];
DieterGraef 0:d26c1b55cfca 161
DieterGraef 0:d26c1b55cfca 162 /*
DieterGraef 0:d26c1b55cfca 163 * What to do with network protocol (NP) packets.
DieterGraef 0:d26c1b55cfca 164 */
DieterGraef 0:d26c1b55cfca 165 enum NPmode {
DieterGraef 0:d26c1b55cfca 166 NPMODE_PASS, /* pass the packet through */
DieterGraef 0:d26c1b55cfca 167 NPMODE_DROP, /* silently drop the packet */
DieterGraef 0:d26c1b55cfca 168 NPMODE_ERROR, /* return an error */
DieterGraef 0:d26c1b55cfca 169 NPMODE_QUEUE /* save it up for later. */
DieterGraef 0:d26c1b55cfca 170 };
DieterGraef 0:d26c1b55cfca 171
DieterGraef 0:d26c1b55cfca 172 /*
DieterGraef 0:d26c1b55cfca 173 * Inline versions of get/put char/short/long.
DieterGraef 0:d26c1b55cfca 174 * Pointer is advanced; we assume that both arguments
DieterGraef 0:d26c1b55cfca 175 * are lvalues and will already be in registers.
DieterGraef 0:d26c1b55cfca 176 * cp MUST be u_char *.
DieterGraef 0:d26c1b55cfca 177 */
DieterGraef 0:d26c1b55cfca 178 #define GETCHAR(c, cp) { \
DieterGraef 0:d26c1b55cfca 179 (c) = *(cp)++; \
DieterGraef 0:d26c1b55cfca 180 }
DieterGraef 0:d26c1b55cfca 181 #define PUTCHAR(c, cp) { \
DieterGraef 0:d26c1b55cfca 182 *(cp)++ = (u_char) (c); \
DieterGraef 0:d26c1b55cfca 183 }
DieterGraef 0:d26c1b55cfca 184
DieterGraef 0:d26c1b55cfca 185
DieterGraef 0:d26c1b55cfca 186 #define GETSHORT(s, cp) { \
DieterGraef 0:d26c1b55cfca 187 (s) = *(cp); (cp)++; (s) <<= 8; \
DieterGraef 0:d26c1b55cfca 188 (s) |= *(cp); (cp)++; \
DieterGraef 0:d26c1b55cfca 189 }
DieterGraef 0:d26c1b55cfca 190 #define PUTSHORT(s, cp) { \
DieterGraef 0:d26c1b55cfca 191 *(cp)++ = (u_char) ((s) >> 8); \
DieterGraef 0:d26c1b55cfca 192 *(cp)++ = (u_char) (s & 0xff); \
DieterGraef 0:d26c1b55cfca 193 }
DieterGraef 0:d26c1b55cfca 194
DieterGraef 0:d26c1b55cfca 195 #define GETLONG(l, cp) { \
DieterGraef 0:d26c1b55cfca 196 (l) = *(cp); (cp)++; (l) <<= 8; \
DieterGraef 0:d26c1b55cfca 197 (l) |= *(cp); (cp)++; (l) <<= 8; \
DieterGraef 0:d26c1b55cfca 198 (l) |= *(cp); (cp)++; (l) <<= 8; \
DieterGraef 0:d26c1b55cfca 199 (l) |= *(cp); (cp)++; \
DieterGraef 0:d26c1b55cfca 200 }
DieterGraef 0:d26c1b55cfca 201 #define PUTLONG(l, cp) { \
DieterGraef 0:d26c1b55cfca 202 *(cp)++ = (u_char) ((l) >> 24); \
DieterGraef 0:d26c1b55cfca 203 *(cp)++ = (u_char) ((l) >> 16); \
DieterGraef 0:d26c1b55cfca 204 *(cp)++ = (u_char) ((l) >> 8); \
DieterGraef 0:d26c1b55cfca 205 *(cp)++ = (u_char) (l); \
DieterGraef 0:d26c1b55cfca 206 }
DieterGraef 0:d26c1b55cfca 207
DieterGraef 0:d26c1b55cfca 208
DieterGraef 0:d26c1b55cfca 209 #define INCPTR(n, cp) ((cp) += (n))
DieterGraef 0:d26c1b55cfca 210 #define DECPTR(n, cp) ((cp) -= (n))
DieterGraef 0:d26c1b55cfca 211
DieterGraef 0:d26c1b55cfca 212 #define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l))
DieterGraef 0:d26c1b55cfca 213 #define BCOPY(s, d, l) MEMCPY((d), (s), (l))
DieterGraef 0:d26c1b55cfca 214 #define BZERO(s, n) memset(s, 0, n)
DieterGraef 0:d26c1b55cfca 215
DieterGraef 0:d26c1b55cfca 216 #if PPP_DEBUG
DieterGraef 0:d26c1b55cfca 217 #define PRINTMSG(m, l) { m[l] = '\0'; LWIP_DEBUGF(LOG_INFO, ("Remote message: %s\n", m)); }
DieterGraef 0:d26c1b55cfca 218 #else /* PPP_DEBUG */
DieterGraef 0:d26c1b55cfca 219 #define PRINTMSG(m, l)
DieterGraef 0:d26c1b55cfca 220 #endif /* PPP_DEBUG */
DieterGraef 0:d26c1b55cfca 221
DieterGraef 0:d26c1b55cfca 222 /*
DieterGraef 0:d26c1b55cfca 223 * MAKEHEADER - Add PPP Header fields to a packet.
DieterGraef 0:d26c1b55cfca 224 */
DieterGraef 0:d26c1b55cfca 225 #define MAKEHEADER(p, t) { \
DieterGraef 0:d26c1b55cfca 226 PUTCHAR(PPP_ALLSTATIONS, p); \
DieterGraef 0:d26c1b55cfca 227 PUTCHAR(PPP_UI, p); \
DieterGraef 0:d26c1b55cfca 228 PUTSHORT(t, p); }
DieterGraef 0:d26c1b55cfca 229
DieterGraef 0:d26c1b55cfca 230 /************************
DieterGraef 0:d26c1b55cfca 231 *** PUBLIC DATA TYPES ***
DieterGraef 0:d26c1b55cfca 232 ************************/
DieterGraef 0:d26c1b55cfca 233
DieterGraef 0:d26c1b55cfca 234 /*
DieterGraef 0:d26c1b55cfca 235 * The following struct gives the addresses of procedures to call
DieterGraef 0:d26c1b55cfca 236 * for a particular protocol.
DieterGraef 0:d26c1b55cfca 237 */
DieterGraef 0:d26c1b55cfca 238 struct protent {
DieterGraef 0:d26c1b55cfca 239 u_short protocol; /* PPP protocol number */
DieterGraef 0:d26c1b55cfca 240 /* Initialization procedure */
DieterGraef 0:d26c1b55cfca 241 void (*init) (int unit);
DieterGraef 0:d26c1b55cfca 242 /* Process a received packet */
DieterGraef 0:d26c1b55cfca 243 void (*input) (int unit, u_char *pkt, int len);
DieterGraef 0:d26c1b55cfca 244 /* Process a received protocol-reject */
DieterGraef 0:d26c1b55cfca 245 void (*protrej) (int unit);
DieterGraef 0:d26c1b55cfca 246 /* Lower layer has come up */
DieterGraef 0:d26c1b55cfca 247 void (*lowerup) (int unit);
DieterGraef 0:d26c1b55cfca 248 /* Lower layer has gone down */
DieterGraef 0:d26c1b55cfca 249 void (*lowerdown) (int unit);
DieterGraef 0:d26c1b55cfca 250 /* Open the protocol */
DieterGraef 0:d26c1b55cfca 251 void (*open) (int unit);
DieterGraef 0:d26c1b55cfca 252 /* Close the protocol */
DieterGraef 0:d26c1b55cfca 253 void (*close) (int unit, char *reason);
DieterGraef 0:d26c1b55cfca 254 #if PPP_ADDITIONAL_CALLBACKS
DieterGraef 0:d26c1b55cfca 255 /* Print a packet in readable form */
DieterGraef 0:d26c1b55cfca 256 int (*printpkt) (u_char *pkt, int len,
DieterGraef 0:d26c1b55cfca 257 void (*printer) (void *, char *, ...),
DieterGraef 0:d26c1b55cfca 258 void *arg);
DieterGraef 0:d26c1b55cfca 259 /* Process a received data packet */
DieterGraef 0:d26c1b55cfca 260 void (*datainput) (int unit, u_char *pkt, int len);
DieterGraef 0:d26c1b55cfca 261 #endif /* PPP_ADDITIONAL_CALLBACKS */
DieterGraef 0:d26c1b55cfca 262 int enabled_flag; /* 0 if protocol is disabled */
DieterGraef 0:d26c1b55cfca 263 char *name; /* Text name of protocol */
DieterGraef 0:d26c1b55cfca 264 #if PPP_ADDITIONAL_CALLBACKS
DieterGraef 0:d26c1b55cfca 265 /* Check requested options, assign defaults */
DieterGraef 0:d26c1b55cfca 266 void (*check_options) (u_long);
DieterGraef 0:d26c1b55cfca 267 /* Configure interface for demand-dial */
DieterGraef 0:d26c1b55cfca 268 int (*demand_conf) (int unit);
DieterGraef 0:d26c1b55cfca 269 /* Say whether to bring up link for this pkt */
DieterGraef 0:d26c1b55cfca 270 int (*active_pkt) (u_char *pkt, int len);
DieterGraef 0:d26c1b55cfca 271 #endif /* PPP_ADDITIONAL_CALLBACKS */
DieterGraef 0:d26c1b55cfca 272 };
DieterGraef 0:d26c1b55cfca 273
DieterGraef 0:d26c1b55cfca 274 /*
DieterGraef 0:d26c1b55cfca 275 * The following structure records the time in seconds since
DieterGraef 0:d26c1b55cfca 276 * the last NP packet was sent or received.
DieterGraef 0:d26c1b55cfca 277 */
DieterGraef 0:d26c1b55cfca 278 struct ppp_idle {
DieterGraef 0:d26c1b55cfca 279 u_short xmit_idle; /* seconds since last NP packet sent */
DieterGraef 0:d26c1b55cfca 280 u_short recv_idle; /* seconds since last NP packet received */
DieterGraef 0:d26c1b55cfca 281 };
DieterGraef 0:d26c1b55cfca 282
DieterGraef 0:d26c1b55cfca 283 struct ppp_settings {
DieterGraef 0:d26c1b55cfca 284
DieterGraef 0:d26c1b55cfca 285 u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */
DieterGraef 0:d26c1b55cfca 286 u_int auth_required : 1; /* Peer is required to authenticate */
DieterGraef 0:d26c1b55cfca 287 u_int explicit_remote : 1; /* remote_name specified with remotename opt */
DieterGraef 0:d26c1b55cfca 288 u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */
DieterGraef 0:d26c1b55cfca 289 u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */
DieterGraef 0:d26c1b55cfca 290 u_int usehostname : 1; /* Use hostname for our_name */
DieterGraef 0:d26c1b55cfca 291 u_int usepeerdns : 1; /* Ask peer for DNS adds */
DieterGraef 0:d26c1b55cfca 292
DieterGraef 0:d26c1b55cfca 293 u_short idle_time_limit; /* Shut down link if idle for this long */
DieterGraef 0:d26c1b55cfca 294 int maxconnect; /* Maximum connect time (seconds) */
DieterGraef 0:d26c1b55cfca 295
DieterGraef 0:d26c1b55cfca 296 char user [MAXNAMELEN + 1]; /* Username for PAP */
DieterGraef 0:d26c1b55cfca 297 char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
DieterGraef 0:d26c1b55cfca 298 char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */
DieterGraef 0:d26c1b55cfca 299 char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
DieterGraef 0:d26c1b55cfca 300 };
DieterGraef 0:d26c1b55cfca 301
DieterGraef 0:d26c1b55cfca 302 /*****************************
DieterGraef 0:d26c1b55cfca 303 *** PUBLIC DATA STRUCTURES ***
DieterGraef 0:d26c1b55cfca 304 *****************************/
DieterGraef 0:d26c1b55cfca 305
DieterGraef 0:d26c1b55cfca 306 /* Buffers for outgoing packets. */
DieterGraef 0:d26c1b55cfca 307 extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN];
DieterGraef 0:d26c1b55cfca 308
DieterGraef 0:d26c1b55cfca 309 extern struct ppp_settings ppp_settings;
DieterGraef 0:d26c1b55cfca 310
DieterGraef 0:d26c1b55cfca 311 extern struct protent *ppp_protocols[]; /* Table of pointers to supported protocols */
DieterGraef 0:d26c1b55cfca 312
DieterGraef 0:d26c1b55cfca 313
DieterGraef 0:d26c1b55cfca 314 /***********************
DieterGraef 0:d26c1b55cfca 315 *** PUBLIC FUNCTIONS ***
DieterGraef 0:d26c1b55cfca 316 ***********************/
DieterGraef 0:d26c1b55cfca 317
DieterGraef 0:d26c1b55cfca 318 /*
DieterGraef 0:d26c1b55cfca 319 * Write n characters to a ppp link.
DieterGraef 0:d26c1b55cfca 320 * RETURN: >= 0 Number of characters written, -1 Failed to write to device.
DieterGraef 0:d26c1b55cfca 321 */
DieterGraef 0:d26c1b55cfca 322 int pppWrite(int pd, const u_char *s, int n);
DieterGraef 0:d26c1b55cfca 323
DieterGraef 0:d26c1b55cfca 324 void pppInProcOverEthernet(int pd, struct pbuf *pb);
DieterGraef 0:d26c1b55cfca 325
DieterGraef 0:d26c1b55cfca 326 struct pbuf *pppSingleBuf(struct pbuf *p);
DieterGraef 0:d26c1b55cfca 327
DieterGraef 0:d26c1b55cfca 328 void pppLinkTerminated(int pd);
DieterGraef 0:d26c1b55cfca 329
DieterGraef 0:d26c1b55cfca 330 void pppLinkDown(int pd);
DieterGraef 0:d26c1b55cfca 331
DieterGraef 0:d26c1b55cfca 332 /* Configure i/f transmit parameters */
DieterGraef 0:d26c1b55cfca 333 void ppp_send_config (int, u16_t, u32_t, int, int);
DieterGraef 0:d26c1b55cfca 334 /* Set extended transmit ACCM */
DieterGraef 0:d26c1b55cfca 335 void ppp_set_xaccm (int, ext_accm *);
DieterGraef 0:d26c1b55cfca 336 /* Configure i/f receive parameters */
DieterGraef 0:d26c1b55cfca 337 void ppp_recv_config (int, int, u32_t, int, int);
DieterGraef 0:d26c1b55cfca 338 /* Find out how long link has been idle */
DieterGraef 0:d26c1b55cfca 339 int get_idle_time (int, struct ppp_idle *);
DieterGraef 0:d26c1b55cfca 340
DieterGraef 0:d26c1b55cfca 341 /* Configure VJ TCP header compression */
DieterGraef 0:d26c1b55cfca 342 int sifvjcomp (int, int, u8_t, u8_t);
DieterGraef 0:d26c1b55cfca 343 /* Configure i/f down (for IP) */
DieterGraef 0:d26c1b55cfca 344 int sifup (int);
DieterGraef 0:d26c1b55cfca 345 /* Set mode for handling packets for proto */
DieterGraef 0:d26c1b55cfca 346 int sifnpmode (int u, int proto, enum NPmode mode);
DieterGraef 0:d26c1b55cfca 347 /* Configure i/f down (for IP) */
DieterGraef 0:d26c1b55cfca 348 int sifdown (int);
DieterGraef 0:d26c1b55cfca 349 /* Configure IP addresses for i/f */
DieterGraef 0:d26c1b55cfca 350 int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t);
DieterGraef 0:d26c1b55cfca 351 /* Reset i/f IP addresses */
DieterGraef 0:d26c1b55cfca 352 int cifaddr (int, u32_t, u32_t);
DieterGraef 0:d26c1b55cfca 353 /* Create default route through i/f */
DieterGraef 0:d26c1b55cfca 354 int sifdefaultroute (int, u32_t, u32_t);
DieterGraef 0:d26c1b55cfca 355 /* Delete default route through i/f */
DieterGraef 0:d26c1b55cfca 356 int cifdefaultroute (int, u32_t, u32_t);
DieterGraef 0:d26c1b55cfca 357
DieterGraef 0:d26c1b55cfca 358 /* Get appropriate netmask for address */
DieterGraef 0:d26c1b55cfca 359 u32_t GetMask (u32_t);
DieterGraef 0:d26c1b55cfca 360
DieterGraef 0:d26c1b55cfca 361 #endif /* PPP_SUPPORT */
DieterGraef 0:d26c1b55cfca 362
DieterGraef 0:d26c1b55cfca 363 #endif /* PPP_IMPL_H */