Copy of NetServicesMin with the HTTP Client library. Includes modification for HTTP servers which send the HTTP status line in its own packet.

Committer:
andrewbonney
Date:
Thu May 26 10:02:40 2011 +0000
Revision:
0:18dd877d2c77

        

Who changed what in which revision?

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