Hi. This is the feed program for Cosm. (The previous name of the services is Pachube.)

Dependencies:   mbed ThermistorPack Pachube ConfigFile EthernetNetIf TextLCD HTTPClient_ToBeRemoved FatFileSystem SDFileSystem

Committer:
shintamainjp
Date:
Mon Aug 06 12:37:59 2012 +0000
Revision:
0:521ba375aa0f
Pachube renamed to Cosm.

Who changed what in which revision?

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