fdsf

Dependents:   sisk_proj_stat MQTT Hello_FXOS8700Q WireFSHandControl ... more

Committer:
grzemich
Date:
Wed Dec 07 23:47:50 2016 +0000
Revision:
0:d7bd7384a37c
dgd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
grzemich 0:d7bd7384a37c 1 /*****************************************************************************
grzemich 0:d7bd7384a37c 2 * ppp_oe.h - PPP Over Ethernet implementation for lwIP.
grzemich 0:d7bd7384a37c 3 *
grzemich 0:d7bd7384a37c 4 * Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
grzemich 0:d7bd7384a37c 5 *
grzemich 0:d7bd7384a37c 6 * The authors hereby grant permission to use, copy, modify, distribute,
grzemich 0:d7bd7384a37c 7 * and license this software and its documentation for any purpose, provided
grzemich 0:d7bd7384a37c 8 * that existing copyright notices are retained in all copies and that this
grzemich 0:d7bd7384a37c 9 * notice and the following disclaimer are included verbatim in any
grzemich 0:d7bd7384a37c 10 * distributions. No written agreement, license, or royalty fee is required
grzemich 0:d7bd7384a37c 11 * for any of the authorized uses.
grzemich 0:d7bd7384a37c 12 *
grzemich 0:d7bd7384a37c 13 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
grzemich 0:d7bd7384a37c 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
grzemich 0:d7bd7384a37c 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
grzemich 0:d7bd7384a37c 16 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
grzemich 0:d7bd7384a37c 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
grzemich 0:d7bd7384a37c 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
grzemich 0:d7bd7384a37c 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
grzemich 0:d7bd7384a37c 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
grzemich 0:d7bd7384a37c 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
grzemich 0:d7bd7384a37c 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
grzemich 0:d7bd7384a37c 23 *
grzemich 0:d7bd7384a37c 24 ******************************************************************************
grzemich 0:d7bd7384a37c 25 * REVISION HISTORY
grzemich 0:d7bd7384a37c 26 *
grzemich 0:d7bd7384a37c 27 * 06-01-01 Marc Boucher <marc@mbsi.ca>
grzemich 0:d7bd7384a37c 28 * Ported to lwIP.
grzemich 0:d7bd7384a37c 29 *****************************************************************************/
grzemich 0:d7bd7384a37c 30
grzemich 0:d7bd7384a37c 31
grzemich 0:d7bd7384a37c 32
grzemich 0:d7bd7384a37c 33 /* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
grzemich 0:d7bd7384a37c 34
grzemich 0:d7bd7384a37c 35 /*-
grzemich 0:d7bd7384a37c 36 * Copyright (c) 2002 The NetBSD Foundation, Inc.
grzemich 0:d7bd7384a37c 37 * All rights reserved.
grzemich 0:d7bd7384a37c 38 *
grzemich 0:d7bd7384a37c 39 * This code is derived from software contributed to The NetBSD Foundation
grzemich 0:d7bd7384a37c 40 * by Martin Husemann <martin@NetBSD.org>.
grzemich 0:d7bd7384a37c 41 *
grzemich 0:d7bd7384a37c 42 * Redistribution and use in source and binary forms, with or without
grzemich 0:d7bd7384a37c 43 * modification, are permitted provided that the following conditions
grzemich 0:d7bd7384a37c 44 * are met:
grzemich 0:d7bd7384a37c 45 * 1. Redistributions of source code must retain the above copyright
grzemich 0:d7bd7384a37c 46 * notice, this list of conditions and the following disclaimer.
grzemich 0:d7bd7384a37c 47 * 2. Redistributions in binary form must reproduce the above copyright
grzemich 0:d7bd7384a37c 48 * notice, this list of conditions and the following disclaimer in the
grzemich 0:d7bd7384a37c 49 * documentation and/or other materials provided with the distribution.
grzemich 0:d7bd7384a37c 50 * 3. All advertising materials mentioning features or use of this software
grzemich 0:d7bd7384a37c 51 * must display the following acknowledgement:
grzemich 0:d7bd7384a37c 52 * This product includes software developed by the NetBSD
grzemich 0:d7bd7384a37c 53 * Foundation, Inc. and its contributors.
grzemich 0:d7bd7384a37c 54 * 4. Neither the name of The NetBSD Foundation nor the names of its
grzemich 0:d7bd7384a37c 55 * contributors may be used to endorse or promote products derived
grzemich 0:d7bd7384a37c 56 * from this software without specific prior written permission.
grzemich 0:d7bd7384a37c 57 *
grzemich 0:d7bd7384a37c 58 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
grzemich 0:d7bd7384a37c 59 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
grzemich 0:d7bd7384a37c 60 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
grzemich 0:d7bd7384a37c 61 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
grzemich 0:d7bd7384a37c 62 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
grzemich 0:d7bd7384a37c 63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
grzemich 0:d7bd7384a37c 64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
grzemich 0:d7bd7384a37c 65 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
grzemich 0:d7bd7384a37c 66 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
grzemich 0:d7bd7384a37c 67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
grzemich 0:d7bd7384a37c 68 * POSSIBILITY OF SUCH DAMAGE.
grzemich 0:d7bd7384a37c 69 */
grzemich 0:d7bd7384a37c 70 #ifndef PPP_OE_H
grzemich 0:d7bd7384a37c 71 #define PPP_OE_H
grzemich 0:d7bd7384a37c 72
grzemich 0:d7bd7384a37c 73 #include "lwip/opt.h"
grzemich 0:d7bd7384a37c 74
grzemich 0:d7bd7384a37c 75 #if PPPOE_SUPPORT > 0
grzemich 0:d7bd7384a37c 76
grzemich 0:d7bd7384a37c 77 #include "netif/etharp.h"
grzemich 0:d7bd7384a37c 78
grzemich 0:d7bd7384a37c 79 #ifdef PACK_STRUCT_USE_INCLUDES
grzemich 0:d7bd7384a37c 80 # include "arch/bpstruct.h"
grzemich 0:d7bd7384a37c 81 #endif
grzemich 0:d7bd7384a37c 82 PACK_STRUCT_BEGIN
grzemich 0:d7bd7384a37c 83 struct pppoehdr {
grzemich 0:d7bd7384a37c 84 PACK_STRUCT_FIELD(u8_t vertype);
grzemich 0:d7bd7384a37c 85 PACK_STRUCT_FIELD(u8_t code);
grzemich 0:d7bd7384a37c 86 PACK_STRUCT_FIELD(u16_t session);
grzemich 0:d7bd7384a37c 87 PACK_STRUCT_FIELD(u16_t plen);
grzemich 0:d7bd7384a37c 88 } PACK_STRUCT_STRUCT;
grzemich 0:d7bd7384a37c 89 PACK_STRUCT_END
grzemich 0:d7bd7384a37c 90 #ifdef PACK_STRUCT_USE_INCLUDES
grzemich 0:d7bd7384a37c 91 # include "arch/epstruct.h"
grzemich 0:d7bd7384a37c 92 #endif
grzemich 0:d7bd7384a37c 93
grzemich 0:d7bd7384a37c 94 #ifdef PACK_STRUCT_USE_INCLUDES
grzemich 0:d7bd7384a37c 95 # include "arch/bpstruct.h"
grzemich 0:d7bd7384a37c 96 #endif
grzemich 0:d7bd7384a37c 97 PACK_STRUCT_BEGIN
grzemich 0:d7bd7384a37c 98 struct pppoetag {
grzemich 0:d7bd7384a37c 99 PACK_STRUCT_FIELD(u16_t tag);
grzemich 0:d7bd7384a37c 100 PACK_STRUCT_FIELD(u16_t len);
grzemich 0:d7bd7384a37c 101 } PACK_STRUCT_STRUCT;
grzemich 0:d7bd7384a37c 102 PACK_STRUCT_END
grzemich 0:d7bd7384a37c 103 #ifdef PACK_STRUCT_USE_INCLUDES
grzemich 0:d7bd7384a37c 104 # include "arch/epstruct.h"
grzemich 0:d7bd7384a37c 105 #endif
grzemich 0:d7bd7384a37c 106
grzemich 0:d7bd7384a37c 107
grzemich 0:d7bd7384a37c 108 #define PPPOE_STATE_INITIAL 0
grzemich 0:d7bd7384a37c 109 #define PPPOE_STATE_PADI_SENT 1
grzemich 0:d7bd7384a37c 110 #define PPPOE_STATE_PADR_SENT 2
grzemich 0:d7bd7384a37c 111 #define PPPOE_STATE_SESSION 3
grzemich 0:d7bd7384a37c 112 #define PPPOE_STATE_CLOSING 4
grzemich 0:d7bd7384a37c 113 /* passive */
grzemich 0:d7bd7384a37c 114 #define PPPOE_STATE_PADO_SENT 1
grzemich 0:d7bd7384a37c 115
grzemich 0:d7bd7384a37c 116 #define PPPOE_HEADERLEN sizeof(struct pppoehdr)
grzemich 0:d7bd7384a37c 117 #define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */
grzemich 0:d7bd7384a37c 118
grzemich 0:d7bd7384a37c 119 #define PPPOE_TAG_EOL 0x0000 /* end of list */
grzemich 0:d7bd7384a37c 120 #define PPPOE_TAG_SNAME 0x0101 /* service name */
grzemich 0:d7bd7384a37c 121 #define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */
grzemich 0:d7bd7384a37c 122 #define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */
grzemich 0:d7bd7384a37c 123 #define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */
grzemich 0:d7bd7384a37c 124 #define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */
grzemich 0:d7bd7384a37c 125 #define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */
grzemich 0:d7bd7384a37c 126 #define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */
grzemich 0:d7bd7384a37c 127 #define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */
grzemich 0:d7bd7384a37c 128 #define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */
grzemich 0:d7bd7384a37c 129
grzemich 0:d7bd7384a37c 130 #define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */
grzemich 0:d7bd7384a37c 131 #define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */
grzemich 0:d7bd7384a37c 132 #define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */
grzemich 0:d7bd7384a37c 133 #define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */
grzemich 0:d7bd7384a37c 134 #define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */
grzemich 0:d7bd7384a37c 135
grzemich 0:d7bd7384a37c 136 #ifndef ETHERMTU
grzemich 0:d7bd7384a37c 137 #define ETHERMTU 1500
grzemich 0:d7bd7384a37c 138 #endif
grzemich 0:d7bd7384a37c 139
grzemich 0:d7bd7384a37c 140 /* two byte PPP protocol discriminator, then IP data */
grzemich 0:d7bd7384a37c 141 #define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
grzemich 0:d7bd7384a37c 142
grzemich 0:d7bd7384a37c 143 #ifndef PPPOE_MAX_AC_COOKIE_LEN
grzemich 0:d7bd7384a37c 144 #define PPPOE_MAX_AC_COOKIE_LEN 64
grzemich 0:d7bd7384a37c 145 #endif
grzemich 0:d7bd7384a37c 146
grzemich 0:d7bd7384a37c 147 struct pppoe_softc {
grzemich 0:d7bd7384a37c 148 struct pppoe_softc *next;
grzemich 0:d7bd7384a37c 149 struct netif *sc_ethif; /* ethernet interface we are using */
grzemich 0:d7bd7384a37c 150 int sc_pd; /* ppp unit number */
grzemich 0:d7bd7384a37c 151 void (*sc_linkStatusCB)(int pd, int up);
grzemich 0:d7bd7384a37c 152
grzemich 0:d7bd7384a37c 153 int sc_state; /* discovery phase or session connected */
grzemich 0:d7bd7384a37c 154 struct eth_addr sc_dest; /* hardware address of concentrator */
grzemich 0:d7bd7384a37c 155 u16_t sc_session; /* PPPoE session id */
grzemich 0:d7bd7384a37c 156
grzemich 0:d7bd7384a37c 157 #ifdef PPPOE_TODO
grzemich 0:d7bd7384a37c 158 char *sc_service_name; /* if != NULL: requested name of service */
grzemich 0:d7bd7384a37c 159 char *sc_concentrator_name; /* if != NULL: requested concentrator id */
grzemich 0:d7bd7384a37c 160 #endif /* PPPOE_TODO */
grzemich 0:d7bd7384a37c 161 u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
grzemich 0:d7bd7384a37c 162 size_t sc_ac_cookie_len; /* length of cookie data */
grzemich 0:d7bd7384a37c 163 #ifdef PPPOE_SERVER
grzemich 0:d7bd7384a37c 164 u8_t *sc_hunique; /* content of host unique we must echo back */
grzemich 0:d7bd7384a37c 165 size_t sc_hunique_len; /* length of host unique */
grzemich 0:d7bd7384a37c 166 #endif
grzemich 0:d7bd7384a37c 167 int sc_padi_retried; /* number of PADI retries already done */
grzemich 0:d7bd7384a37c 168 int sc_padr_retried; /* number of PADR retries already done */
grzemich 0:d7bd7384a37c 169 };
grzemich 0:d7bd7384a37c 170
grzemich 0:d7bd7384a37c 171
grzemich 0:d7bd7384a37c 172 #define pppoe_init() /* compatibility define, no initialization needed */
grzemich 0:d7bd7384a37c 173
grzemich 0:d7bd7384a37c 174 err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
grzemich 0:d7bd7384a37c 175 err_t pppoe_destroy(struct netif *ifp);
grzemich 0:d7bd7384a37c 176
grzemich 0:d7bd7384a37c 177 int pppoe_connect(struct pppoe_softc *sc);
grzemich 0:d7bd7384a37c 178 void pppoe_disconnect(struct pppoe_softc *sc);
grzemich 0:d7bd7384a37c 179
grzemich 0:d7bd7384a37c 180 void pppoe_disc_input(struct netif *netif, struct pbuf *p);
grzemich 0:d7bd7384a37c 181 void pppoe_data_input(struct netif *netif, struct pbuf *p);
grzemich 0:d7bd7384a37c 182
grzemich 0:d7bd7384a37c 183 err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
grzemich 0:d7bd7384a37c 184
grzemich 0:d7bd7384a37c 185 /** used in ppp.c */
grzemich 0:d7bd7384a37c 186 #define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
grzemich 0:d7bd7384a37c 187
grzemich 0:d7bd7384a37c 188 #endif /* PPPOE_SUPPORT */
grzemich 0:d7bd7384a37c 189
grzemich 0:d7bd7384a37c 190 #endif /* PPP_OE_H */