NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

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