I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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