Index: src/include/ipv4/lwip/ip_addr.h =================================================================== RCS file: /cvsroot/lwip/lwip/src/include/ipv4/lwip/ip_addr.h,v retrieving revision 1.24 diff -u -w -r1.24 ip_addr.h --- src/include/ipv4/lwip/ip_addr.h 28 Apr 2004 23:18:20 -0000 1.24 +++ src/include/ipv4/lwip/ip_addr.h 29 Apr 2004 09:27:45 -0000 @@ -116,7 +116,7 @@ #define ip_addr_set(dest, src) (dest)->addr = \ ((src) == NULL? 0:\ - ((struct ip_addr *)src)->addr) + (src)->addr) #define ip_addr_maskcmp(addr1, addr2, mask) (((addr1)->addr & \ (mask)->addr) == \ ((addr2)->addr & \ Index: src/netif/etharp.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/netif/etharp.c,v retrieving revision 1.56 diff -u -w -r1.56 etharp.c --- src/netif/etharp.c 28 Apr 2004 23:20:18 -0000 1.56 +++ src/netif/etharp.c 29 Apr 2004 09:27:45 -0000 @@ -135,7 +135,7 @@ static s8_t find_arp_entry(void); #define ARP_INSERT_FLAG 1 -static struct pbuf *update_arp_entry(struct netif *netif, struct ip_addr2 *ipaddr, struct eth_addr *ethaddr, u8_t flags); +static struct pbuf *update_arp_entry(struct netif *netif, struct ip_addr *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); @@ -331,15 +331,17 @@ * @see pbuf_free() */ static struct pbuf * -update_arp_entry(struct netif *netif, struct ip_addr2 *ipaddr, struct eth_addr *ethaddr, u8_t flags) +update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags) { s8_t i, k; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n")); LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0); - 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])); + 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->addrw[0] == 0 && ipaddr->addrw[1] == 0) { + if (ipaddr->addr == 0) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add 0.0.0.0 to ARP cache\n")); return NULL; } @@ -349,7 +351,8 @@ 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 (!memcmp(ipaddr, &arp_table[i].ipaddr, sizeof(struct ip_addr))) { + if (arp_table[i].state != ETHARP_STATE_EMPTY && + ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { /* 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)); @@ -482,7 +485,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, (struct ip_addr2 *)&(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG); + update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG); return NULL; } @@ -506,6 +509,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) { struct etharp_hdr *hdr; + struct ip_addr sipaddr, dipaddr; u8_t i; u8_t for_us; @@ -518,23 +522,27 @@ hdr = p->payload; + /* get aligned copies of addresses */ + *(struct ip_addr2 *)&sipaddr = hdr->sipaddr; + *(struct ip_addr2 *)&dipaddr = hdr->dipaddr; + /* this interface is not configured? */ if (netif->ip_addr.addr == 0) { for_us = 0; } else { /* ARP packet directed to us? */ - for_us = !memcmp(&(hdr->dipaddr), &(netif->ip_addr), sizeof(struct ip_addr)); + for_us = ip_addr_cmp(&dipaddr, &(netif->ip_addr)); } /* add or update entries in the ARP cache */ if (for_us) { /* insert IP address in ARP cache (assume requester wants to talk to us) * we might even send out a queued packet to this host */ - update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), ARP_INSERT_FLAG); + update_arp_entry(netif, &sipaddr, &(hdr->shwaddr), ARP_INSERT_FLAG); /* request was not directed to us, but snoop anyway */ } else { /* update the source IP address in the cache */ - update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0); + update_arp_entry(netif, &sipaddr, &(hdr->shwaddr), 0); } switch (htons(hdr->opcode)) { @@ -588,7 +596,7 @@ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n")); #if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) /* DHCP wants to know about ARP replies to our wanna-have-address */ - if (for_us) dhcp_arp_reply(netif, &hdr->sipaddr); + if (for_us) dhcp_arp_reply(netif, &sipaddr); #endif break; default: @@ -764,7 +772,8 @@ srcaddr = (struct eth_addr *)netif->hwaddr; /* bail out if this IP address is pending */ for (i = 0; i < ARP_TABLE_SIZE; ++i) { - if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { + if (arp_table[i].state != ETHARP_STATE_EMPTY && + ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { if (arp_table[i].state == ETHARP_STATE_PENDING) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already pending as entry %u\n", i)); /* break out of for-loop, user may wish to queue a packet on a pending entry */