Index: src/include/ipv4/lwip/ip_addr.h =================================================================== RCS file: /cvsroot/lwip/lwip/src/include/ipv4/lwip/ip_addr.h,v retrieving revision 1.22 diff -u -r1.22 ip_addr.h --- src/include/ipv4/lwip/ip_addr.h 26 Mar 2004 13:21:10 -0000 1.22 +++ src/include/ipv4/lwip/ip_addr.h 27 Apr 2004 15:09:44 -0000 @@ -46,6 +46,18 @@ # include "arch/epstruct.h" #endif +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip_addr2 { + PACK_STRUCT_FIELD(u16_t addrw[2]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + /* For compatibility with BSD code */ struct in_addr { u32_t s_addr; Index: src/include/netif/etharp.h =================================================================== RCS file: /cvsroot/lwip/lwip/src/include/netif/etharp.h,v retrieving revision 1.11 diff -u -r1.11 etharp.h --- src/include/netif/etharp.h 7 Feb 2004 23:24:10 -0000 1.11 +++ src/include/netif/etharp.h 27 Apr 2004 15:09:44 -0000 @@ -33,6 +33,8 @@ #ifndef __NETIF_ETHARP_H__ #define __NETIF_ETHARP_H__ +#define PAD_ETH_SIZE 2 + #include "lwip/pbuf.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" @@ -49,6 +51,9 @@ PACK_STRUCT_BEGIN struct eth_hdr { +#if PAD_ETH_SIZE + PACK_STRUCT_FIELD(u8_t padding[PAD_ETH_SIZE]); +#endif PACK_STRUCT_FIELD(struct eth_addr dest); PACK_STRUCT_FIELD(struct eth_addr src); PACK_STRUCT_FIELD(u16_t type); @@ -64,9 +69,9 @@ PACK_STRUCT_FIELD(u16_t _hwlen_protolen); PACK_STRUCT_FIELD(u16_t opcode); PACK_STRUCT_FIELD(struct eth_addr shwaddr); - PACK_STRUCT_FIELD(struct ip_addr sipaddr); + PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); PACK_STRUCT_FIELD(struct eth_addr dhwaddr); - PACK_STRUCT_FIELD(struct ip_addr dipaddr); + PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); } PACK_STRUCT_STRUCT; PACK_STRUCT_END Index: src/netif/etharp.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/netif/etharp.c,v retrieving revision 1.54 diff -u -r1.54 etharp.c --- src/netif/etharp.c 22 Apr 2004 09:50:22 -0000 1.54 +++ src/netif/etharp.c 27 Apr 2004 15:09:44 -0000 @@ -133,7 +133,7 @@ static s8_t find_arp_entry(void); #define ARP_INSERT_FLAG 1 -static struct pbuf *update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags); +static struct pbuf *update_arp_entry(struct netif *netif, struct ip_addr2 *ipaddr, struct eth_addr *ethaddr, u8_t flags); #if ARP_QUEUEING static struct pbuf *etharp_enqueue(s8_t i, struct pbuf *q); static u8_t etharp_dequeue(s8_t i); @@ -329,7 +329,7 @@ * @see pbuf_free() */ static struct pbuf * -update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags) +update_arp_entry(struct netif *netif, struct ip_addr2 *ipaddr, struct eth_addr *ethaddr, u8_t flags) { s8_t i, k; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n")); @@ -337,7 +337,7 @@ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr), ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); /* do not update for 0.0.0.0 addresses */ - if (ipaddr->addr == 0) { + if (ipaddr->addrw[0] == 0 && ipaddr->addrw[1] == 0) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add 0.0.0.0 to ARP cache\n")); return NULL; } @@ -347,7 +347,7 @@ for (i = 0; i < ARP_TABLE_SIZE; ++i) { /* Check if the source IP address of the incoming packet matches the IP address in this ARP table entry. */ - if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { + if (!memcmp(ipaddr, &arp_table[i].ipaddr, sizeof(struct ip_addr))) { /* pending entry? */ if (arp_table[i].state == ETHARP_STATE_PENDING) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: pending entry %u goes stable\n", i)); @@ -480,7 +480,7 @@ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n")); /* update ARP table, ask to insert entry */ - update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG); + update_arp_entry(netif, (struct ip_addr2 *)&(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG); return NULL; } @@ -521,7 +521,7 @@ for_us = 0; } else { /* ARP packet directed to us? */ - for_us = ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr)); + for_us = !memcmp(&(hdr->dipaddr), &(netif->ip_addr), sizeof(struct ip_addr)); } /* add or update entries in the ARP cache */ @@ -556,8 +556,8 @@ /* re-use pbuf to send ARP reply */ hdr->opcode = htons(ARP_REPLY); - ip_addr_set(&(hdr->dipaddr), &(hdr->sipaddr)); - ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr)); + hdr->dipaddr = hdr->sipaddr; + hdr->sipaddr = *(struct ip_addr2 *)&netif->ip_addr; for(i = 0; i < netif->hwaddr_len; ++i) { hdr->dhwaddr.addr[i] = hdr->shwaddr.addr[i]; @@ -821,8 +821,8 @@ * a request it is a don't-care, we use 0's */ hdr->dhwaddr.addr[j] = 0x00; } - ip_addr_set(&(hdr->dipaddr), ipaddr); - ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr)); + hdr->dipaddr = *(struct ip_addr2 *)ipaddr; + hdr->sipaddr = *(struct ip_addr2 *)&netif->ip_addr; hdr->hwtype = htons(HWTYPE_ETHERNET); ARPH_HWLEN_SET(hdr, netif->hwaddr_len); Index: src/netif/ethernetif.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/netif/ethernetif.c,v retrieving revision 1.16 diff -u -r1.16 ethernetif.c --- src/netif/ethernetif.c 23 Apr 2004 15:24:36 -0000 1.16 +++ src/netif/ethernetif.c 27 Apr 2004 15:09:44 -0000 @@ -103,6 +103,10 @@ initiate transfer(); +#if PAD_ETH_SIZE + pbuf_header(p, -PAD_ETH_SIZE); /* drop the padding word */ +#endif + for(q = p; q != NULL; q = q->next) { /* Send the data from the pbuf to the interface, one pbuf at a time. The size of the data in each pbuf is kept in the ->len @@ -111,6 +115,10 @@ } signal that packet should be sent(); + +#if PAD_ETH_SIZE + pbuf_header(p, PAD_ETH_SIZE); /* reclaim the padding word */ +#endif #ifdef LINK_STATS lwip_stats.link.xmit++; @@ -137,10 +145,19 @@ variable. */ len = ; +#if PAD_ETH_SIZE + len += PAD_ETH_SIZE; /* allow room for Ethernet padding */ +#endif + /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); if (p != NULL) { + +#if PAD_ETH_SIZE + pbuf_header(p, -PAD_ETH_SIZE); /* drop the padding word */ +#endif + /* We iterate over the pbuf chain until we have read the entire packet into the pbuf. */ for(q = p; q != NULL; q = q->next) { @@ -150,6 +167,11 @@ read data into(q->payload, q->len); } acknowledge that packet has been read(); + +#if PAD_ETH_SIZE + pbuf_header(p, PAD_ETH_SIZE); /* reclaim the padding word */ +#endif + #ifdef LINK_STATS lwip_stats.link.recv++; #endif /* LINK_STATS */ @@ -237,7 +259,7 @@ switch (htons(ethhdr->type)) { case ETHTYPE_IP: q = etharp_ip_input(netif, p); - pbuf_header(p, -14); + pbuf_header(p, -sizeof(struct eth_hdr)); netif->input(p, netif); break;