Dependents:   SNMPAgent HTTPServer think_speak_a cyassl-client ... more

Committer:
mamezu
Date:
Thu Dec 09 01:33:56 2010 +0000
Revision:
0:0f6c82fcde82

        

Who changed what in which revision?

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