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