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