- prework for fixing bug #45029: access IPv4 configuration of struct netif via new API (netif_ip4_addr()/netif_ip4_netmask()/netif_ip4_gw()) instead of accessing the struct member directly. This way, we can change the struct member types from ip4_addr_t to ip_addr_t;

- fixed some bugs in calls to ip4_addr*() where the cast to u8_t* did not reveal the wrong address type
This commit is contained in:
sg
2015-08-20 22:39:48 +02:00
parent cc348dcca2
commit 177c06b1f1
15 changed files with 92 additions and 81 deletions

View File

@@ -132,7 +132,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);
#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_ip4_addr(netif) : NULL)
#if IP_DEBUG
void ip4_debug_print(struct pbuf *p);

View File

@@ -221,10 +221,10 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
ip4_addr4_16(&(ipaddr)))
/* Get one byte from the 4-byte address */
#define ip4_addr1(ipaddr) (((const u8_t*)(ipaddr))[0])
#define ip4_addr2(ipaddr) (((const u8_t*)(ipaddr))[1])
#define ip4_addr3(ipaddr) (((const u8_t*)(ipaddr))[2])
#define ip4_addr4(ipaddr) (((const u8_t*)(ipaddr))[3])
#define ip4_addr1(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[0])
#define ip4_addr2(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[1])
#define ip4_addr3(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[2])
#define ip4_addr4(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[3])
/* These are cast to u16_t, with the intent that they are often arguments
* to printf using the U16_F format from cc.h. */
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))

View File

@@ -50,7 +50,7 @@ typedef struct _ip_addr {
union {
ip6_addr_t ip6;
ip4_addr_t ip4;
} addr;
} u_addr;
u8_t type;
} ip_addr_t;

View File

@@ -388,6 +388,12 @@ void netif_poll_all(void);
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
#endif /* ENABLE_LOOPBACK */
#if LWIP_IPV4
#define netif_ip4_addr(netif) (&((netif)->ip_addr))
#define netif_ip4_netmask(netif) (&((netif)->netmask))
#define netif_ip4_gw(netif) (&((netif)->gw))
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
#define netif_ip6_addr(netif, i) (&((netif)->ip6_addr[(i)]))
#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[(i)])

View File

@@ -205,7 +205,7 @@ err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr);
* this is an ARP packet sent by a node in order to spontaneously cause other
* nodes to update an entry in their ARP cache.
* From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
#define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
#define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif))
void etharp_cleanup_netif(struct netif *netif);
#if ETHARP_SUPPORT_STATIC_ENTRIES