My fork of the HTTPServer (working)

Dependents:   DGWWebServer LAN2

Committer:
screamer
Date:
Mon Aug 06 09:23:14 2012 +0000
Revision:
0:7a64fbb4069d
[mbed] converted /DGWWebServer/HTTPServer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:7a64fbb4069d 1 /*
screamer 0:7a64fbb4069d 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
screamer 0:7a64fbb4069d 3 * All rights reserved.
screamer 0:7a64fbb4069d 4 *
screamer 0:7a64fbb4069d 5 * Redistribution and use in source and binary forms, with or without modification,
screamer 0:7a64fbb4069d 6 * are permitted provided that the following conditions are met:
screamer 0:7a64fbb4069d 7 *
screamer 0:7a64fbb4069d 8 * 1. Redistributions of source code must retain the above copyright notice,
screamer 0:7a64fbb4069d 9 * this list of conditions and the following disclaimer.
screamer 0:7a64fbb4069d 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
screamer 0:7a64fbb4069d 11 * this list of conditions and the following disclaimer in the documentation
screamer 0:7a64fbb4069d 12 * and/or other materials provided with the distribution.
screamer 0:7a64fbb4069d 13 * 3. The name of the author may not be used to endorse or promote products
screamer 0:7a64fbb4069d 14 * derived from this software without specific prior written permission.
screamer 0:7a64fbb4069d 15 *
screamer 0:7a64fbb4069d 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
screamer 0:7a64fbb4069d 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
screamer 0:7a64fbb4069d 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
screamer 0:7a64fbb4069d 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
screamer 0:7a64fbb4069d 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
screamer 0:7a64fbb4069d 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
screamer 0:7a64fbb4069d 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
screamer 0:7a64fbb4069d 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
screamer 0:7a64fbb4069d 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
screamer 0:7a64fbb4069d 25 * OF SUCH DAMAGE.
screamer 0:7a64fbb4069d 26 *
screamer 0:7a64fbb4069d 27 * This file is part of the lwIP TCP/IP stack.
screamer 0:7a64fbb4069d 28 *
screamer 0:7a64fbb4069d 29 * Author: Adam Dunkels <adam@sics.se>
screamer 0:7a64fbb4069d 30 *
screamer 0:7a64fbb4069d 31 */
screamer 0:7a64fbb4069d 32 #ifndef __LWIP_IP_H__
screamer 0:7a64fbb4069d 33 #define __LWIP_IP_H__
screamer 0:7a64fbb4069d 34
screamer 0:7a64fbb4069d 35 #include "lwip/opt.h"
screamer 0:7a64fbb4069d 36
screamer 0:7a64fbb4069d 37 #include "lwip/def.h"
screamer 0:7a64fbb4069d 38 #include "lwip/pbuf.h"
screamer 0:7a64fbb4069d 39 #include "lwip/ip_addr.h"
screamer 0:7a64fbb4069d 40 #include "lwip/err.h"
screamer 0:7a64fbb4069d 41
screamer 0:7a64fbb4069d 42 #ifdef __cplusplus
screamer 0:7a64fbb4069d 43 extern "C" {
screamer 0:7a64fbb4069d 44 #endif
screamer 0:7a64fbb4069d 45
screamer 0:7a64fbb4069d 46 #define ip_init() /* Compatibility define, not init needed. */
screamer 0:7a64fbb4069d 47 struct netif *ip_route(struct ip_addr *dest);
screamer 0:7a64fbb4069d 48 err_t ip_input(struct pbuf *p, struct netif *inp);
screamer 0:7a64fbb4069d 49 err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
screamer 0:7a64fbb4069d 50 u8_t ttl, u8_t tos, u8_t proto);
screamer 0:7a64fbb4069d 51 err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
screamer 0:7a64fbb4069d 52 u8_t ttl, u8_t tos, u8_t proto,
screamer 0:7a64fbb4069d 53 struct netif *netif);
screamer 0:7a64fbb4069d 54 #if LWIP_NETIF_HWADDRHINT
screamer 0:7a64fbb4069d 55 err_t ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
screamer 0:7a64fbb4069d 56 u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
screamer 0:7a64fbb4069d 57 #endif /* LWIP_NETIF_HWADDRHINT */
screamer 0:7a64fbb4069d 58
screamer 0:7a64fbb4069d 59 #define IP_HLEN 20
screamer 0:7a64fbb4069d 60
screamer 0:7a64fbb4069d 61 #define IP_PROTO_ICMP 1
screamer 0:7a64fbb4069d 62 #define IP_PROTO_UDP 17
screamer 0:7a64fbb4069d 63 #define IP_PROTO_UDPLITE 136
screamer 0:7a64fbb4069d 64 #define IP_PROTO_TCP 6
screamer 0:7a64fbb4069d 65
screamer 0:7a64fbb4069d 66 /* This is passed as the destination address to ip_output_if (not
screamer 0:7a64fbb4069d 67 to ip_output), meaning that an IP header already is constructed
screamer 0:7a64fbb4069d 68 in the pbuf. This is used when TCP retransmits. */
screamer 0:7a64fbb4069d 69 #ifdef IP_HDRINCL
screamer 0:7a64fbb4069d 70 #undef IP_HDRINCL
screamer 0:7a64fbb4069d 71 #endif /* IP_HDRINCL */
screamer 0:7a64fbb4069d 72 #define IP_HDRINCL NULL
screamer 0:7a64fbb4069d 73
screamer 0:7a64fbb4069d 74 #if LWIP_NETIF_HWADDRHINT
screamer 0:7a64fbb4069d 75 #define IP_PCB_ADDRHINT ;u8_t addr_hint
screamer 0:7a64fbb4069d 76 #else
screamer 0:7a64fbb4069d 77 #define IP_PCB_ADDRHINT
screamer 0:7a64fbb4069d 78 #endif /* LWIP_NETIF_HWADDRHINT */
screamer 0:7a64fbb4069d 79
screamer 0:7a64fbb4069d 80 /* This is the common part of all PCB types. It needs to be at the
screamer 0:7a64fbb4069d 81 beginning of a PCB type definition. It is located here so that
screamer 0:7a64fbb4069d 82 changes to this common part are made in one location instead of
screamer 0:7a64fbb4069d 83 having to change all PCB structs. */
screamer 0:7a64fbb4069d 84 #define IP_PCB \
screamer 0:7a64fbb4069d 85 /* ip addresses in network byte order */ \
screamer 0:7a64fbb4069d 86 struct ip_addr local_ip; \
screamer 0:7a64fbb4069d 87 struct ip_addr remote_ip; \
screamer 0:7a64fbb4069d 88 /* Socket options */ \
screamer 0:7a64fbb4069d 89 u16_t so_options; \
screamer 0:7a64fbb4069d 90 /* Type Of Service */ \
screamer 0:7a64fbb4069d 91 u8_t tos; \
screamer 0:7a64fbb4069d 92 /* Time To Live */ \
screamer 0:7a64fbb4069d 93 u8_t ttl \
screamer 0:7a64fbb4069d 94 /* link layer address resolution hint */ \
screamer 0:7a64fbb4069d 95 IP_PCB_ADDRHINT
screamer 0:7a64fbb4069d 96
screamer 0:7a64fbb4069d 97 struct ip_pcb {
screamer 0:7a64fbb4069d 98 /* Common members of all PCB types */
screamer 0:7a64fbb4069d 99 IP_PCB;
screamer 0:7a64fbb4069d 100 };
screamer 0:7a64fbb4069d 101
screamer 0:7a64fbb4069d 102 /*
screamer 0:7a64fbb4069d 103 * Option flags per-socket. These are the same like SO_XXX.
screamer 0:7a64fbb4069d 104 */
screamer 0:7a64fbb4069d 105 #define SOF_DEBUG (u16_t)0x0001U /* turn on debugging info recording */
screamer 0:7a64fbb4069d 106 #define SOF_ACCEPTCONN (u16_t)0x0002U /* socket has had listen() */
screamer 0:7a64fbb4069d 107 #define SOF_REUSEADDR (u16_t)0x0004U /* allow local address reuse */
screamer 0:7a64fbb4069d 108 #define SOF_KEEPALIVE (u16_t)0x0008U /* keep connections alive */
screamer 0:7a64fbb4069d 109 #define SOF_DONTROUTE (u16_t)0x0010U /* just use interface addresses */
screamer 0:7a64fbb4069d 110 #define SOF_BROADCAST (u16_t)0x0020U /* permit sending of broadcast msgs */
screamer 0:7a64fbb4069d 111 #define SOF_USELOOPBACK (u16_t)0x0040U /* bypass hardware when possible */
screamer 0:7a64fbb4069d 112 #define SOF_LINGER (u16_t)0x0080U /* linger on close if data present */
screamer 0:7a64fbb4069d 113 #define SOF_OOBINLINE (u16_t)0x0100U /* leave received OOB data in line */
screamer 0:7a64fbb4069d 114 #define SOF_REUSEPORT (u16_t)0x0200U /* allow local address & port reuse */
screamer 0:7a64fbb4069d 115
screamer 0:7a64fbb4069d 116
screamer 0:7a64fbb4069d 117 #ifdef PACK_STRUCT_USE_INCLUDES
screamer 0:7a64fbb4069d 118 # include "arch/bpstruct.h"
screamer 0:7a64fbb4069d 119 #endif
screamer 0:7a64fbb4069d 120 PACK_STRUCT_BEGIN
screamer 0:7a64fbb4069d 121 struct ip_hdr {
screamer 0:7a64fbb4069d 122 /* version / header length / type of service */
screamer 0:7a64fbb4069d 123 PACK_STRUCT_FIELD(u16_t _v_hl_tos);
screamer 0:7a64fbb4069d 124 /* total length */
screamer 0:7a64fbb4069d 125 PACK_STRUCT_FIELD(u16_t _len);
screamer 0:7a64fbb4069d 126 /* identification */
screamer 0:7a64fbb4069d 127 PACK_STRUCT_FIELD(u16_t _id);
screamer 0:7a64fbb4069d 128 /* fragment offset field */
screamer 0:7a64fbb4069d 129 PACK_STRUCT_FIELD(u16_t _offset);
screamer 0:7a64fbb4069d 130 #define IP_RF 0x8000 /* reserved fragment flag */
screamer 0:7a64fbb4069d 131 #define IP_DF 0x4000 /* dont fragment flag */
screamer 0:7a64fbb4069d 132 #define IP_MF 0x2000 /* more fragments flag */
screamer 0:7a64fbb4069d 133 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
screamer 0:7a64fbb4069d 134 /* time to live / protocol*/
screamer 0:7a64fbb4069d 135 PACK_STRUCT_FIELD(u16_t _ttl_proto);
screamer 0:7a64fbb4069d 136 /* checksum */
screamer 0:7a64fbb4069d 137 PACK_STRUCT_FIELD(u16_t _chksum);
screamer 0:7a64fbb4069d 138 /* source and destination IP addresses */
screamer 0:7a64fbb4069d 139 PACK_STRUCT_FIELD(struct ip_addr src);
screamer 0:7a64fbb4069d 140 PACK_STRUCT_FIELD(struct ip_addr dest);
screamer 0:7a64fbb4069d 141 } PACK_STRUCT_STRUCT;
screamer 0:7a64fbb4069d 142 PACK_STRUCT_END
screamer 0:7a64fbb4069d 143 #ifdef PACK_STRUCT_USE_INCLUDES
screamer 0:7a64fbb4069d 144 # include "arch/epstruct.h"
screamer 0:7a64fbb4069d 145 #endif
screamer 0:7a64fbb4069d 146
screamer 0:7a64fbb4069d 147 #define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
screamer 0:7a64fbb4069d 148 #define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
screamer 0:7a64fbb4069d 149 #define IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff)
screamer 0:7a64fbb4069d 150 #define IPH_LEN(hdr) ((hdr)->_len)
screamer 0:7a64fbb4069d 151 #define IPH_ID(hdr) ((hdr)->_id)
screamer 0:7a64fbb4069d 152 #define IPH_OFFSET(hdr) ((hdr)->_offset)
screamer 0:7a64fbb4069d 153 #define IPH_TTL(hdr) (ntohs((hdr)->_ttl_proto) >> 8)
screamer 0:7a64fbb4069d 154 #define IPH_PROTO(hdr) (ntohs((hdr)->_ttl_proto) & 0xff)
screamer 0:7a64fbb4069d 155 #define IPH_CHKSUM(hdr) ((hdr)->_chksum)
screamer 0:7a64fbb4069d 156
screamer 0:7a64fbb4069d 157 #define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
screamer 0:7a64fbb4069d 158 #define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
screamer 0:7a64fbb4069d 159 #define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
screamer 0:7a64fbb4069d 160 #define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
screamer 0:7a64fbb4069d 161 #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((u16_t)(ttl) << 8)))
screamer 0:7a64fbb4069d 162 #define IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))
screamer 0:7a64fbb4069d 163 #define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
screamer 0:7a64fbb4069d 164
screamer 0:7a64fbb4069d 165 #if IP_DEBUG
screamer 0:7a64fbb4069d 166 void ip_debug_print(struct pbuf *p);
screamer 0:7a64fbb4069d 167 #else
screamer 0:7a64fbb4069d 168 #define ip_debug_print(p)
screamer 0:7a64fbb4069d 169 #endif /* IP_DEBUG */
screamer 0:7a64fbb4069d 170
screamer 0:7a64fbb4069d 171 #ifdef __cplusplus
screamer 0:7a64fbb4069d 172 }
screamer 0:7a64fbb4069d 173 #endif
screamer 0:7a64fbb4069d 174
screamer 0:7a64fbb4069d 175 #endif /* __LWIP_IP_H__ */
screamer 0:7a64fbb4069d 176
screamer 0:7a64fbb4069d 177