/[lwip]/lwip/src/netif/etharp.c
ViewVC logotype

Diff of /lwip/src/netif/etharp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.90 by likewise, Mon Jan 24 23:02:30 2005 UTC revision 1.91 by christiaans, Fri Nov 25 12:03:39 2005 UTC
# Line 146  etharp_tmr(void) Line 146  etharp_tmr(void)
146      if ((arp_table[i].state == ETHARP_STATE_STABLE) &&      if ((arp_table[i].state == ETHARP_STATE_STABLE) &&
147           /* entry has become old? */           /* entry has become old? */
148          (arp_table[i].ctime >= ARP_MAXAGE)) {          (arp_table[i].ctime >= ARP_MAXAGE)) {
149        LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %u.\n", i));        LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %"U16_F".\n", (u16_t)i));
150        arp_table[i].state = ETHARP_STATE_EXPIRED;        arp_table[i].state = ETHARP_STATE_EXPIRED;
151      /* pending entry? */      /* pending entry? */
152      } else if (arp_table[i].state == ETHARP_STATE_PENDING) {      } else if (arp_table[i].state == ETHARP_STATE_PENDING) {
153        /* entry unresolved/pending for too long? */        /* entry unresolved/pending for too long? */
154        if (arp_table[i].ctime >= ARP_MAXPENDING) {        if (arp_table[i].ctime >= ARP_MAXPENDING) {
155          LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %u.\n", i));          LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %"U16_F".\n", (u16_t)i));
156          arp_table[i].state = ETHARP_STATE_EXPIRED;          arp_table[i].state = ETHARP_STATE_EXPIRED;
157  #if ARP_QUEUEING  #if ARP_QUEUEING
158        } else if (arp_table[i].p != NULL) {        } else if (arp_table[i].p != NULL) {
# Line 166  etharp_tmr(void) Line 166  etharp_tmr(void)
166        /* and empty packet queue */        /* and empty packet queue */
167        if (arp_table[i].p != NULL) {        if (arp_table[i].p != NULL) {
168          /* remove all queued packets */          /* remove all queued packets */
169          LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %u, packet queue %p.\n", i, (void *)(arp_table[i].p)));          LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].p)));
170          pbuf_free(arp_table[i].p);          pbuf_free(arp_table[i].p);
171          arp_table[i].p = NULL;          arp_table[i].p = NULL;
172        }        }
# Line 229  static s8_t find_entry(struct ip_addr *i Line 229  static s8_t find_entry(struct ip_addr *i
229    for (i = 0; i < ARP_TABLE_SIZE; ++i) {    for (i = 0; i < ARP_TABLE_SIZE; ++i) {
230      /* no empty entry found yet and now we do find one? */      /* no empty entry found yet and now we do find one? */
231      if ((empty == ARP_TABLE_SIZE) && (arp_table[i].state == ETHARP_STATE_EMPTY)) {      if ((empty == ARP_TABLE_SIZE) && (arp_table[i].state == ETHARP_STATE_EMPTY)) {
232        LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %d\n", i));        LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %"U16_F"\n", (u16_t)i));
233        /* remember first empty entry */        /* remember first empty entry */
234        empty = i;        empty = i;
235      }      }
# Line 237  static s8_t find_entry(struct ip_addr *i Line 237  static s8_t find_entry(struct ip_addr *i
237      else if (arp_table[i].state == ETHARP_STATE_PENDING) {      else if (arp_table[i].state == ETHARP_STATE_PENDING) {
238        /* if given, does IP address match IP address in ARP entry? */        /* if given, does IP address match IP address in ARP entry? */
239        if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {        if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
240          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %d\n", i));          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i));
241          /* found exact IP address match, simply bail out */          /* found exact IP address match, simply bail out */
242          return i;          return i;
243  #if ARP_QUEUEING  #if ARP_QUEUEING
# Line 260  static s8_t find_entry(struct ip_addr *i Line 260  static s8_t find_entry(struct ip_addr *i
260      else if (arp_table[i].state == ETHARP_STATE_STABLE) {      else if (arp_table[i].state == ETHARP_STATE_STABLE) {
261        /* if given, does IP address match IP address in ARP entry? */        /* if given, does IP address match IP address in ARP entry? */
262        if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {        if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
263          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %d\n", i));          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i));
264          /* found exact IP address match, simply bail out */          /* found exact IP address match, simply bail out */
265          return i;          return i;
266        /* remember entry with oldest stable entry in oldest, its age in maxtime */        /* remember entry with oldest stable entry in oldest, its age in maxtime */
# Line 290  static s8_t find_entry(struct ip_addr *i Line 290  static s8_t find_entry(struct ip_addr *i
290    /* 1) empty entry available? */    /* 1) empty entry available? */
291    if (empty < ARP_TABLE_SIZE) {    if (empty < ARP_TABLE_SIZE) {
292      i = empty;      i = empty;
293      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %d\n", i));      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i));
294    }    }
295    /* 2) found recyclable stable entry? */    /* 2) found recyclable stable entry? */
296    else if (old_stable < ARP_TABLE_SIZE) {    else if (old_stable < ARP_TABLE_SIZE) {
297      /* recycle oldest stable*/      /* recycle oldest stable*/
298      i = old_stable;      i = old_stable;
299      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %d\n", i));      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i));
300  #if ARP_QUEUEING  #if ARP_QUEUEING
301      /* no queued packets should exist on stable entries */      /* no queued packets should exist on stable entries */
302      LWIP_ASSERT("arp_table[i].p == NULL", arp_table[i].p == NULL);      LWIP_ASSERT("arp_table[i].p == NULL", arp_table[i].p == NULL);
# Line 305  static s8_t find_entry(struct ip_addr *i Line 305  static s8_t find_entry(struct ip_addr *i
305    } else if (old_pending < ARP_TABLE_SIZE) {    } else if (old_pending < ARP_TABLE_SIZE) {
306      /* recycle oldest pending */      /* recycle oldest pending */
307      i = old_pending;      i = old_pending;
308      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %d (without queue)\n", i));      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i));
309  #if ARP_QUEUEING  #if ARP_QUEUEING
310    /* 4) found recyclable pending entry with queued packets? */    /* 4) found recyclable pending entry with queued packets? */
311    } else if (old_queue < ARP_TABLE_SIZE) {    } else if (old_queue < ARP_TABLE_SIZE) {
312      /* recycle oldest pending */      /* recycle oldest pending */
313      i = old_queue;      i = old_queue;
314      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %d, freeing packet queue %p\n", i, (void *)(arp_table[i].p)));      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].p)));
315      pbuf_free(arp_table[i].p);      pbuf_free(arp_table[i].p);
316      arp_table[i].p = NULL;      arp_table[i].p = NULL;
317  #endif  #endif
# Line 360  update_arp_entry(struct netif *netif, st Line 360  update_arp_entry(struct netif *netif, st
360    s8_t i, k;    s8_t i, k;
361    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n"));    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n"));
362    LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);    LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);
363    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n",    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
364                                          ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),                                          ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
365                                          ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2],                                          ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2],
366                                          ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));                                          ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));
# Line 379  update_arp_entry(struct netif *netif, st Line 379  update_arp_entry(struct netif *netif, st
379    /* mark it stable */    /* mark it stable */
380    arp_table[i].state = ETHARP_STATE_STABLE;    arp_table[i].state = ETHARP_STATE_STABLE;
381    
382    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %u\n", i));    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));
383    /* update address */    /* update address */
384    for (k = 0; k < netif->hwaddr_len; ++k) {    for (k = 0; k < netif->hwaddr_len; ++k) {
385      arp_table[i].ethaddr.addr[k] = ethaddr->addr[k];      arp_table[i].ethaddr.addr[k] = ethaddr->addr[k];
# Line 477  etharp_arp_input(struct netif *netif, st Line 477  etharp_arp_input(struct netif *netif, st
477        
478    /* drop short ARP packets */    /* drop short ARP packets */
479    if (p->tot_len < sizeof(struct etharp_hdr)) {    if (p->tot_len < sizeof(struct etharp_hdr)) {
480      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, sizeof(struct etharp_hdr)));
481      pbuf_free(p);      pbuf_free(p);
482      return;      return;
483    }    }
# Line 565  etharp_arp_input(struct netif *netif, st Line 565  etharp_arp_input(struct netif *netif, st
565  #endif  #endif
566      break;      break;
567    default:    default:
568      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode)));      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode)));
569      break;      break;
570    }    }
571    /* free ARP packet */    /* free ARP packet */
# Line 765  err_t etharp_query(struct netif *netif, Line 765  err_t etharp_query(struct netif *netif,
765            pbuf_queue(arp_table[i].p, p);            pbuf_queue(arp_table[i].p, p);
766  #endif  #endif
767          }          }
768          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %d\n", (void *)q, i));          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i));
769          result = ERR_OK;          result = ERR_OK;
770        } else {        } else {
771          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));          LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26