Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pppoe.h Source File

pppoe.h

00001 /*****************************************************************************
00002 * pppoe.h - PPP Over Ethernet implementation for lwIP.
00003 *
00004 * Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
00005 *
00006 * The authors hereby grant permission to use, copy, modify, distribute,
00007 * and license this software and its documentation for any purpose, provided
00008 * that existing copyright notices are retained in all copies and that this
00009 * notice and the following disclaimer are included verbatim in any 
00010 * distributions. No written agreement, license, or royalty fee is required
00011 * for any of the authorized uses.
00012 *
00013 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
00014 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00015 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
00016 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00017 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00018 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00019 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00020 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00021 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00022 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00023 *
00024 ******************************************************************************
00025 * REVISION HISTORY
00026 *
00027 * 06-01-01 Marc Boucher <marc@mbsi.ca>
00028 *   Ported to lwIP.
00029 *****************************************************************************/
00030 
00031 
00032 
00033 /* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
00034 
00035 /*-
00036  * Copyright (c) 2002 The NetBSD Foundation, Inc.
00037  * All rights reserved.
00038  *
00039  * This code is derived from software contributed to The NetBSD Foundation
00040  * by Martin Husemann <martin@NetBSD.org>.
00041  *
00042  * Redistribution and use in source and binary forms, with or without
00043  * modification, are permitted provided that the following conditions
00044  * are met:
00045  * 1. Redistributions of source code must retain the above copyright
00046  *    notice, this list of conditions and the following disclaimer.
00047  * 2. Redistributions in binary form must reproduce the above copyright
00048  *    notice, this list of conditions and the following disclaimer in the
00049  *    documentation and/or other materials provided with the distribution.
00050  * 3. All advertising materials mentioning features or use of this software
00051  *    must display the following acknowledgement:
00052  *        This product includes software developed by the NetBSD
00053  *        Foundation, Inc. and its contributors.
00054  * 4. Neither the name of The NetBSD Foundation nor the names of its
00055  *    contributors may be used to endorse or promote products derived
00056  *    from this software without specific prior written permission.
00057  *
00058  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
00059  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00060  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00061  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
00062  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00063  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00064  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00065  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00066  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00067  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00068  * POSSIBILITY OF SUCH DAMAGE.
00069  */
00070 #include "netif/ppp/ppp_opts.h"
00071 #if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
00072 
00073 #ifndef PPP_OE_H
00074 #define PPP_OE_H
00075 
00076 #include "ppp.h"
00077 #include "lwip/etharp.h"
00078 
00079 #ifdef PACK_STRUCT_USE_INCLUDES
00080 #  include "arch/bpstruct.h"
00081 #endif
00082 PACK_STRUCT_BEGIN
00083 struct pppoehdr {
00084   PACK_STRUCT_FLD_8(u8_t vertype);
00085   PACK_STRUCT_FLD_8(u8_t code);
00086   PACK_STRUCT_FIELD(u16_t session);
00087   PACK_STRUCT_FIELD(u16_t plen);
00088 } PACK_STRUCT_STRUCT;
00089 PACK_STRUCT_END
00090 #ifdef PACK_STRUCT_USE_INCLUDES
00091 #  include "arch/epstruct.h"
00092 #endif
00093 
00094 #ifdef PACK_STRUCT_USE_INCLUDES
00095 #  include "arch/bpstruct.h"
00096 #endif
00097 PACK_STRUCT_BEGIN
00098 struct pppoetag {
00099   PACK_STRUCT_FIELD(u16_t tag);
00100   PACK_STRUCT_FIELD(u16_t len);
00101 } PACK_STRUCT_STRUCT;
00102 PACK_STRUCT_END
00103 #ifdef PACK_STRUCT_USE_INCLUDES
00104 #  include "arch/epstruct.h"
00105 #endif
00106 
00107 
00108 #define PPPOE_STATE_INITIAL   0
00109 #define PPPOE_STATE_PADI_SENT 1
00110 #define PPPOE_STATE_PADR_SENT 2
00111 #define PPPOE_STATE_SESSION   3
00112 /* passive */
00113 #define PPPOE_STATE_PADO_SENT 1
00114 
00115 #define PPPOE_HEADERLEN       sizeof(struct pppoehdr)
00116 #define PPPOE_VERTYPE         0x11    /* VER=1, TYPE = 1 */
00117 
00118 #define PPPOE_TAG_EOL         0x0000  /* end of list */
00119 #define PPPOE_TAG_SNAME       0x0101  /* service name */
00120 #define PPPOE_TAG_ACNAME      0x0102  /* access concentrator name */
00121 #define PPPOE_TAG_HUNIQUE     0x0103  /* host unique */
00122 #define PPPOE_TAG_ACCOOKIE    0x0104  /* AC cookie */
00123 #define PPPOE_TAG_VENDOR      0x0105  /* vendor specific */
00124 #define PPPOE_TAG_RELAYSID    0x0110  /* relay session id */
00125 #define PPPOE_TAG_SNAME_ERR   0x0201  /* service name error */
00126 #define PPPOE_TAG_ACSYS_ERR   0x0202  /* AC system error */
00127 #define PPPOE_TAG_GENERIC_ERR 0x0203  /* gerneric error */
00128 
00129 #define PPPOE_CODE_PADI       0x09    /* Active Discovery Initiation */
00130 #define PPPOE_CODE_PADO       0x07    /* Active Discovery Offer */
00131 #define PPPOE_CODE_PADR       0x19    /* Active Discovery Request */
00132 #define PPPOE_CODE_PADS       0x65    /* Active Discovery Session confirmation */
00133 #define PPPOE_CODE_PADT       0xA7    /* Active Discovery Terminate */
00134 
00135 #ifndef PPPOE_MAX_AC_COOKIE_LEN
00136 #define PPPOE_MAX_AC_COOKIE_LEN   64
00137 #endif
00138 
00139 struct pppoe_softc {
00140   struct pppoe_softc *next;
00141   struct netif *sc_ethif;      /* ethernet interface we are using */
00142   ppp_pcb *pcb;                /* PPP PCB */
00143 
00144   struct eth_addr sc_dest;     /* hardware address of concentrator */
00145   u16_t sc_session;            /* PPPoE session id */
00146   u8_t sc_state;               /* discovery phase or session connected */
00147 
00148 #ifdef PPPOE_TODO
00149   u8_t *sc_service_name;       /* if != NULL: requested name of service */
00150   u8_t *sc_concentrator_name;  /* if != NULL: requested concentrator id */
00151 #endif /* PPPOE_TODO */
00152   u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
00153   u8_t sc_ac_cookie_len;       /* length of cookie data */
00154 #ifdef PPPOE_SERVER
00155   u8_t *sc_hunique;            /* content of host unique we must echo back */
00156   u8_t sc_hunique_len;         /* length of host unique */
00157 #endif
00158   u8_t sc_padi_retried;        /* number of PADI retries already done */
00159   u8_t sc_padr_retried;        /* number of PADR retries already done */
00160 };
00161 
00162 
00163 #define pppoe_init() /* compatibility define, no initialization needed */
00164 
00165 ppp_pcb *pppoe_create(struct netif *pppif,
00166        struct netif *ethif,
00167        const char *service_name, const char *concentrator_name,
00168        ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
00169 
00170 /*
00171  * Functions called from lwIP
00172  * DO NOT CALL FROM lwIP USER APPLICATION.
00173  */
00174 void pppoe_disc_input(struct netif *netif, struct pbuf *p);
00175 void pppoe_data_input(struct netif *netif, struct pbuf *p);
00176 
00177 #endif /* PPP_OE_H */
00178 
00179 #endif /* PPP_SUPPORT && PPPOE_SUPPORT */