Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.
lwip/include/netif/etharp.h@0:ec559500a63f, 2011-04-08 (annotated)
- Committer:
- andrewbonney
- Date:
- Fri Apr 08 14:39:41 2011 +0000
- Revision:
- 0:ec559500a63f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewbonney | 0:ec559500a63f | 1 | /* |
andrewbonney | 0:ec559500a63f | 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
andrewbonney | 0:ec559500a63f | 3 | * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv> |
andrewbonney | 0:ec559500a63f | 4 | * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. |
andrewbonney | 0:ec559500a63f | 5 | * All rights reserved. |
andrewbonney | 0:ec559500a63f | 6 | * |
andrewbonney | 0:ec559500a63f | 7 | * Redistribution and use in source and binary forms, with or without modification, |
andrewbonney | 0:ec559500a63f | 8 | * are permitted provided that the following conditions are met: |
andrewbonney | 0:ec559500a63f | 9 | * |
andrewbonney | 0:ec559500a63f | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
andrewbonney | 0:ec559500a63f | 11 | * this list of conditions and the following disclaimer. |
andrewbonney | 0:ec559500a63f | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
andrewbonney | 0:ec559500a63f | 13 | * this list of conditions and the following disclaimer in the documentation |
andrewbonney | 0:ec559500a63f | 14 | * and/or other materials provided with the distribution. |
andrewbonney | 0:ec559500a63f | 15 | * 3. The name of the author may not be used to endorse or promote products |
andrewbonney | 0:ec559500a63f | 16 | * derived from this software without specific prior written permission. |
andrewbonney | 0:ec559500a63f | 17 | * |
andrewbonney | 0:ec559500a63f | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
andrewbonney | 0:ec559500a63f | 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
andrewbonney | 0:ec559500a63f | 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
andrewbonney | 0:ec559500a63f | 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
andrewbonney | 0:ec559500a63f | 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
andrewbonney | 0:ec559500a63f | 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
andrewbonney | 0:ec559500a63f | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
andrewbonney | 0:ec559500a63f | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
andrewbonney | 0:ec559500a63f | 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
andrewbonney | 0:ec559500a63f | 27 | * OF SUCH DAMAGE. |
andrewbonney | 0:ec559500a63f | 28 | * |
andrewbonney | 0:ec559500a63f | 29 | * This file is part of the lwIP TCP/IP stack. |
andrewbonney | 0:ec559500a63f | 30 | * |
andrewbonney | 0:ec559500a63f | 31 | * Author: Adam Dunkels <adam@sics.se> |
andrewbonney | 0:ec559500a63f | 32 | * |
andrewbonney | 0:ec559500a63f | 33 | */ |
andrewbonney | 0:ec559500a63f | 34 | |
andrewbonney | 0:ec559500a63f | 35 | #ifndef __NETIF_ETHARP_H__ |
andrewbonney | 0:ec559500a63f | 36 | #define __NETIF_ETHARP_H__ |
andrewbonney | 0:ec559500a63f | 37 | |
andrewbonney | 0:ec559500a63f | 38 | #include "lwip/opt.h" |
andrewbonney | 0:ec559500a63f | 39 | |
andrewbonney | 0:ec559500a63f | 40 | #if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ |
andrewbonney | 0:ec559500a63f | 41 | |
andrewbonney | 0:ec559500a63f | 42 | #include "lwip/pbuf.h" |
andrewbonney | 0:ec559500a63f | 43 | #include "lwip/ip_addr.h" |
andrewbonney | 0:ec559500a63f | 44 | #include "lwip/netif.h" |
andrewbonney | 0:ec559500a63f | 45 | #include "lwip/ip.h" |
andrewbonney | 0:ec559500a63f | 46 | |
andrewbonney | 0:ec559500a63f | 47 | #ifdef __cplusplus |
andrewbonney | 0:ec559500a63f | 48 | extern "C" { |
andrewbonney | 0:ec559500a63f | 49 | #endif |
andrewbonney | 0:ec559500a63f | 50 | |
andrewbonney | 0:ec559500a63f | 51 | #ifndef ETHARP_HWADDR_LEN |
andrewbonney | 0:ec559500a63f | 52 | #define ETHARP_HWADDR_LEN 6 |
andrewbonney | 0:ec559500a63f | 53 | #endif |
andrewbonney | 0:ec559500a63f | 54 | |
andrewbonney | 0:ec559500a63f | 55 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 56 | # include "arch/bpstruct.h" |
andrewbonney | 0:ec559500a63f | 57 | #endif |
andrewbonney | 0:ec559500a63f | 58 | PACK_STRUCT_BEGIN |
andrewbonney | 0:ec559500a63f | 59 | struct eth_addr { |
andrewbonney | 0:ec559500a63f | 60 | PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]); |
andrewbonney | 0:ec559500a63f | 61 | } PACK_STRUCT_STRUCT; |
andrewbonney | 0:ec559500a63f | 62 | PACK_STRUCT_END |
andrewbonney | 0:ec559500a63f | 63 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 64 | # include "arch/epstruct.h" |
andrewbonney | 0:ec559500a63f | 65 | #endif |
andrewbonney | 0:ec559500a63f | 66 | |
andrewbonney | 0:ec559500a63f | 67 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 68 | # include "arch/bpstruct.h" |
andrewbonney | 0:ec559500a63f | 69 | #endif |
andrewbonney | 0:ec559500a63f | 70 | PACK_STRUCT_BEGIN |
andrewbonney | 0:ec559500a63f | 71 | /* Ethernet header */ |
andrewbonney | 0:ec559500a63f | 72 | struct eth_hdr { |
andrewbonney | 0:ec559500a63f | 73 | #if ETH_PAD_SIZE |
andrewbonney | 0:ec559500a63f | 74 | PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); |
andrewbonney | 0:ec559500a63f | 75 | #endif |
andrewbonney | 0:ec559500a63f | 76 | PACK_STRUCT_FIELD(struct eth_addr dest); |
andrewbonney | 0:ec559500a63f | 77 | PACK_STRUCT_FIELD(struct eth_addr src); |
andrewbonney | 0:ec559500a63f | 78 | PACK_STRUCT_FIELD(u16_t type); |
andrewbonney | 0:ec559500a63f | 79 | } PACK_STRUCT_STRUCT; |
andrewbonney | 0:ec559500a63f | 80 | PACK_STRUCT_END |
andrewbonney | 0:ec559500a63f | 81 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 82 | # include "arch/epstruct.h" |
andrewbonney | 0:ec559500a63f | 83 | #endif |
andrewbonney | 0:ec559500a63f | 84 | |
andrewbonney | 0:ec559500a63f | 85 | #define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE) |
andrewbonney | 0:ec559500a63f | 86 | |
andrewbonney | 0:ec559500a63f | 87 | #if ETHARP_SUPPORT_VLAN |
andrewbonney | 0:ec559500a63f | 88 | |
andrewbonney | 0:ec559500a63f | 89 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 90 | # include "arch/bpstruct.h" |
andrewbonney | 0:ec559500a63f | 91 | #endif |
andrewbonney | 0:ec559500a63f | 92 | PACK_STRUCT_BEGIN |
andrewbonney | 0:ec559500a63f | 93 | /* VLAN header inserted between ethernet header and payload |
andrewbonney | 0:ec559500a63f | 94 | * if 'type' in ethernet header is ETHTYPE_VLAN. |
andrewbonney | 0:ec559500a63f | 95 | * See IEEE802.Q */ |
andrewbonney | 0:ec559500a63f | 96 | struct eth_vlan_hdr { |
andrewbonney | 0:ec559500a63f | 97 | PACK_STRUCT_FIELD(u16_t tpid); |
andrewbonney | 0:ec559500a63f | 98 | PACK_STRUCT_FIELD(u16_t prio_vid); |
andrewbonney | 0:ec559500a63f | 99 | } PACK_STRUCT_STRUCT; |
andrewbonney | 0:ec559500a63f | 100 | PACK_STRUCT_END |
andrewbonney | 0:ec559500a63f | 101 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 102 | # include "arch/epstruct.h" |
andrewbonney | 0:ec559500a63f | 103 | #endif |
andrewbonney | 0:ec559500a63f | 104 | |
andrewbonney | 0:ec559500a63f | 105 | #define SIZEOF_VLAN_HDR 4 |
andrewbonney | 0:ec559500a63f | 106 | #define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF) |
andrewbonney | 0:ec559500a63f | 107 | |
andrewbonney | 0:ec559500a63f | 108 | #endif /* ETHARP_SUPPORT_VLAN */ |
andrewbonney | 0:ec559500a63f | 109 | |
andrewbonney | 0:ec559500a63f | 110 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 111 | # include "arch/bpstruct.h" |
andrewbonney | 0:ec559500a63f | 112 | #endif |
andrewbonney | 0:ec559500a63f | 113 | PACK_STRUCT_BEGIN |
andrewbonney | 0:ec559500a63f | 114 | /* the ARP message, see RFC 826 ("Packet format") */ |
andrewbonney | 0:ec559500a63f | 115 | struct etharp_hdr { |
andrewbonney | 0:ec559500a63f | 116 | PACK_STRUCT_FIELD(u16_t hwtype); |
andrewbonney | 0:ec559500a63f | 117 | PACK_STRUCT_FIELD(u16_t proto); |
andrewbonney | 0:ec559500a63f | 118 | PACK_STRUCT_FIELD(u8_t hwlen); |
andrewbonney | 0:ec559500a63f | 119 | PACK_STRUCT_FIELD(u8_t protolen); |
andrewbonney | 0:ec559500a63f | 120 | PACK_STRUCT_FIELD(u16_t opcode); |
andrewbonney | 0:ec559500a63f | 121 | PACK_STRUCT_FIELD(struct eth_addr shwaddr); |
andrewbonney | 0:ec559500a63f | 122 | PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); |
andrewbonney | 0:ec559500a63f | 123 | PACK_STRUCT_FIELD(struct eth_addr dhwaddr); |
andrewbonney | 0:ec559500a63f | 124 | PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); |
andrewbonney | 0:ec559500a63f | 125 | } PACK_STRUCT_STRUCT; |
andrewbonney | 0:ec559500a63f | 126 | PACK_STRUCT_END |
andrewbonney | 0:ec559500a63f | 127 | #ifdef PACK_STRUCT_USE_INCLUDES |
andrewbonney | 0:ec559500a63f | 128 | # include "arch/epstruct.h" |
andrewbonney | 0:ec559500a63f | 129 | #endif |
andrewbonney | 0:ec559500a63f | 130 | |
andrewbonney | 0:ec559500a63f | 131 | #define SIZEOF_ETHARP_HDR 28 |
andrewbonney | 0:ec559500a63f | 132 | #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR) |
andrewbonney | 0:ec559500a63f | 133 | |
andrewbonney | 0:ec559500a63f | 134 | /* 5 seconds period */ |
andrewbonney | 0:ec559500a63f | 135 | #define ARP_TMR_INTERVAL 5000 |
andrewbonney | 0:ec559500a63f | 136 | |
andrewbonney | 0:ec559500a63f | 137 | #define ETHTYPE_ARP 0x0806 |
andrewbonney | 0:ec559500a63f | 138 | #define ETHTYPE_IP 0x0800 |
andrewbonney | 0:ec559500a63f | 139 | #define ETHTYPE_VLAN 0x8100 |
andrewbonney | 0:ec559500a63f | 140 | #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ |
andrewbonney | 0:ec559500a63f | 141 | #define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ |
andrewbonney | 0:ec559500a63f | 142 | |
andrewbonney | 0:ec559500a63f | 143 | /* MEMCPY-like macro to copy to/from struct eth_addr's that are local variables |
andrewbonney | 0:ec559500a63f | 144 | * or known to be 32-bit aligned within the protocol header. */ |
andrewbonney | 0:ec559500a63f | 145 | #ifndef ETHADDR32_COPY |
andrewbonney | 0:ec559500a63f | 146 | #define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) |
andrewbonney | 0:ec559500a63f | 147 | #endif |
andrewbonney | 0:ec559500a63f | 148 | |
andrewbonney | 0:ec559500a63f | 149 | /* MEMCPY-like macro to copy to/from struct eth_addr's that are no local |
andrewbonney | 0:ec559500a63f | 150 | * variables and known to be 16-bit aligned within the protocol header. */ |
andrewbonney | 0:ec559500a63f | 151 | #ifndef ETHADDR16_COPY |
andrewbonney | 0:ec559500a63f | 152 | #define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) |
andrewbonney | 0:ec559500a63f | 153 | #endif |
andrewbonney | 0:ec559500a63f | 154 | |
andrewbonney | 0:ec559500a63f | 155 | #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ |
andrewbonney | 0:ec559500a63f | 156 | |
andrewbonney | 0:ec559500a63f | 157 | /* ARP message types (opcodes) */ |
andrewbonney | 0:ec559500a63f | 158 | #define ARP_REQUEST 1 |
andrewbonney | 0:ec559500a63f | 159 | #define ARP_REPLY 2 |
andrewbonney | 0:ec559500a63f | 160 | |
andrewbonney | 0:ec559500a63f | 161 | /* Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) |
andrewbonney | 0:ec559500a63f | 162 | * to a filter function that returns the correct netif when using multiple |
andrewbonney | 0:ec559500a63f | 163 | * netifs on one hardware interface where the netif's low-level receive |
andrewbonney | 0:ec559500a63f | 164 | * routine cannot decide for the correct netif (e.g. when mapping multiple |
andrewbonney | 0:ec559500a63f | 165 | * IP addresses to one hardware interface). |
andrewbonney | 0:ec559500a63f | 166 | */ |
andrewbonney | 0:ec559500a63f | 167 | #ifndef LWIP_ARP_FILTER_NETIF |
andrewbonney | 0:ec559500a63f | 168 | #define LWIP_ARP_FILTER_NETIF 0 |
andrewbonney | 0:ec559500a63f | 169 | #endif |
andrewbonney | 0:ec559500a63f | 170 | |
andrewbonney | 0:ec559500a63f | 171 | #if ARP_QUEUEING |
andrewbonney | 0:ec559500a63f | 172 | /* struct for queueing outgoing packets for unknown address |
andrewbonney | 0:ec559500a63f | 173 | * defined here to be accessed by memp.h |
andrewbonney | 0:ec559500a63f | 174 | */ |
andrewbonney | 0:ec559500a63f | 175 | struct etharp_q_entry { |
andrewbonney | 0:ec559500a63f | 176 | struct etharp_q_entry *next; |
andrewbonney | 0:ec559500a63f | 177 | struct pbuf *p; |
andrewbonney | 0:ec559500a63f | 178 | }; |
andrewbonney | 0:ec559500a63f | 179 | #endif /* ARP_QUEUEING */ |
andrewbonney | 0:ec559500a63f | 180 | |
andrewbonney | 0:ec559500a63f | 181 | #define etharp_init() /* Compatibility define, not init needed. */ |
andrewbonney | 0:ec559500a63f | 182 | void etharp_tmr(void); |
andrewbonney | 0:ec559500a63f | 183 | s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, |
andrewbonney | 0:ec559500a63f | 184 | struct eth_addr **eth_ret, ip_addr_t **ip_ret); |
andrewbonney | 0:ec559500a63f | 185 | err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr); |
andrewbonney | 0:ec559500a63f | 186 | err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q); |
andrewbonney | 0:ec559500a63f | 187 | err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr); |
andrewbonney | 0:ec559500a63f | 188 | /* For Ethernet network interfaces, we might want to send "gratuitous ARP"; |
andrewbonney | 0:ec559500a63f | 189 | * this is an ARP packet sent by a node in order to spontaneously cause other |
andrewbonney | 0:ec559500a63f | 190 | * nodes to update an entry in their ARP cache. |
andrewbonney | 0:ec559500a63f | 191 | * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ |
andrewbonney | 0:ec559500a63f | 192 | #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) |
andrewbonney | 0:ec559500a63f | 193 | |
andrewbonney | 0:ec559500a63f | 194 | #if ETHARP_SUPPORT_STATIC_ENTRIES |
andrewbonney | 0:ec559500a63f | 195 | err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr); |
andrewbonney | 0:ec559500a63f | 196 | err_t etharp_remove_static_entry(ip_addr_t *ipaddr); |
andrewbonney | 0:ec559500a63f | 197 | #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ |
andrewbonney | 0:ec559500a63f | 198 | |
andrewbonney | 0:ec559500a63f | 199 | #if LWIP_AUTOIP |
andrewbonney | 0:ec559500a63f | 200 | err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, |
andrewbonney | 0:ec559500a63f | 201 | const struct eth_addr *ethdst_addr, |
andrewbonney | 0:ec559500a63f | 202 | const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr, |
andrewbonney | 0:ec559500a63f | 203 | const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr, |
andrewbonney | 0:ec559500a63f | 204 | const u16_t opcode); |
andrewbonney | 0:ec559500a63f | 205 | #endif /* LWIP_AUTOIP */ |
andrewbonney | 0:ec559500a63f | 206 | |
andrewbonney | 0:ec559500a63f | 207 | #endif /* LWIP_ARP */ |
andrewbonney | 0:ec559500a63f | 208 | |
andrewbonney | 0:ec559500a63f | 209 | err_t ethernet_input(struct pbuf *p, struct netif *netif); |
andrewbonney | 0:ec559500a63f | 210 | |
andrewbonney | 0:ec559500a63f | 211 | #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0) |
andrewbonney | 0:ec559500a63f | 212 | |
andrewbonney | 0:ec559500a63f | 213 | extern const struct eth_addr ethbroadcast, ethzero; |
andrewbonney | 0:ec559500a63f | 214 | |
andrewbonney | 0:ec559500a63f | 215 | #ifdef __cplusplus |
andrewbonney | 0:ec559500a63f | 216 | } |
andrewbonney | 0:ec559500a63f | 217 | #endif |
andrewbonney | 0:ec559500a63f | 218 | |
andrewbonney | 0:ec559500a63f | 219 | #endif /* LWIP_ARP || LWIP_ETHERNET */ |
andrewbonney | 0:ec559500a63f | 220 | |
andrewbonney | 0:ec559500a63f | 221 | #endif /* __NETIF_ARP_H__ */ |