Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Committer:
mkersh3
Date:
Thu Apr 04 05:26:09 2013 +0000
Revision:
0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.

Who changed what in which revision?

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