mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-09-25 18:23:50 +08:00
- 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:
@@ -1591,8 +1591,13 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
struct dhcp_msg *reply_msg = (struct dhcp_msg *)p->payload;
|
||||
u8_t msg_type;
|
||||
u8_t i;
|
||||
|
||||
#if LWIP_IPV6
|
||||
LWIP_ASSERT("invalid server address type", !IP_IS_V6(addr));
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p,
|
||||
ip4_addr1_16(addr), ip4_addr2_16(addr), ip4_addr3_16(addr), ip4_addr4_16(addr), port));
|
||||
ip4_addr1_16(ip_2_ip4(addr)), ip4_addr2_16(ip_2_ip4(addr)), ip4_addr3_16(ip_2_ip4(addr)), ip4_addr4_16(ip_2_ip4(addr)), port));
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len));
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len));
|
||||
/* prevent warnings about unused arguments */
|
||||
@@ -1753,7 +1758,7 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type)
|
||||
if ((message_type == DHCP_INFORM) || (message_type == DHCP_DECLINE) || (message_type == DHCP_RELEASE) ||
|
||||
((message_type == DHCP_REQUEST) && /* DHCP_STATE_BOUND not used for sending! */
|
||||
((dhcp->state== DHCP_STATE_RENEWING) || dhcp->state== DHCP_STATE_REBINDING))) {
|
||||
ip4_addr_copy(dhcp->msg_out->ciaddr, netif->ip_addr);
|
||||
ip4_addr_copy(dhcp->msg_out->ciaddr, *netif_ip4_addr(netif));
|
||||
}
|
||||
ip4_addr_set_zero(&dhcp->msg_out->yiaddr);
|
||||
ip4_addr_set_zero(&dhcp->msg_out->siaddr);
|
||||
|
||||
@@ -1094,7 +1094,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
/* read the IP address after answer resource record's header */
|
||||
pbuf_copy_partial(p, &(entry->ipaddr), sizeof(entry->ipaddr), res_idx);
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", entry->name));
|
||||
ip4_addr_debug_print(DNS_DEBUG, (&(entry->ipaddr)));
|
||||
ip_addr_debug_print(DNS_DEBUG, (&(entry->ipaddr)));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("\n"));
|
||||
/* call specified callback function if provided */
|
||||
dns_call_found(entry_idx, &entry->ipaddr);
|
||||
|
||||
@@ -373,7 +373,7 @@ autoip_stop(struct netif *netif)
|
||||
{
|
||||
if (netif->autoip) {
|
||||
netif->autoip->state = AUTOIP_STATE_OFF;
|
||||
if (ip4_addr_islinklocal(&netif->ip_addr)) {
|
||||
if (ip4_addr_islinklocal(netif_ip4_addr(netif))) {
|
||||
netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,9 +144,9 @@ ip4_route(const ip4_addr_t *dest)
|
||||
/* iterate through netifs */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
/* is the netif up, does it have a link and a valid address? */
|
||||
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(netif->ip_addr)) {
|
||||
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
||||
/* network mask matches? */
|
||||
if (ip4_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
|
||||
if (ip4_addr_netcmp(dest, netif_ip4_addr(netif), netif_ip4_netmask(netif))) {
|
||||
/* return netif on which to forward IP packet */
|
||||
return netif;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ ip4_route(const ip4_addr_t *dest)
|
||||
}
|
||||
|
||||
if ((netif_default == NULL) || !netif_is_up(netif_default) || !netif_is_link_up(netif_default) ||
|
||||
ip4_addr_isany_val(netif_default->ip_addr)) {
|
||||
ip4_addr_isany_val(*netif_ip4_addr(netif_default))) {
|
||||
/* No matching netif found an default netif is not usable.
|
||||
If this is not good enough for you, use LWIP_HOOK_IP4_ROUTE() */
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
@@ -247,8 +247,8 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
/* RFC3927 2.7: do not forward link-local addresses */
|
||||
if (ip4_addr_islinklocal(ip4_current_dest_addr())) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not forwarding LLA %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()),
|
||||
ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr())));
|
||||
ip4_addr1_16(ip4_current_dest_addr()), ip4_addr2_16(ip4_current_dest_addr()),
|
||||
ip4_addr3_16(ip4_current_dest_addr()), ip4_addr4_16(ip4_current_dest_addr())));
|
||||
goto return_noroute;
|
||||
}
|
||||
|
||||
@@ -256,8 +256,8 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
netif = ip4_route(ip4_current_dest_addr());
|
||||
if (netif == NULL) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for %"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n",
|
||||
ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()),
|
||||
ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr())));
|
||||
ip4_addr1_16(ip4_current_dest_addr()), ip4_addr2_16(ip4_current_dest_addr()),
|
||||
ip4_addr3_16(ip4_current_dest_addr()), ip4_addr4_16(ip4_current_dest_addr())));
|
||||
/* @todo: send ICMP_DUR_NET? */
|
||||
goto return_noroute;
|
||||
}
|
||||
@@ -292,8 +292,8 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()),
|
||||
ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr())));
|
||||
ip4_addr1_16(ip4_current_dest_addr()), ip4_addr2_16(ip4_current_dest_addr()),
|
||||
ip4_addr3_16(ip4_current_dest_addr()), ip4_addr4_16(ip4_current_dest_addr())));
|
||||
|
||||
IP_STATS_INC(ip.fw);
|
||||
IP_STATS_INC(ip.xmit);
|
||||
@@ -462,15 +462,15 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
netif = inp;
|
||||
do {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n",
|
||||
ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(&netif->ip_addr),
|
||||
ip4_addr_get_u32(&iphdr->dest) & ip4_addr_get_u32(&netif->netmask),
|
||||
ip4_addr_get_u32(&netif->ip_addr) & ip4_addr_get_u32(&netif->netmask),
|
||||
ip4_addr_get_u32(&iphdr->dest) & ~ip4_addr_get_u32(&netif->netmask)));
|
||||
ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(netif_ip4_addr(netif)),
|
||||
ip4_addr_get_u32(&iphdr->dest) & ip4_addr_get_u32(netif_ip4_netmask(netif)),
|
||||
ip4_addr_get_u32(netif_ip4_addr(netif)) & ip4_addr_get_u32(netif_ip4_netmask(netif)),
|
||||
ip4_addr_get_u32(&iphdr->dest) & ~ip4_addr_get_u32(netif_ip4_netmask(netif))));
|
||||
|
||||
/* interface is up and configured? */
|
||||
if ((netif_is_up(netif)) && (!ip4_addr_isany_val(netif->ip_addr))) {
|
||||
if ((netif_is_up(netif)) && (!ip4_addr_isany_val(*netif_ip4_addr(netif)))) {
|
||||
/* unicast to this interface address? */
|
||||
if (ip4_addr_cmp(ip4_current_dest_addr(), &(netif->ip_addr)) ||
|
||||
if (ip4_addr_cmp(ip4_current_dest_addr(), netif_ip4_addr(netif)) ||
|
||||
/* or broadcast on this interface network address? */
|
||||
ip_addr_isbroadcast(ip_current_dest_addr(), netif)
|
||||
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
|
||||
@@ -736,7 +736,7 @@ err_t ip4_output_if_opt(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t
|
||||
const ip4_addr_t *src_used = src;
|
||||
if (dest != IP_HDRINCL) {
|
||||
if (ip4_addr_isany(src)) {
|
||||
src_used = &netif->ip_addr;
|
||||
src_used = netif_ip4_addr(netif);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
|
||||
ip4_debug_print(p);
|
||||
|
||||
#if ENABLE_LOOPBACK
|
||||
if (ip4_addr_cmp(dest, &netif->ip_addr)
|
||||
if (ip4_addr_cmp(dest, netif_ip4_addr(netif))
|
||||
#if !LWIP_HAVE_LOOPIF
|
||||
|| ip4_addr_isloopback(dest)
|
||||
#endif /* !LWIP_HAVE_LOOPIF */
|
||||
|
||||
@@ -70,13 +70,13 @@ ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif)
|
||||
* nor can we check against any broadcast addresses */
|
||||
return 0;
|
||||
/* address matches network interface address exactly? => no broadcast */
|
||||
} else if (addr == ip4_addr_get_u32(&netif->ip_addr)) {
|
||||
} else if (addr == ip4_addr_get_u32(netif_ip4_addr(netif))) {
|
||||
return 0;
|
||||
/* on the same (sub) network... */
|
||||
} else if (ip4_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask))
|
||||
} else if (ip4_addr_netcmp(&ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif))
|
||||
/* ...and host identifier bits are all ones? =>... */
|
||||
&& ((addr & ~ip4_addr_get_u32(&netif->netmask)) ==
|
||||
(IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) {
|
||||
&& ((addr & ~ip4_addr_get_u32(netif_ip4_netmask(netif))) ==
|
||||
(IPADDR_BROADCAST & ~ip4_addr_get_u32(netif_ip4_netmask(netif))))) {
|
||||
/* => network broadcast address */
|
||||
return 1;
|
||||
} else {
|
||||
@@ -325,7 +325,7 @@ ip4_2_ip(const ip4_addr_t *ip4addr, ip_addr_t* storage)
|
||||
if ((ip4addr == NULL) || (storage == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
ip4_addr_copy(storage->addr.ip4, *ip4addr);
|
||||
ip4_addr_copy(storage->u_addr.ip4, *ip4addr);
|
||||
IP_SET_TYPE_VAL(*storage, IPADDR_TYPE_V4);
|
||||
return storage;
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ ip6_2_ip(const ip6_addr_t *ip6addr, ip_addr_t* storage)
|
||||
if ((ip6addr == NULL) || (storage == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
ip6_addr_copy(storage->addr.ip6, *ip6addr);
|
||||
ip6_addr_copy(storage->u_addr.ip6, *ip6addr);
|
||||
IP_SET_TYPE_VAL(*storage, IPADDR_TYPE_V6);
|
||||
return storage;
|
||||
}
|
||||
|
||||
@@ -320,9 +320,9 @@ netif_remove(struct netif *netif)
|
||||
}
|
||||
|
||||
#if LWIP_IPV4
|
||||
if (!ip4_addr_isany_val(netif->ip_addr)) {
|
||||
if (!ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
||||
#if LWIP_TCP
|
||||
tcp_netif_ipv4_addr_changed(&netif->ip_addr, NULL);
|
||||
tcp_netif_ipv4_addr_changed(netif_ip4_addr(netif), NULL);
|
||||
#endif /* LWIP_TCP */
|
||||
/* cannot do this for UDP, as there is no 'err' callback in udp pcbs */
|
||||
}
|
||||
@@ -421,19 +421,19 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||
{
|
||||
ip4_addr_t new_addr = (ipaddr ? *ipaddr : *IP4_ADDR_ANY);
|
||||
/* address is actually being changed? */
|
||||
if (ip4_addr_cmp(&new_addr, &(netif->ip_addr)) == 0) {
|
||||
if (ip4_addr_cmp(&new_addr, netif_ip4_addr(netif)) == 0) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
|
||||
#if LWIP_TCP
|
||||
tcp_netif_ipv4_addr_changed(&netif->ip_addr, ipaddr);
|
||||
tcp_netif_ipv4_addr_changed(netif_ip4_addr(netif), ipaddr);
|
||||
#endif /* LWIP_TCP */
|
||||
#if LWIP_UDP
|
||||
udp_netif_ipv4_addr_changed(&netif->ip_addr, ipaddr);
|
||||
udp_netif_ipv4_addr_changed(netif_ip4_addr(netif), ipaddr);
|
||||
#endif /* LWIP_UDP */
|
||||
|
||||
snmp_delete_ipaddridx_tree(netif);
|
||||
snmp_delete_iprteidx_tree(0, netif);
|
||||
/* set new IP address to netif */
|
||||
ip4_addr_set(&(netif->ip_addr), ipaddr);
|
||||
ip4_addr_set(netif_ip4_addr(netif), ipaddr);
|
||||
snmp_insert_ipaddridx_tree(netif);
|
||||
snmp_insert_iprteidx_tree(0, netif);
|
||||
|
||||
@@ -444,10 +444,10 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||
|
||||
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
netif->name[0], netif->name[1],
|
||||
ip4_addr1_16(&netif->ip_addr),
|
||||
ip4_addr2_16(&netif->ip_addr),
|
||||
ip4_addr3_16(&netif->ip_addr),
|
||||
ip4_addr4_16(&netif->ip_addr)));
|
||||
ip4_addr1_16(netif_ip4_addr(netif)),
|
||||
ip4_addr2_16(netif_ip4_addr(netif)),
|
||||
ip4_addr3_16(netif_ip4_addr(netif)),
|
||||
ip4_addr4_16(netif_ip4_addr(netif))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,13 +461,13 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||
void
|
||||
netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
|
||||
{
|
||||
ip4_addr_set(&(netif->gw), gw);
|
||||
ip4_addr_set(netif_ip4_gw(netif), gw);
|
||||
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
netif->name[0], netif->name[1],
|
||||
ip4_addr1_16(&netif->gw),
|
||||
ip4_addr2_16(&netif->gw),
|
||||
ip4_addr3_16(&netif->gw),
|
||||
ip4_addr4_16(&netif->gw)));
|
||||
ip4_addr1_16(netif_ip4_gw(netif)),
|
||||
ip4_addr2_16(netif_ip4_gw(netif)),
|
||||
ip4_addr3_16(netif_ip4_gw(netif)),
|
||||
ip4_addr4_16(netif_ip4_gw(netif))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,14 +484,14 @@ netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
|
||||
{
|
||||
snmp_delete_iprteidx_tree(0, netif);
|
||||
/* set new netmask to netif */
|
||||
ip4_addr_set(&(netif->netmask), netmask);
|
||||
ip4_addr_set(netif_ip4_netmask(netif), netmask);
|
||||
snmp_insert_iprteidx_tree(0, netif);
|
||||
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
netif->name[0], netif->name[1],
|
||||
ip4_addr1_16(&netif->netmask),
|
||||
ip4_addr2_16(&netif->netmask),
|
||||
ip4_addr3_16(&netif->netmask),
|
||||
ip4_addr4_16(&netif->netmask)));
|
||||
ip4_addr1_16(netif_ip4_netmask(netif)),
|
||||
ip4_addr2_16(netif_ip4_netmask(netif)),
|
||||
ip4_addr3_16(netif_ip4_netmask(netif)),
|
||||
ip4_addr4_16(netif_ip4_netmask(netif))));
|
||||
}
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
@@ -549,7 +549,7 @@ netif_issue_reports(struct netif* netif, u8_t report_type)
|
||||
{
|
||||
#if LWIP_IPV4
|
||||
if ((report_type & NETIF_REPORT_TYPE_IPV4) &&
|
||||
!ip4_addr_isany_val(netif->ip_addr)) {
|
||||
!ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
||||
#if LWIP_ARP
|
||||
/* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */
|
||||
if (netif->flags & (NETIF_FLAG_ETHARP)) {
|
||||
|
||||
@@ -1304,7 +1304,7 @@ void snmp_insert_ipaddridx_tree(struct netif *ni)
|
||||
u8_t level;
|
||||
|
||||
LWIP_ASSERT("ni != NULL", ni != NULL);
|
||||
snmp_iptooid(&ni->ip_addr, &ipaddridx[0]);
|
||||
snmp_iptooid(netif_ip4_addr(ni), &ipaddridx[0]);
|
||||
|
||||
level = 0;
|
||||
ipa_rn = &ipaddrtree_root;
|
||||
@@ -1358,7 +1358,7 @@ void snmp_delete_ipaddridx_tree(struct netif *ni)
|
||||
u8_t fc, level, del_cnt;
|
||||
|
||||
LWIP_ASSERT("ni != NULL", ni != NULL);
|
||||
snmp_iptooid(&ni->ip_addr, &ipaddridx[0]);
|
||||
snmp_iptooid(netif_ip4_addr(ni), &ipaddridx[0]);
|
||||
|
||||
/* mark nodes for deletion */
|
||||
level = 0;
|
||||
@@ -1431,7 +1431,7 @@ void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
|
||||
else
|
||||
{
|
||||
/* route to the network address */
|
||||
ip4_addr_get_network(&dst, &ni->ip_addr, &ni->netmask);
|
||||
ip4_addr_get_network(&dst, netif_ip4_addr(ni), netif_ip4_netmask(ni));
|
||||
/* exclude 0.0.0.0 network (reserved for default rte) */
|
||||
if (!ip4_addr_isany_val(dst)) {
|
||||
insert = 1;
|
||||
@@ -1508,7 +1508,7 @@ void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
|
||||
else
|
||||
{
|
||||
/* route to the network address */
|
||||
ip4_addr_get_network(&dst, &ni->ip_addr, &ni->netmask);
|
||||
ip4_addr_get_network(&dst, netif_ip4_addr(ni), netif_ip4_netmask(ni));
|
||||
/* exclude 0.0.0.0 network (reserved for default rte) */
|
||||
if (!ip4_addr_isany_val(dst)) {
|
||||
del = 1;
|
||||
@@ -3084,7 +3084,7 @@ ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
LWIP_UNUSED_ARG(len);
|
||||
snmp_oidtoip(&od->id_inst_ptr[1], &ip);
|
||||
ifidx = 0;
|
||||
while ((netif != NULL) && !ip4_addr_cmp(&ip, &netif->ip_addr))
|
||||
while ((netif != NULL) && !ip4_addr_cmp(&ip, netif_ip4_addr(netif)))
|
||||
{
|
||||
netif = netif->next;
|
||||
ifidx++;
|
||||
@@ -3099,7 +3099,7 @@ ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
case 1: /* ipAdEntAddr */
|
||||
{
|
||||
ip4_addr_t *dst = (ip4_addr_t*)value;
|
||||
*dst = netif->ip_addr;
|
||||
*dst = *netif_ip4_addr(netif);
|
||||
}
|
||||
break;
|
||||
case 2: /* ipAdEntIfIndex */
|
||||
@@ -3111,7 +3111,7 @@ ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
case 3: /* ipAdEntNetMask */
|
||||
{
|
||||
ip4_addr_t *dst = (ip4_addr_t*)value;
|
||||
*dst = netif->netmask;
|
||||
*dst = *netif_ip4_netmask(netif);
|
||||
}
|
||||
break;
|
||||
case 4: /* ipAdEntBcastAddr */
|
||||
@@ -3238,7 +3238,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
/* not using ip_route(), need exact match! */
|
||||
netif = netif_list;
|
||||
while ((netif != NULL) &&
|
||||
!ip4_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) )
|
||||
!ip4_addr_netcmp(&dest, netif_ip4_addr(netif), netif_ip4_netmask(netif)) )
|
||||
{
|
||||
netif = netif->next;
|
||||
}
|
||||
@@ -3261,7 +3261,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
else
|
||||
{
|
||||
/* netifs have netaddress dest */
|
||||
ip4_addr_get_network(dst, &netif->ip_addr, &netif->netmask);
|
||||
ip4_addr_get_network(dst, netif_ip4_addr(netif), netif_ip4_netmask(netif));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3305,12 +3305,12 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* default rte: gateway */
|
||||
*dst = netif->gw;
|
||||
*dst = *netif_ip4_gw(netif);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* other rtes: netif ip_addr */
|
||||
*dst = netif->ip_addr;
|
||||
*dst = *netif_ip4_addr(netif);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3357,7 +3357,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
else
|
||||
{
|
||||
/* other rtes use netmask */
|
||||
*dst = netif->netmask;
|
||||
*dst = *netif_ip4_netmask(netif);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -263,11 +263,11 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
#if IP_SOF_BROADCAST_RECV
|
||||
(broadcast && ip_get_option(pcb, SOF_BROADCAST) &&
|
||||
(ip_addr_isany(&pcb->local_ip) ||
|
||||
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))))
|
||||
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), netif_ip4_netmask(inp))))))
|
||||
#else /* IP_SOF_BROADCAST_RECV */
|
||||
(broadcast &&
|
||||
(ip_addr_isany(&pcb->local_ip) ||
|
||||
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))))
|
||||
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), netif_ip4_netmask(inp))))))
|
||||
#endif /* IP_SOF_BROADCAST_RECV */
|
||||
#endif /* LWIP_IPV4 */
|
||||
) {
|
||||
@@ -318,7 +318,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
#endif /* LWIP_IPV6 */
|
||||
#if LWIP_IPV4
|
||||
{
|
||||
for_us = ip4_addr_cmp(&inp->ip_addr, ip4_current_dest_addr());
|
||||
for_us = ip4_addr_cmp(netif_ip4_addr(inp), ip4_current_dest_addr());
|
||||
}
|
||||
#endif /* LWIP_IPV4 */
|
||||
}
|
||||
@@ -664,11 +664,11 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_i
|
||||
#if LWIP_IPV4
|
||||
if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip))) {
|
||||
/* use outgoing network interface IP address as source address */
|
||||
src_ip = ip4_2_ip(&netif->ip_addr, &src_ip_tmp);
|
||||
src_ip = ip4_2_ip(netif_ip4_addr(netif), &src_ip_tmp);
|
||||
} else {
|
||||
/* check if UDP PCB local IP address is correct
|
||||
* this could be an old address if netif->ip_addr has changed */
|
||||
if (!ip4_addr_cmp(ip_2_ip4(&(pcb->local_ip)), &(netif->ip_addr))) {
|
||||
if (!ip4_addr_cmp(ip_2_ip4(&(pcb->local_ip)), netif_ip4_addr(netif))) {
|
||||
/* local_ip doesn't match, drop the packet */
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user