Give water to plants if dry amd pla meanwhile music the music vou can define with note length bind and breake also select several instruments for the sound

Dependencies:   mbed

Committer:
helmut
Date:
Wed Sep 19 14:16:56 2012 +0000
Revision:
0:5150b09127e3
plays mostly music that you can do with notes length breakes and bind; Some already defined; Tool is to start a pump for water to give plant is too dry.; Meanwhie plays music the most part of all

Who changed what in which revision?

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