Merged from trunk: use a define to set/reset netif->addr_hint to prevent too many #ifdef's in the code

This commit is contained in:
goldsimon 2011-12-14 21:48:06 +01:00
parent a91d8e7395
commit d3ee77e7b1
6 changed files with 17 additions and 25 deletions

View File

@ -859,9 +859,9 @@ ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
return ERR_RTE; return ERR_RTE;
} }
netif->addr_hint = addr_hint; NETIF_SET_HWADDRHINT(netif, addr_hint);
err = ip_output_if(p, src, dest, ttl, tos, proto, netif); err = ip_output_if(p, src, dest, ttl, tos, proto, netif);
netif->addr_hint = NULL; NETIF_SET_HWADDRHINT(netif, NULL);
return err; return err;
} }

View File

@ -341,9 +341,9 @@ ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
return ERR_RTE; return ERR_RTE;
} }
netif->addr_hint = addr_hint; LWIP_NETIF_HWADDRHINT(netif, addr_hint);
err = ip_output_if(p, src, dest, ttl, tos, proto, netif); err = ip_output_if(p, src, dest, ttl, tos, proto, netif);
netif->addr_hint = NULL; LWIP_NETIF_HWADDRHINT(netif, NULL);
return err; return err;
} }

View File

@ -173,9 +173,7 @@ netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
netif->state = state; netif->state = state;
netif->num = netif_num++; netif->num = netif_num++;
netif->input = input; netif->input = input;
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, NULL);
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS #if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
netif->loop_cnt_current = 0; netif->loop_cnt_current = 0;
#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */

View File

@ -263,13 +263,9 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
src_ip = &(pcb->local_ip); src_ip = &(pcb->local_ip);
} }
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint);
netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif); err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, NULL);
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
/* did we chain a header earlier? */ /* did we chain a header earlier? */
if (q != p) { if (q != p) {

View File

@ -689,13 +689,9 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
#endif /* CHECKSUM_GEN_UDP */ #endif /* CHECKSUM_GEN_UDP */
/* output to IP */ /* output to IP */
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n")); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n"));
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint);
netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif);
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, NULL);
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
} else } else
#endif /* LWIP_UDPLITE */ #endif /* LWIP_UDPLITE */
{ /* UDP */ { /* UDP */
@ -728,13 +724,9 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum));
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
/* output to IP */ /* output to IP */
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint);
netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif); err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif);
#if LWIP_NETIF_HWADDRHINT NETIF_SET_HWADDRHINT(netif, NULL);
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
} }
/* TODO: must this be increased even if error occured? */ /* TODO: must this be increased even if error occured? */
snmp_inc_udpoutdatagrams(); snmp_inc_udpoutdatagrams();

View File

@ -315,6 +315,12 @@ void netif_poll_all(void);
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
#endif /* ENABLE_LOOPBACK */ #endif /* ENABLE_LOOPBACK */
#if LWIP_NETIF_HWADDRHINT
#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint))
#else /* LWIP_NETIF_HWADDRHINT */
#define NETIF_SET_HWADDRHINT(netif, hint)
#endif /* LWIP_NETIF_HWADDRHINT */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif