Cleaned up using struct netif.ip_addr by creating API functions for it

This commit is contained in:
goldsimon 2015-09-24 14:57:16 +02:00
parent 99d2e5233d
commit b0917d987a
4 changed files with 5 additions and 3 deletions

View File

@ -120,7 +120,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
if (ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif())) { if (ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif())) {
#if LWIP_BROADCAST_PING #if LWIP_BROADCAST_PING
/* For broadcast, use address of receiving interface as source address */ /* For broadcast, use address of receiving interface as source address */
src = &inp->ip_addr; src = netif_ip4_addr(inp);
#else /* LWIP_BROADCAST_PING */ #else /* LWIP_BROADCAST_PING */
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to broadcast pings\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to broadcast pings\n"));
goto icmperr; goto icmperr;

View File

@ -683,7 +683,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_i
#if LWIP_IPV4 #if LWIP_IPV4
if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip))) { if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip))) {
/* use outgoing network interface IP address as source address */ /* use outgoing network interface IP address as source address */
src_ip = &netif->ip_addr; src_ip = netif_ip_addr4(netif);
} else { } else {
/* check if UDP PCB local IP address is correct /* check if UDP PCB local IP address is correct
* this could be an old address if netif->ip_addr has changed */ * this could be an old address if netif->ip_addr has changed */

View File

@ -143,7 +143,7 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
void ip4_set_default_multicast_netif(struct netif* default_multicast_netif); void ip4_set_default_multicast_netif(struct netif* default_multicast_netif);
#endif /* LWIP_MULTICAST_TX_OPTIONS */ #endif /* LWIP_MULTICAST_TX_OPTIONS */
#define ip4_netif_get_local_ip(netif) (((netif) != NULL) ? &((netif)->ip_addr) : NULL) #define ip4_netif_get_local_ip(netif) (((netif) != NULL) ? netif_ip_addr4(netif) : NULL)
#if IP_DEBUG #if IP_DEBUG
void ip4_debug_print(struct pbuf *p); void ip4_debug_print(struct pbuf *p);

View File

@ -351,6 +351,8 @@ void netif_set_gw(struct netif *netif, const ip4_addr_t *gw);
#define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr))) #define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr)))
#define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask))) #define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask)))
#define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw))) #define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw)))
#define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr))
#define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw))
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */
void netif_set_up(struct netif *netif); void netif_set_up(struct netif *netif);