Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Thu Sep 26 00:44:20 2013 -0500
Revision:
5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point

Who changed what in which revision?

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