Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Committer:
mkersh3
Date:
Thu Apr 04 05:26:09 2013 +0000
Revision:
0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.

Who changed what in which revision?

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