- 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

@@ -777,11 +777,11 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
IPADDR2_COPY(&dipaddr, &hdr->dipaddr);
/* this interface is not configured? */
if (ip4_addr_isany_val(netif->ip_addr)) {
if (ip4_addr_isany_val(*netif_ip4_addr(netif))) {
for_us = 0;
} else {
/* ARP packet directed to us? */
for_us = (u8_t)ip4_addr_cmp(&dipaddr, &(netif->ip_addr));
for_us = (u8_t)ip4_addr_cmp(&dipaddr, netif_ip4_addr(netif));
}
/* ARP message directed to us?
@@ -811,7 +811,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
hdr->opcode = htons(ARP_REPLY);
IPADDR2_COPY(&hdr->dipaddr, &hdr->sipaddr);
IPADDR2_COPY(&hdr->sipaddr, &netif->ip_addr);
IPADDR2_COPY(&hdr->sipaddr, netif_ip4_addr(netif));
LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!",
(netif->hwaddr_len == ETHARP_HWADDR_LEN));
@@ -819,7 +819,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* If we are using Link-Local, all ARP packets that contain a Link-Local
* 'sender IP address' MUST be sent using link-layer broadcast instead of
* link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */
ethdst_hwaddr = ip4_addr_islinklocal(&netif->ip_addr) ? (const u8_t*)(ethbroadcast.addr) : hdr->shwaddr.addr;
ethdst_hwaddr = ip4_addr_islinklocal(netif_ip4_addr(netif)) ? (const u8_t*)(ethbroadcast.addr) : hdr->shwaddr.addr;
#endif /* LWIP_AUTOIP */
ETHADDR16_COPY(&hdr->dhwaddr, &hdr->shwaddr);
@@ -837,7 +837,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* return ARP reply */
netif->linkoutput(netif, p);
/* we are not configured? */
} else if (ip4_addr_isany_val(netif->ip_addr)) {
} else if (ip4_addr_isany_val(*netif_ip4_addr(netif))) {
/* { for_us == 0 and netif->ip_addr.addr == 0 } */
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));
/* request was not directed to us */
@@ -960,7 +960,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
s8_t i;
/* outside local network? if so, this can neither be a global broadcast nor
a subnet broadcast. */
if (!ip4_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask)) &&
if (!ip4_addr_netcmp(ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) &&
!ip4_addr_islinklocal(ipaddr)) {
#if LWIP_AUTOIP
struct ip_hdr *iphdr = (struct ip_hdr*)((u8_t*)q->payload +
@@ -983,9 +983,9 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
#endif /* LWIP_HOOK_ETHARP_GET_GW */
{
/* interface has default gateway? */
if (!ip4_addr_isany_val(netif->gw)) {
if (!ip4_addr_isany_val(*netif_ip4_gw(netif))) {
/* send to hardware address of default gateway IP address */
dst_addr = &(netif->gw);
dst_addr = netif_ip4_gw(netif);
/* no default gateway available */
} else {
/* no route to destination error (default gateway missing) */
@@ -1353,7 +1353,7 @@ static err_t
etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr* hw_dst_addr)
{
return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, hw_dst_addr,
(struct eth_addr *)netif->hwaddr, &netif->ip_addr, &ethzero,
(struct eth_addr *)netif->hwaddr, netif_ip4_addr(netif), &ethzero,
ipaddr, ARP_REQUEST);
}