Rename IP and Ethernet equality checkers from _cmp to _eq

Functions ending in cmp are expected to return 0 on equality but these
return non-zero.

eth_addr_cmp -> eth_addr_eq

ip_addr_cmp -> ip_addr_eq
ip4_addr_cmp -> ip4_addr_eq
ip6_addr_cmp -> ip6_addr_eq

ip_addr_netcmp -> ip_addr_net_eq
ip4_addr_netcmp -> ip4_addr_net_eq
ip6_addr_netcmp -> ip6_addr_net_eq

ip_addr_cmp_zoneless -> ip_addr_zoneless_eq
ip6_addr_cmp_zoneless -> ip6_addr_zoneless_eq

ip6_addr_cmp_zone -> ip6_addr_zone_eq
ip6_addr_netcmp_zoneless -> ip6_addr_net_zoneless_eq
ip6_addr_nethostcmp -> ip6_addr_nethost_eq
ip6_addr_cmp_packed -> ip6_addr_packed_eq
ip6_addr_cmp_solicitednode -> ip6_addr_solicitednode_eq

All call sites have been changed, and fallback macros have been added to not
break external users.
This commit is contained in:
Erik Ekman 2020-07-07 16:55:52 +02:00
parent 047f3b3306
commit 264a5a3e97
41 changed files with 211 additions and 162 deletions

View File

@ -7,6 +7,8 @@ with newer versions.
(git master) (git master)
* [Enter new changes just after this line - do not remove this line] * [Enter new changes just after this line - do not remove this line]
* The eth_addr_cmp and ip_addr_cmp set of functions have been renamed to eth_addr_eq, ip_addr_eq
and so on, since they return non-zero on equality. Macros for the old names exist.
(2.1.0) (2.1.0)

View File

@ -128,7 +128,7 @@ tcp_md5_get_info(const struct tcp_pcb *pcb, const ip_addr_t *remote_ip, u16_t re
if (pcb != NULL) { if (pcb != NULL) {
struct tcp_md5_conn_info *info = (struct tcp_md5_conn_info *)tcp_ext_arg_get(pcb, tcp_md5_extarg_id); struct tcp_md5_conn_info *info = (struct tcp_md5_conn_info *)tcp_ext_arg_get(pcb, tcp_md5_extarg_id);
while (info != NULL) { while (info != NULL) {
if (ip_addr_cmp(&info->remote_addr, remote_ip)) { if (ip_addr_eq(&info->remote_addr, remote_ip)) {
if (info->remote_port == remote_port) { if (info->remote_port == remote_port) {
return info; return info;
} }
@ -157,7 +157,7 @@ tcp_md5_extarg_passive_open(u8_t id, struct tcp_pcb_listen *lpcb, struct tcp_pcb
iter = (struct tcp_md5_conn_info *)tcp_ext_arg_get((struct tcp_pcb *)lpcb, id); iter = (struct tcp_md5_conn_info *)tcp_ext_arg_get((struct tcp_pcb *)lpcb, id);
while (iter != NULL) { while (iter != NULL) {
if (iter->remote_port == cpcb->remote_port) { if (iter->remote_port == cpcb->remote_port) {
if (ip_addr_cmp(&iter->remote_addr, &cpcb->remote_ip)) { if (ip_addr_eq(&iter->remote_addr, &cpcb->remote_ip)) {
struct tcp_md5_conn_info *info = tcp_md5_conn_info_alloc(); struct tcp_md5_conn_info *info = tcp_md5_conn_info_alloc();
if (info != NULL) { if (info != NULL) {
memcpy(info, iter, sizeof(struct tcp_md5_conn_info)); memcpy(info, iter, sizeof(struct tcp_md5_conn_info));

View File

@ -323,7 +323,7 @@ netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port)
* and NETCONN_FLAG_IPV6_V6ONLY is 0, use IP_ANY_TYPE to bind * and NETCONN_FLAG_IPV6_V6ONLY is 0, use IP_ANY_TYPE to bind
*/ */
if ((netconn_get_ipv6only(conn) == 0) && if ((netconn_get_ipv6only(conn) == 0) &&
ip_addr_cmp(addr, IP6_ADDR_ANY)) { ip_addr_eq(addr, IP6_ADDR_ANY)) {
addr = IP_ANY_TYPE; addr = IP_ANY_TYPE;
} }
#endif /* LWIP_IPV4 && LWIP_IPV6 */ #endif /* LWIP_IPV4 && LWIP_IPV6 */

View File

@ -1473,7 +1473,7 @@ lwip_netconn_do_listen(void *m)
/* "Socket API like" dual-stack support: If IP to listen to is IP6_ADDR_ANY, /* "Socket API like" dual-stack support: If IP to listen to is IP6_ADDR_ANY,
* and NETCONN_FLAG_IPV6_V6ONLY is NOT set, use IP_ANY_TYPE to listen * and NETCONN_FLAG_IPV6_V6ONLY is NOT set, use IP_ANY_TYPE to listen
*/ */
if (ip_addr_cmp(&msg->conn->pcb.ip->local_ip, IP6_ADDR_ANY) && if (ip_addr_eq(&msg->conn->pcb.ip->local_ip, IP6_ADDR_ANY) &&
(netconn_get_ipv6only(msg->conn) == 0)) { (netconn_get_ipv6only(msg->conn) == 0)) {
/* change PCB type to IPADDR_TYPE_ANY */ /* change PCB type to IPADDR_TYPE_ANY */
IP_SET_TYPE_VAL(msg->conn->pcb.tcp->local_ip, IPADDR_TYPE_ANY); IP_SET_TYPE_VAL(msg->conn->pcb.tcp->local_ip, IPADDR_TYPE_ANY);

View File

@ -4063,8 +4063,8 @@ lwip_socket_unregister_membership(int s, const ip4_addr_t *if_addr, const ip4_ad
for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) { for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) {
if ((socket_ipv4_multicast_memberships[i].sock == sock) && if ((socket_ipv4_multicast_memberships[i].sock == sock) &&
ip4_addr_cmp(&socket_ipv4_multicast_memberships[i].if_addr, if_addr) && ip4_addr_eq(&socket_ipv4_multicast_memberships[i].if_addr, if_addr) &&
ip4_addr_cmp(&socket_ipv4_multicast_memberships[i].multi_addr, multi_addr)) { ip4_addr_eq(&socket_ipv4_multicast_memberships[i].multi_addr, multi_addr)) {
socket_ipv4_multicast_memberships[i].sock = NULL; socket_ipv4_multicast_memberships[i].sock = NULL;
ip4_addr_set_zero(&socket_ipv4_multicast_memberships[i].if_addr); ip4_addr_set_zero(&socket_ipv4_multicast_memberships[i].if_addr);
ip4_addr_set_zero(&socket_ipv4_multicast_memberships[i].multi_addr); ip4_addr_set_zero(&socket_ipv4_multicast_memberships[i].multi_addr);
@ -4152,7 +4152,7 @@ lwip_socket_unregister_mld6_membership(int s, unsigned int if_idx, const ip6_add
for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) { for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) {
if ((socket_ipv6_multicast_memberships[i].sock == sock) && if ((socket_ipv6_multicast_memberships[i].sock == sock) &&
(socket_ipv6_multicast_memberships[i].if_idx == if_idx) && (socket_ipv6_multicast_memberships[i].if_idx == if_idx) &&
ip6_addr_cmp(&socket_ipv6_multicast_memberships[i].multi_addr, multi_addr)) { ip6_addr_eq(&socket_ipv6_multicast_memberships[i].multi_addr, multi_addr)) {
socket_ipv6_multicast_memberships[i].sock = NULL; socket_ipv6_multicast_memberships[i].sock = NULL;
socket_ipv6_multicast_memberships[i].if_idx = NETIF_NO_INDEX; socket_ipv6_multicast_memberships[i].if_idx = NETIF_NO_INDEX;
ip6_addr_set_zero(&socket_ipv6_multicast_memberships[i].multi_addr); ip6_addr_set_zero(&socket_ipv6_multicast_memberships[i].multi_addr);

View File

@ -603,7 +603,7 @@ lwiperf_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
LWIP_ASSERT("invalid conn pcb", s->conn_pcb == NULL); LWIP_ASSERT("invalid conn pcb", s->conn_pcb == NULL);
if (s->specific_remote) { if (s->specific_remote) {
LWIP_ASSERT("s->base.related_master_state != NULL", s->base.related_master_state != NULL); LWIP_ASSERT("s->base.related_master_state != NULL", s->base.related_master_state != NULL);
if (!ip_addr_cmp(&newpcb->remote_ip, &s->remote_addr)) { if (!ip_addr_eq(&newpcb->remote_ip, &s->remote_addr)) {
/* this listener belongs to a client session, and this is not the correct remote */ /* this listener belongs to a client session, and this is not the correct remote */
return ERR_VAL; return ERR_VAL;
} }

View File

@ -2118,7 +2118,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
#if LWIP_IPV6 #if LWIP_IPV6
if (IP_IS_V6(ip_current_dest_addr())) { if (IP_IS_V6(ip_current_dest_addr())) {
/* instead of having one 'v6group' per netif, just compare zoneless here */ /* instead of having one 'v6group' per netif, just compare zoneless here */
if (!ip_addr_cmp_zoneless(ip_current_dest_addr(), &v6group)) { if (!ip_addr_zoneless_eq(ip_current_dest_addr(), &v6group)) {
packet.recv_unicast = 1; packet.recv_unicast = 1;
if (ip6_addr_ismulticast_global(ip_2_ip6(ip_current_src_addr())) if (ip6_addr_ismulticast_global(ip_2_ip6(ip_current_src_addr()))
@ -2130,10 +2130,10 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
#endif #endif
#if LWIP_IPV4 #if LWIP_IPV4
if (!IP_IS_V6(ip_current_dest_addr())) { if (!IP_IS_V6(ip_current_dest_addr())) {
if (!ip_addr_cmp(ip_current_dest_addr(), &v4group)) { if (!ip_addr_eq(ip_current_dest_addr(), &v4group)) {
packet.recv_unicast = 1; packet.recv_unicast = 1;
if (!ip4_addr_netcmp(ip_2_ip4(ip_current_src_addr()), if (!ip4_addr_net_eq(ip_2_ip4(ip_current_src_addr()),
netif_ip4_addr(recv_netif), netif_ip4_addr(recv_netif),
netif_ip4_netmask(recv_netif))){ netif_ip4_netmask(recv_netif))){
goto dealloc; goto dealloc;
@ -2164,7 +2164,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
struct mdns_packet *q = pending_tc_questions; struct mdns_packet *q = pending_tc_questions;
while (q) { while (q) {
if ((packet.source_port == q->source_port) && if ((packet.source_port == q->source_port) &&
ip_addr_cmp(&packet.source_addr, &q->source_addr)) ip_addr_eq(&packet.source_addr, &q->source_addr))
break; break;
q = q->next_tc_question; q = q->next_tc_question;
} }

View File

@ -263,7 +263,7 @@ ip_AddrTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_t row_
/* find netif with requested ip */ /* find netif with requested ip */
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
if (ip4_addr_cmp(&ip, netif_ip4_addr(netif))) { if (ip4_addr_eq(&ip, netif_ip4_addr(netif))) {
/* fill in object properties */ /* fill in object properties */
return ip_AddrTable_get_cell_value_core(netif, column, value, value_len); return ip_AddrTable_get_cell_value_core(netif, column, value, value_len);
} }
@ -417,7 +417,7 @@ ip_RouteTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_t row
ip4_addr_t dst; ip4_addr_t dst;
ip4_addr_get_network(&dst, netif_ip4_addr(netif), netif_ip4_netmask(netif)); ip4_addr_get_network(&dst, netif_ip4_addr(netif), netif_ip4_netmask(netif));
if (ip4_addr_cmp(&dst, &test_ip)) { if (ip4_addr_eq(&dst, &test_ip)) {
/* fill in object properties */ /* fill in object properties */
return ip_RouteTable_get_cell_value_core(netif, 0, column, value, value_len); return ip_RouteTable_get_cell_value_core(netif, 0, column, value, value_len);
} }
@ -535,7 +535,7 @@ ip_NetToMediaTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_
struct eth_addr *ethaddr; struct eth_addr *ethaddr;
if (etharp_get_entry(i, &ip, &netif, &ethaddr)) { if (etharp_get_entry(i, &ip, &netif, &ethaddr)) {
if ((netif_index == netif_to_num(netif)) && ip4_addr_cmp(&ip_in, ip)) { if ((netif_index == netif_to_num(netif)) && ip4_addr_eq(&ip_in, ip)) {
/* fill in object properties */ /* fill in object properties */
return ip_NetToMediaTable_get_cell_value_core(i, column, value, value_len); return ip_NetToMediaTable_get_cell_value_core(i, column, value, value_len);
} }

View File

@ -227,17 +227,17 @@ tcp_ConnTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_t row
while (pcb != NULL) { while (pcb != NULL) {
/* do local IP and local port match? */ /* do local IP and local port match? */
if (IP_IS_V4_VAL(pcb->local_ip) && if (IP_IS_V4_VAL(pcb->local_ip) &&
ip4_addr_cmp(&local_ip, ip_2_ip4(&pcb->local_ip)) && (local_port == pcb->local_port)) { ip4_addr_eq(&local_ip, ip_2_ip4(&pcb->local_ip)) && (local_port == pcb->local_port)) {
/* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */ /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */
if (pcb->state == LISTEN) { if (pcb->state == LISTEN) {
if (ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY4) && (remote_port == 0)) { if (ip4_addr_eq(&remote_ip, IP4_ADDR_ANY4) && (remote_port == 0)) {
/* fill in object properties */ /* fill in object properties */
return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len); return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len);
} }
} else { } else {
if (IP_IS_V4_VAL(pcb->remote_ip) && if (IP_IS_V4_VAL(pcb->remote_ip) &&
ip4_addr_cmp(&remote_ip, ip_2_ip4(&pcb->remote_ip)) && (remote_port == pcb->remote_port)) { ip4_addr_eq(&remote_ip, ip_2_ip4(&pcb->remote_ip)) && (remote_port == pcb->remote_port)) {
/* fill in object properties */ /* fill in object properties */
return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len); return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len);
} }
@ -355,9 +355,9 @@ tcp_ConnectionTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8
pcb = *tcp_pcb_nonlisten_lists[i]; pcb = *tcp_pcb_nonlisten_lists[i];
while (pcb != NULL) { while (pcb != NULL) {
if (ip_addr_cmp(&local_ip, &pcb->local_ip) && if (ip_addr_eq(&local_ip, &pcb->local_ip) &&
(local_port == pcb->local_port) && (local_port == pcb->local_port) &&
ip_addr_cmp(&remote_ip, &pcb->remote_ip) && ip_addr_eq(&remote_ip, &pcb->remote_ip) &&
(remote_port == pcb->remote_port)) { (remote_port == pcb->remote_port)) {
/* fill in object properties */ /* fill in object properties */
return tcp_ConnectionTable_get_cell_value_core(column, pcb, value); return tcp_ConnectionTable_get_cell_value_core(column, pcb, value);
@ -454,7 +454,7 @@ tcp_ListenerTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_t
/* find tcp_pcb with requested ip and port*/ /* find tcp_pcb with requested ip and port*/
pcb = tcp_listen_pcbs.listen_pcbs; pcb = tcp_listen_pcbs.listen_pcbs;
while (pcb != NULL) { while (pcb != NULL) {
if (ip_addr_cmp(&local_ip, &pcb->local_ip) && if (ip_addr_eq(&local_ip, &pcb->local_ip) &&
(local_port == pcb->local_port)) { (local_port == pcb->local_port)) {
/* fill in object properties */ /* fill in object properties */
return tcp_ListenerTable_get_cell_value_core(column, value); return tcp_ListenerTable_get_cell_value_core(column, value);

View File

@ -147,9 +147,9 @@ udp_endpointTable_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_t
/* find udp_pcb with requested ip and port*/ /* find udp_pcb with requested ip and port*/
pcb = udp_pcbs; pcb = udp_pcbs;
while (pcb != NULL) { while (pcb != NULL) {
if (ip_addr_cmp(&local_ip, &pcb->local_ip) && if (ip_addr_eq(&local_ip, &pcb->local_ip) &&
(local_port == pcb->local_port) && (local_port == pcb->local_port) &&
ip_addr_cmp(&remote_ip, &pcb->remote_ip) && ip_addr_eq(&remote_ip, &pcb->remote_ip) &&
(remote_port == pcb->remote_port)) { (remote_port == pcb->remote_port)) {
/* fill in object properties */ /* fill in object properties */
return udp_endpointTable_get_cell_value_core(column, value); return udp_endpointTable_get_cell_value_core(column, value);
@ -263,7 +263,7 @@ udp_Table_get_cell_value(const u32_t *column, const u32_t *row_oid, u8_t row_oid
pcb = udp_pcbs; pcb = udp_pcbs;
while (pcb != NULL) { while (pcb != NULL) {
if (IP_IS_V4_VAL(pcb->local_ip)) { if (IP_IS_V4_VAL(pcb->local_ip)) {
if (ip4_addr_cmp(&ip, ip_2_ip4(&pcb->local_ip)) && (port == pcb->local_port)) { if (ip4_addr_eq(&ip, ip_2_ip4(&pcb->local_ip)) && (port == pcb->local_port)) {
/* fill in object properties */ /* fill in object properties */
return udp_Table_get_cell_value_core(pcb, column, value, value_len); return udp_Table_get_cell_value_core(pcb, column, value, value_len);
} }

View File

@ -467,7 +467,7 @@ sntp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
err = ERR_ARG; err = ERR_ARG;
#if SNTP_CHECK_RESPONSE >= 1 #if SNTP_CHECK_RESPONSE >= 1
/* check server address and port */ /* check server address and port */
if (((sntp_opmode != SNTP_OPMODE_POLL) || ip_addr_cmp(addr, &sntp_last_server_address)) && if (((sntp_opmode != SNTP_OPMODE_POLL) || ip_addr_eq(addr, &sntp_last_server_address)) &&
(port == SNTP_PORT)) (port == SNTP_PORT))
#else /* SNTP_CHECK_RESPONSE >= 1 */ #else /* SNTP_CHECK_RESPONSE >= 1 */
LWIP_UNUSED_ARG(addr); LWIP_UNUSED_ARG(addr);

View File

@ -249,7 +249,7 @@ tftp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr
LWIP_UNUSED_ARG(upcb); LWIP_UNUSED_ARG(upcb);
if (((tftp_state.port != 0) && (port != tftp_state.port)) || if (((tftp_state.port != 0) && (port != tftp_state.port)) ||
(!ip_addr_isany_val(tftp_state.addr) && !ip_addr_cmp(&tftp_state.addr, addr))) { (!ip_addr_isany_val(tftp_state.addr) && !ip_addr_eq(&tftp_state.addr, addr))) {
send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "Only one connection at a time is supported"); send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "Only one connection at a time is supported");
pbuf_free(p); pbuf_free(p);
return; return;

View File

@ -545,7 +545,7 @@ dns_local_removehost(const char *hostname, const ip_addr_t *addr)
struct local_hostlist_entry *last_entry = NULL; struct local_hostlist_entry *last_entry = NULL;
while (entry != NULL) { while (entry != NULL) {
if (((hostname == NULL) || !lwip_stricmp(entry->name, hostname)) && if (((hostname == NULL) || !lwip_stricmp(entry->name, hostname)) &&
((addr == NULL) || ip_addr_cmp(&entry->addr, addr))) { ((addr == NULL) || ip_addr_eq(&entry->addr, addr))) {
struct local_hostlist_entry *free_entry; struct local_hostlist_entry *free_entry;
if (last_entry != NULL) { if (last_entry != NULL) {
last_entry->next = entry->next; last_entry->next = entry->next;
@ -1237,7 +1237,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
{ {
/* Check whether response comes from the same network address to which the /* Check whether response comes from the same network address to which the
question was sent. (RFC 5452) */ question was sent. (RFC 5452) */
if (!ip_addr_cmp(addr, &dns_servers[entry->server_idx])) { if (!ip_addr_eq(addr, &dns_servers[entry->server_idx])) {
goto ignore_packet; /* ignore this packet */ goto ignore_packet; /* ignore this packet */
} }
} }

View File

@ -378,10 +378,10 @@ acd_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
* OR * OR
* ip.dst == ipaddr && hw.src != own hwaddr (someone else is probing it) * ip.dst == ipaddr && hw.src != own hwaddr (someone else is probing it)
*/ */
if ((ip4_addr_cmp(&sipaddr, &acd->ipaddr)) || if ((ip4_addr_eq(&sipaddr, &acd->ipaddr)) ||
(ip4_addr_isany_val(sipaddr) && (ip4_addr_isany_val(sipaddr) &&
ip4_addr_cmp(&dipaddr, &acd->ipaddr) && ip4_addr_eq(&dipaddr, &acd->ipaddr) &&
!eth_addr_cmp(&netifaddr, &hdr->shwaddr))) { !eth_addr_eq(&netifaddr, &hdr->shwaddr))) {
LWIP_DEBUGF(ACD_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, LWIP_DEBUGF(ACD_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING,
("acd_arp_reply(): Probe Conflict detected\n")); ("acd_arp_reply(): Probe Conflict detected\n"));
acd_restart(netif, acd); acd_restart(netif, acd);
@ -395,8 +395,8 @@ acd_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
* in any state we have a conflict if * in any state we have a conflict if
* ip.src == ipaddr && hw.src != own hwaddr (someone is using our address) * ip.src == ipaddr && hw.src != own hwaddr (someone is using our address)
*/ */
if (ip4_addr_cmp(&sipaddr, &acd->ipaddr) && if (ip4_addr_eq(&sipaddr, &acd->ipaddr) &&
!eth_addr_cmp(&netifaddr, &hdr->shwaddr)) { !eth_addr_eq(&netifaddr, &hdr->shwaddr)) {
LWIP_DEBUGF(ACD_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, LWIP_DEBUGF(ACD_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING,
("acd_arp_reply(): Conflicting ARP-Packet detected\n")); ("acd_arp_reply(): Conflicting ARP-Packet detected\n"));
acd_handle_arp_conflict(netif, acd); acd_handle_arp_conflict(netif, acd);
@ -513,7 +513,7 @@ acd_netif_ip_addr_changed(struct netif *netif, const ip_addr_t *old_addr,
ACD_FOREACH(acd, netif->acd_list) { ACD_FOREACH(acd, netif->acd_list) {
/* Find ACD module of old address */ /* Find ACD module of old address */
if(ip4_addr_cmp(&acd->ipaddr, ip_2_ip4(old_addr))) { if(ip4_addr_eq(&acd->ipaddr, ip_2_ip4(old_addr))) {
/* Did we change from a LL address to a routable address? */ /* Did we change from a LL address to a routable address? */
if (ip_addr_islinklocal(old_addr) && !ip_addr_islinklocal(new_addr)) { if (ip_addr_islinklocal(old_addr) && !ip_addr_islinklocal(new_addr)) {
LWIP_DEBUGF(ACD_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, LWIP_DEBUGF(ACD_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,

View File

@ -363,7 +363,7 @@ autoip_supplied_address(struct netif *netif)
{ {
struct autoip *autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
return (autoip != NULL) return (autoip != NULL)
&& (ip4_addr_cmp(netif_ip4_addr(netif), &(autoip->llipaddr))) && (ip4_addr_eq(netif_ip4_addr(netif), &(autoip->llipaddr)))
&& (autoip->state == AUTOIP_STATE_BOUND); && (autoip->state == AUTOIP_STATE_BOUND);
} }
@ -372,7 +372,7 @@ autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr)
{ {
struct autoip *autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
return (autoip != NULL) return (autoip != NULL)
&& (ip4_addr_cmp(addr, &(autoip->llipaddr))) && (ip4_addr_eq(addr, &(autoip->llipaddr)))
&& (autoip->state == AUTOIP_STATE_BOUND); && (autoip->state == AUTOIP_STATE_BOUND);
} }

View File

@ -292,7 +292,7 @@ etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif *netif)
LWIP_ASSERT("state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE", LWIP_ASSERT("state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE",
state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE); state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE);
/* if given, does IP address match IP address in ARP entry? */ /* if given, does IP address match IP address in ARP entry? */
if (ipaddr && ip4_addr_cmp(ipaddr, &arp_table[i].ipaddr) if (ipaddr && ip4_addr_eq(ipaddr, &arp_table[i].ipaddr)
#if ETHARP_TABLE_MATCH_NETIF #if ETHARP_TABLE_MATCH_NETIF
&& ((netif == NULL) || (netif == arp_table[i].netif)) && ((netif == NULL) || (netif == arp_table[i].netif))
#endif /* ETHARP_TABLE_MATCH_NETIF */ #endif /* ETHARP_TABLE_MATCH_NETIF */
@ -689,9 +689,9 @@ etharp_input(struct pbuf *p, struct netif *netif)
from_us = 0; from_us = 0;
} else { } else {
/* ARP packet directed to us? */ /* ARP packet directed to us? */
for_us = (u8_t)ip4_addr_cmp(&dipaddr, netif_ip4_addr(netif)); for_us = (u8_t)ip4_addr_eq(&dipaddr, netif_ip4_addr(netif));
/* ARP packet from us? */ /* ARP packet from us? */
from_us = (u8_t)ip4_addr_cmp(&sipaddr, netif_ip4_addr(netif)); from_us = (u8_t)ip4_addr_eq(&sipaddr, netif_ip4_addr(netif));
} }
/* ARP message directed to us? /* ARP message directed to us?
@ -823,7 +823,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
netif_addr_idx_t i; netif_addr_idx_t i;
/* outside local network? if so, this can neither be a global broadcast nor /* outside local network? if so, this can neither be a global broadcast nor
a subnet broadcast. */ a subnet broadcast. */
if (!ip4_addr_netcmp(ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) && if (!ip4_addr_net_eq(ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) &&
!ip4_addr_islinklocal(ipaddr)) { !ip4_addr_islinklocal(ipaddr)) {
#if LWIP_AUTOIP #if LWIP_AUTOIP
struct ip_hdr *iphdr = LWIP_ALIGNMENT_CAST(struct ip_hdr *, q->payload); struct ip_hdr *iphdr = LWIP_ALIGNMENT_CAST(struct ip_hdr *, q->payload);
@ -863,7 +863,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
#if ETHARP_TABLE_MATCH_NETIF #if ETHARP_TABLE_MATCH_NETIF
(arp_table[etharp_cached_entry].netif == netif) && (arp_table[etharp_cached_entry].netif == netif) &&
#endif #endif
(ip4_addr_cmp(dst_addr, &arp_table[etharp_cached_entry].ipaddr))) { (ip4_addr_eq(dst_addr, &arp_table[etharp_cached_entry].ipaddr))) {
/* the per-pcb-cached entry is stable and the right one! */ /* the per-pcb-cached entry is stable and the right one! */
ETHARP_STATS_INC(etharp.cachehit); ETHARP_STATS_INC(etharp.cachehit);
return etharp_output_to_arp_index(netif, q, etharp_cached_entry); return etharp_output_to_arp_index(netif, q, etharp_cached_entry);
@ -880,7 +880,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
#if ETHARP_TABLE_MATCH_NETIF #if ETHARP_TABLE_MATCH_NETIF
(arp_table[i].netif == netif) && (arp_table[i].netif == netif) &&
#endif #endif
(ip4_addr_cmp(dst_addr, &arp_table[i].ipaddr))) { (ip4_addr_eq(dst_addr, &arp_table[i].ipaddr))) {
/* found an existing, stable entry */ /* found an existing, stable entry */
ETHARP_SET_ADDRHINT(netif, i); ETHARP_SET_ADDRHINT(netif, i);
return etharp_output_to_arp_index(netif, q, i); return etharp_output_to_arp_index(netif, q, i);

View File

@ -220,7 +220,7 @@ igmp_lookfor_group(struct netif *ifp, const ip4_addr_t *addr)
struct igmp_group *group = netif_igmp_data(ifp); struct igmp_group *group = netif_igmp_data(ifp);
while (group != NULL) { while (group != NULL) {
if (ip4_addr_cmp(&(group->group_address), addr)) { if (ip4_addr_eq(&(group->group_address), addr)) {
return group; return group;
} }
group = group->next; group = group->next;
@ -266,13 +266,13 @@ igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr)
if (list_head == NULL) { if (list_head == NULL) {
/* this is the first entry in linked list */ /* this is the first entry in linked list */
LWIP_ASSERT("igmp_lookup_group: first group must be allsystems", LWIP_ASSERT("igmp_lookup_group: first group must be allsystems",
(ip4_addr_cmp(addr, &allsystems) != 0)); (ip4_addr_eq(addr, &allsystems) != 0));
group->next = NULL; group->next = NULL;
netif_set_client_data(ifp, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP, group); netif_set_client_data(ifp, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP, group);
} else { } else {
/* append _after_ first entry */ /* append _after_ first entry */
LWIP_ASSERT("igmp_lookup_group: all except first group must not be allsystems", LWIP_ASSERT("igmp_lookup_group: all except first group must not be allsystems",
(ip4_addr_cmp(addr, &allsystems) == 0)); (ip4_addr_eq(addr, &allsystems) == 0));
group->next = list_head->next; group->next = list_head->next;
list_head->next = group; list_head->next = group;
} }
@ -366,7 +366,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
switch (igmp->igmp_msgtype) { switch (igmp->igmp_msgtype) {
case IGMP_MEMB_QUERY: case IGMP_MEMB_QUERY:
/* IGMP_MEMB_QUERY to the "all systems" address ? */ /* IGMP_MEMB_QUERY to the "all systems" address ? */
if ((ip4_addr_cmp(dest, &allsystems)) && ip4_addr_isany(&igmp->igmp_group_address)) { if ((ip4_addr_eq(dest, &allsystems)) && ip4_addr_isany(&igmp->igmp_group_address)) {
/* THIS IS THE GENERAL QUERY */ /* THIS IS THE GENERAL QUERY */
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: General IGMP_MEMB_QUERY on \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: General IGMP_MEMB_QUERY on \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
@ -395,7 +395,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
if (!ip4_addr_isany(&igmp->igmp_group_address)) { if (!ip4_addr_isany(&igmp->igmp_group_address)) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group "));
ip4_addr_debug_print_val(IGMP_DEBUG, igmp->igmp_group_address); ip4_addr_debug_print_val(IGMP_DEBUG, igmp->igmp_group_address);
if (ip4_addr_cmp(dest, &allsystems)) { if (ip4_addr_eq(dest, &allsystems)) {
ip4_addr_t groupaddr; ip4_addr_t groupaddr;
LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
/* we first need to re-look for the group since we used dest last time */ /* we first need to re-look for the group since we used dest last time */
@ -455,12 +455,12 @@ igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
/* make sure it is multicast address */ /* make sure it is multicast address */
LWIP_ERROR("igmp_joingroup: attempt to join non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;); LWIP_ERROR("igmp_joingroup: attempt to join non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;);
LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip4_addr_eq(groupaddr, &allsystems)), return ERR_VAL;);
/* loop through netif's */ /* loop through netif's */
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
/* Should we join this interface ? */ /* Should we join this interface ? */
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_cmp(netif_ip4_addr(netif), ifaddr)))) { if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_eq(netif_ip4_addr(netif), ifaddr)))) {
err = igmp_joingroup_netif(netif, groupaddr); err = igmp_joingroup_netif(netif, groupaddr);
if (err != ERR_OK) { if (err != ERR_OK) {
/* Return an error even if some network interfaces are joined */ /* Return an error even if some network interfaces are joined */
@ -490,7 +490,7 @@ igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
/* make sure it is multicast address */ /* make sure it is multicast address */
LWIP_ERROR("igmp_joingroup_netif: attempt to join non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;); LWIP_ERROR("igmp_joingroup_netif: attempt to join non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;);
LWIP_ERROR("igmp_joingroup_netif: attempt to join allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); LWIP_ERROR("igmp_joingroup_netif: attempt to join allsystems address", (!ip4_addr_eq(groupaddr, &allsystems)), return ERR_VAL;);
/* make sure it is an igmp-enabled netif */ /* make sure it is an igmp-enabled netif */
LWIP_ERROR("igmp_joingroup_netif: attempt to join on non-IGMP netif", netif->flags & NETIF_FLAG_IGMP, return ERR_VAL;); LWIP_ERROR("igmp_joingroup_netif: attempt to join on non-IGMP netif", netif->flags & NETIF_FLAG_IGMP, return ERR_VAL;);
@ -552,12 +552,12 @@ igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
/* make sure it is multicast address */ /* make sure it is multicast address */
LWIP_ERROR("igmp_leavegroup: attempt to leave non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;); LWIP_ERROR("igmp_leavegroup: attempt to leave non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;);
LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip4_addr_eq(groupaddr, &allsystems)), return ERR_VAL;);
/* loop through netif's */ /* loop through netif's */
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
/* Should we leave this interface ? */ /* Should we leave this interface ? */
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_cmp(netif_ip4_addr(netif), ifaddr)))) { if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_eq(netif_ip4_addr(netif), ifaddr)))) {
err_t res = igmp_leavegroup_netif(netif, groupaddr); err_t res = igmp_leavegroup_netif(netif, groupaddr);
if (err != ERR_OK) { if (err != ERR_OK) {
/* Store this result if we have not yet gotten a success */ /* Store this result if we have not yet gotten a success */
@ -586,7 +586,7 @@ igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
/* make sure it is multicast address */ /* make sure it is multicast address */
LWIP_ERROR("igmp_leavegroup_netif: attempt to leave non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;); LWIP_ERROR("igmp_leavegroup_netif: attempt to leave non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;);
LWIP_ERROR("igmp_leavegroup_netif: attempt to leave allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); LWIP_ERROR("igmp_leavegroup_netif: attempt to leave allsystems address", (!ip4_addr_eq(groupaddr, &allsystems)), return ERR_VAL;);
/* make sure it is an igmp-enabled netif */ /* make sure it is an igmp-enabled netif */
LWIP_ERROR("igmp_leavegroup_netif: attempt to leave on non-IGMP netif", netif->flags & NETIF_FLAG_IGMP, return ERR_VAL;); LWIP_ERROR("igmp_leavegroup_netif: attempt to leave on non-IGMP netif", netif->flags & NETIF_FLAG_IGMP, return ERR_VAL;);
@ -669,7 +669,7 @@ igmp_timeout(struct netif *netif, struct igmp_group *group)
/* If the state is IGMP_GROUP_DELAYING_MEMBER then we send a report for this group /* If the state is IGMP_GROUP_DELAYING_MEMBER then we send a report for this group
(unless it is the allsystems group) */ (unless it is the allsystems group) */
if ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) && if ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) &&
(!(ip4_addr_cmp(&(group->group_address), &allsystems)))) { (!(ip4_addr_eq(&(group->group_address), &allsystems)))) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address "));
ip4_addr_debug_print_val(IGMP_DEBUG, group->group_address); ip4_addr_debug_print_val(IGMP_DEBUG, group->group_address);
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void *)netif)); LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void *)netif));

View File

@ -171,12 +171,12 @@ ip4_route(const ip4_addr_t *dest)
/* is the netif up, does it have a link and a valid address? */ /* 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_ip4_addr(netif))) { if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
/* network mask matches? */ /* network mask matches? */
if (ip4_addr_netcmp(dest, netif_ip4_addr(netif), netif_ip4_netmask(netif))) { if (ip4_addr_net_eq(dest, netif_ip4_addr(netif), netif_ip4_netmask(netif))) {
/* return netif on which to forward IP packet */ /* return netif on which to forward IP packet */
return netif; return netif;
} }
/* gateway matches on a non broadcast interface? (i.e. peer in a point to point interface) */ /* gateway matches on a non broadcast interface? (i.e. peer in a point to point interface) */
if (((netif->flags & NETIF_FLAG_BROADCAST) == 0) && ip4_addr_cmp(dest, netif_ip4_gw(netif))) { if (((netif->flags & NETIF_FLAG_BROADCAST) == 0) && ip4_addr_eq(dest, netif_ip4_gw(netif))) {
/* return netif on which to forward IP packet */ /* return netif on which to forward IP packet */
return netif; return netif;
} }
@ -416,7 +416,7 @@ ip4_input_accept(struct netif *netif)
/* interface is up and configured? */ /* interface is up and configured? */
if ((netif_is_up(netif)) && (!ip4_addr_isany_val(*netif_ip4_addr(netif)))) { if ((netif_is_up(netif)) && (!ip4_addr_isany_val(*netif_ip4_addr(netif)))) {
/* unicast to this interface address? */ /* unicast to this interface address? */
if (ip4_addr_cmp(ip4_current_dest_addr(), netif_ip4_addr(netif)) || if (ip4_addr_eq(ip4_current_dest_addr(), netif_ip4_addr(netif)) ||
/* or broadcast on this interface network address? */ /* or broadcast on this interface network address? */
ip4_addr_isbroadcast(ip4_current_dest_addr(), netif) ip4_addr_isbroadcast(ip4_current_dest_addr(), netif)
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF #if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
@ -556,7 +556,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
/* IGMP snooping switches need 0.0.0.0 to be allowed as source address (RFC 4541) */ /* IGMP snooping switches need 0.0.0.0 to be allowed as source address (RFC 4541) */
ip4_addr_t allsystems; ip4_addr_t allsystems;
IP4_ADDR(&allsystems, 224, 0, 0, 1); IP4_ADDR(&allsystems, 224, 0, 0, 1);
if (ip4_addr_cmp(ip4_current_dest_addr(), &allsystems) && if (ip4_addr_eq(ip4_current_dest_addr(), &allsystems) &&
ip4_addr_isany(ip4_current_src_addr())) { ip4_addr_isany(ip4_current_src_addr())) {
check_ip_src = 0; check_ip_src = 0;
} }
@ -1015,7 +1015,7 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d
ip4_debug_print(p); ip4_debug_print(p);
#if ENABLE_LOOPBACK #if ENABLE_LOOPBACK
if (ip4_addr_cmp(dest, netif_ip4_addr(netif)) if (ip4_addr_eq(dest, netif_ip4_addr(netif))
#if !LWIP_HAVE_LOOPIF #if !LWIP_HAVE_LOOPIF
|| ip4_addr_isloopback(dest) || ip4_addr_isloopback(dest)
#endif /* !LWIP_HAVE_LOOPIF */ #endif /* !LWIP_HAVE_LOOPIF */

View File

@ -73,7 +73,7 @@ ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif)
} else if (addr == ip4_addr_get_u32(netif_ip4_addr(netif))) { } else if (addr == ip4_addr_get_u32(netif_ip4_addr(netif))) {
return 0; return 0;
/* on the same (sub) network... */ /* on the same (sub) network... */
} else if (ip4_addr_netcmp(&ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) } else if (ip4_addr_net_eq(&ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif))
/* ...and host identifier bits are all ones? =>... */ /* ...and host identifier bits are all ones? =>... */
&& ((addr & ~ip4_addr_get_u32(netif_ip4_netmask(netif))) == && ((addr & ~ip4_addr_get_u32(netif_ip4_netmask(netif))) ==
(IPADDR_BROADCAST & ~ip4_addr_get_u32(netif_ip4_netmask(netif))))) { (IPADDR_BROADCAST & ~ip4_addr_get_u32(netif_ip4_netmask(netif))))) {

View File

@ -106,8 +106,8 @@ PACK_STRUCT_END
#endif #endif
#define IP_ADDRESSES_AND_ID_MATCH(iphdrA, iphdrB) \ #define IP_ADDRESSES_AND_ID_MATCH(iphdrA, iphdrB) \
(ip4_addr_cmp(&(iphdrA)->src, &(iphdrB)->src) && \ (ip4_addr_eq(&(iphdrA)->src, &(iphdrB)->src) && \
ip4_addr_cmp(&(iphdrA)->dest, &(iphdrB)->dest) && \ ip4_addr_eq(&(iphdrA)->dest, &(iphdrB)->dest) && \
IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0 IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0
/* global variables */ /* global variables */

View File

@ -166,7 +166,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
} }
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp_zoneless(src, netif_ip6_addr(netif, i))) { ip6_addr_zoneless_eq(src, netif_ip6_addr(netif, i))) {
return netif; return netif;
} }
} }
@ -199,9 +199,9 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
} }
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_netcmp(dest, netif_ip6_addr(netif, i)) && ip6_addr_net_eq(dest, netif_ip6_addr(netif, i)) &&
(netif_ip6_addr_isstatic(netif, i) || (netif_ip6_addr_isstatic(netif, i) ||
ip6_addr_nethostcmp(dest, netif_ip6_addr(netif, i)))) { ip6_addr_nethost_eq(dest, netif_ip6_addr(netif, i)))) {
return netif; return netif;
} }
} }
@ -222,7 +222,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
} }
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp(src, netif_ip6_addr(netif, i))) { ip6_addr_eq(src, netif_ip6_addr(netif, i))) {
return netif; return netif;
} }
} }
@ -332,8 +332,8 @@ ip6_select_source_address(struct netif *netif, const ip6_addr_t *dest)
/* @todo compute the actual common bits, for longest matching prefix. */ /* @todo compute the actual common bits, for longest matching prefix. */
/* We cannot count on the destination address having a proper zone /* We cannot count on the destination address having a proper zone
* assignment, so do not compare zones in this case. */ * assignment, so do not compare zones in this case. */
cand_bits = ip6_addr_netcmp_zoneless(cand_addr, dest); /* just 1 or 0 for now */ cand_bits = ip6_addr_net_zoneless_eq(cand_addr, dest); /* just 1 or 0 for now */
if (cand_bits && ip6_addr_nethostcmp(cand_addr, dest)) { if (cand_bits && ip6_addr_nethost_eq(cand_addr, dest)) {
return netif_ip_addr6(netif, i); /* Rule 1 */ return netif_ip_addr6(netif, i); /* Rule 1 */
} }
if ((best_addr == NULL) || /* no alternative yet */ if ((best_addr == NULL) || /* no alternative yet */
@ -477,7 +477,7 @@ ip6_input_accept(struct netif *netif)
* scope as well (e.g., is this interface on the same link?). */ * scope as well (e.g., is this interface on the same link?). */
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp(ip6_current_dest_addr(), netif_ip6_addr(netif, i)) ip6_addr_eq(ip6_current_dest_addr(), netif_ip6_addr(netif, i))
#if IPV6_CUSTOM_SCOPES #if IPV6_CUSTOM_SCOPES
&& (!ip6_addr_has_zone(ip6_current_src_addr()) || && (!ip6_addr_has_zone(ip6_current_src_addr()) ||
ip6_addr_test_zone(ip6_current_src_addr(), netif)) ip6_addr_test_zone(ip6_current_src_addr(), netif))
@ -611,7 +611,7 @@ ip6_input(struct pbuf *p, struct netif *inp)
netif = NULL; netif = NULL;
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) &&
ip6_addr_cmp_solicitednode(ip6_current_dest_addr(), netif_ip6_addr(inp, i))) { ip6_addr_solicitednode_eq(ip6_current_dest_addr(), netif_ip6_addr(inp, i))) {
netif = inp; netif = inp;
LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: solicited node packet accepted on interface %c%c\n", LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: solicited node packet accepted on interface %c%c\n",
netif->name[0], netif->name[1])); netif->name[0], netif->name[1]));
@ -1245,7 +1245,7 @@ ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
#endif /* !LWIP_HAVE_LOOPIF */ #endif /* !LWIP_HAVE_LOOPIF */
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp(dest, netif_ip6_addr(netif, i))) { ip6_addr_eq(dest, netif_ip6_addr(netif, i))) {
/* Packet to self, enqueue it for loopback */ /* Packet to self, enqueue it for loopback */
LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n")); LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
return netif_loop_output(netif, p); return netif_loop_output(netif, p);

View File

@ -320,8 +320,8 @@ ip6_reass(struct pbuf *p)
in the reassembly buffer. If so, we proceed with copying the in the reassembly buffer. If so, we proceed with copying the
fragment into the buffer. */ fragment into the buffer. */
if ((frag_hdr->_identification == ipr->identification) && if ((frag_hdr->_identification == ipr->identification) &&
ip6_addr_cmp_packed(ip6_current_src_addr(), &(IPV6_FRAG_SRC(ipr)), ipr->src_zone) && ip6_addr_packed_eq(ip6_current_src_addr(), &(IPV6_FRAG_SRC(ipr)), ipr->src_zone) &&
ip6_addr_cmp_packed(ip6_current_dest_addr(), &(IPV6_FRAG_DEST(ipr)), ipr->dest_zone)) { ip6_addr_packed_eq(ip6_current_dest_addr(), &(IPV6_FRAG_DEST(ipr)), ipr->dest_zone)) {
IP6_FRAG_STATS_INC(ip6_frag.cachehit); IP6_FRAG_STATS_INC(ip6_frag.cachehit);
break; break;
} }

View File

@ -146,7 +146,7 @@ mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr)
struct mld_group *group = netif_mld6_data(ifp); struct mld_group *group = netif_mld6_data(ifp);
while (group != NULL) { while (group != NULL) {
if (ip6_addr_cmp(&(group->group_address), addr)) { if (ip6_addr_eq(&(group->group_address), addr)) {
return group; return group;
} }
group = group->next; group = group->next;

View File

@ -225,7 +225,7 @@ nd6_process_autoconfig_prefix(struct netif *netif,
for (i = 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
addr_state = netif_ip6_addr_state(netif, i); addr_state = netif_ip6_addr_state(netif, i);
if (!ip6_addr_isinvalid(addr_state) && !netif_ip6_addr_isstatic(netif, i) && if (!ip6_addr_isinvalid(addr_state) && !netif_ip6_addr_isstatic(netif, i) &&
ip6_addr_netcmp(prefix_addr, netif_ip6_addr(netif, i))) { ip6_addr_net_eq(prefix_addr, netif_ip6_addr(netif, i))) {
/* Update the valid lifetime, as per RFC 4862 Sec. 5.5.3 point (e). /* Update the valid lifetime, as per RFC 4862 Sec. 5.5.3 point (e).
* The valid lifetime will never drop to zero as a result of this. */ * The valid lifetime will never drop to zero as a result of this. */
u32_t remaining_life = netif_ip6_addr_valid_life(netif, i); u32_t remaining_life = netif_ip6_addr_valid_life(netif, i);
@ -273,7 +273,7 @@ nd6_process_autoconfig_prefix(struct netif *netif,
free_idx = 0; free_idx = 0;
for (i = 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) { if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
if (ip6_addr_cmp(&ip6addr, netif_ip6_addr(netif, i))) { if (ip6_addr_eq(&ip6addr, netif_ip6_addr(netif, i))) {
return; /* formed address already exists */ return; /* formed address already exists */
} }
} else if (free_idx == 0) { } else if (free_idx == 0) {
@ -353,7 +353,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (!ip6_addr_isinvalid(netif_ip6_addr_state(inp, i)) && if (!ip6_addr_isinvalid(netif_ip6_addr_state(inp, i)) &&
!ip6_addr_isduplicated(netif_ip6_addr_state(inp, i)) && !ip6_addr_isduplicated(netif_ip6_addr_state(inp, i)) &&
ip6_addr_cmp(&target_address, netif_ip6_addr(inp, i))) { ip6_addr_eq(&target_address, netif_ip6_addr(inp, i))) {
/* We are using a duplicate address. */ /* We are using a duplicate address. */
nd6_duplicate_addr_detected(inp, i); nd6_duplicate_addr_detected(inp, i);
@ -490,7 +490,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
if ((ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) || if ((ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) ||
(ip6_addr_istentative(netif_ip6_addr_state(inp, i)) && (ip6_addr_istentative(netif_ip6_addr_state(inp, i)) &&
ip6_addr_isany(ip6_current_src_addr()))) && ip6_addr_isany(ip6_current_src_addr()))) &&
ip6_addr_cmp(&target_address, netif_ip6_addr(inp, i))) { ip6_addr_eq(&target_address, netif_ip6_addr(inp, i))) {
accepted = 1; accepted = 1;
break; break;
} }
@ -507,7 +507,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
/* Sender is validating this address. */ /* Sender is validating this address. */
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) {
if (!ip6_addr_isinvalid(netif_ip6_addr_state(inp, i)) && if (!ip6_addr_isinvalid(netif_ip6_addr_state(inp, i)) &&
ip6_addr_cmp(&target_address, netif_ip6_addr(inp, i))) { ip6_addr_eq(&target_address, netif_ip6_addr(inp, i))) {
/* Send a NA back so that the sender does not use this address. */ /* Send a NA back so that the sender does not use this address. */
nd6_send_na(inp, netif_ip6_addr(inp, i), ND6_FLAG_OVERRIDE | ND6_SEND_FLAG_ALLNODES_DEST); nd6_send_na(inp, netif_ip6_addr(inp, i), ND6_FLAG_OVERRIDE | ND6_SEND_FLAG_ALLNODES_DEST);
if (ip6_addr_istentative(netif_ip6_addr_state(inp, i))) { if (ip6_addr_istentative(netif_ip6_addr_state(inp, i))) {
@ -797,7 +797,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
u8_t s; u8_t s;
for (s = 0; s < DNS_MAX_SERVERS; s++) { for (s = 0; s < DNS_MAX_SERVERS; s++) {
const ip_addr_t *addr = dns_getserver(s); const ip_addr_t *addr = dns_getserver(s);
if(ip_addr_cmp(addr, &rdnss_address)) { if(ip_addr_eq(addr, &rdnss_address)) {
dns_setserver(s, NULL); dns_setserver(s, NULL);
} }
} }
@ -1047,7 +1047,7 @@ nd6_tmr(void)
* its destination cache entries, as per RFC 4861 Sec. 5.3 and 6.3.5. */ * its destination cache entries, as per RFC 4861 Sec. 5.3 and 6.3.5. */
s8_t j; s8_t j;
for (j = 0; j < LWIP_ND6_NUM_DESTINATIONS; j++) { for (j = 0; j < LWIP_ND6_NUM_DESTINATIONS; j++) {
if (ip6_addr_cmp(&destination_cache[j].next_hop_addr, if (ip6_addr_eq(&destination_cache[j].next_hop_addr,
&default_router_list[i].neighbor_entry->next_hop_address)) { &default_router_list[i].neighbor_entry->next_hop_address)) {
ip6_addr_set_any(&destination_cache[j].destination_addr); ip6_addr_set_any(&destination_cache[j].destination_addr);
} }
@ -1206,7 +1206,7 @@ nd6_send_ns(struct netif *netif, const ip6_addr_t *target_addr, u8_t flags)
int i; int i;
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_netcmp(target_addr, netif_ip6_addr(netif, i))) { ip6_addr_net_eq(target_addr, netif_ip6_addr(netif, i))) {
src_addr = netif_ip6_addr(netif, i); src_addr = netif_ip6_addr(netif, i);
break; break;
} }
@ -1429,7 +1429,7 @@ nd6_find_neighbor_cache_entry(const ip6_addr_t *ip6addr)
{ {
s8_t i; s8_t i;
for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
if (ip6_addr_cmp(ip6addr, &(neighbor_cache[i].next_hop_address))) { if (ip6_addr_eq(ip6addr, &(neighbor_cache[i].next_hop_address))) {
return i; return i;
} }
} }
@ -1591,7 +1591,7 @@ nd6_find_destination_cache_entry(const ip6_addr_t *ip6addr)
IP6_ADDR_ZONECHECK(ip6addr); IP6_ADDR_ZONECHECK(ip6addr);
for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) {
if (ip6_addr_cmp(ip6addr, &(destination_cache[i].destination_addr))) { if (ip6_addr_eq(ip6addr, &(destination_cache[i].destination_addr))) {
return i; return i;
} }
} }
@ -1662,7 +1662,7 @@ nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif)
for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) { for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) {
if ((prefix_list[i].netif == netif) && if ((prefix_list[i].netif == netif) &&
(prefix_list[i].invalidation_timer > 0) && (prefix_list[i].invalidation_timer > 0) &&
ip6_addr_netcmp(ip6addr, &(prefix_list[i].prefix))) { ip6_addr_net_eq(ip6addr, &(prefix_list[i].prefix))) {
return 1; return 1;
} }
} }
@ -1673,7 +1673,7 @@ nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif)
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
netif_ip6_addr_isstatic(netif, i) && netif_ip6_addr_isstatic(netif, i) &&
ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i))) { ip6_addr_net_eq(ip6addr, netif_ip6_addr(netif, i))) {
return 1; return 1;
} }
} }
@ -1777,7 +1777,7 @@ nd6_find_route(const ip6_addr_t *ip6addr)
* matches. Pick the first one that is associated with a suitable netif. */ * matches. Pick the first one that is associated with a suitable netif. */
for (i = 0; i < LWIP_ND6_NUM_PREFIXES; ++i) { for (i = 0; i < LWIP_ND6_NUM_PREFIXES; ++i) {
netif = prefix_list[i].netif; netif = prefix_list[i].netif;
if ((netif != NULL) && ip6_addr_netcmp(&prefix_list[i].prefix, ip6addr) && if ((netif != NULL) && ip6_addr_net_eq(&prefix_list[i].prefix, ip6addr) &&
netif_is_up(netif) && netif_is_link_up(netif)) { netif_is_up(netif) && netif_is_link_up(netif)) {
return netif; return netif;
} }
@ -1812,7 +1812,7 @@ nd6_get_router(const ip6_addr_t *router_addr, struct netif *netif)
for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) { for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) {
if ((default_router_list[i].neighbor_entry != NULL) && if ((default_router_list[i].neighbor_entry != NULL) &&
((netif != NULL) ? netif == default_router_list[i].neighbor_entry->netif : 1) && ((netif != NULL) ? netif == default_router_list[i].neighbor_entry->netif : 1) &&
ip6_addr_cmp(router_addr, &(default_router_list[i].neighbor_entry->next_hop_address))) { ip6_addr_eq(router_addr, &(default_router_list[i].neighbor_entry->next_hop_address))) {
return i; return i;
} }
} }
@ -1898,7 +1898,7 @@ nd6_get_onlink_prefix(const ip6_addr_t *prefix, struct netif *netif)
/* Look for prefix in list. */ /* Look for prefix in list. */
for (i = 0; i < LWIP_ND6_NUM_PREFIXES; ++i) { for (i = 0; i < LWIP_ND6_NUM_PREFIXES; ++i) {
if ((ip6_addr_netcmp(&(prefix_list[i].prefix), prefix)) && if ((ip6_addr_net_eq(&(prefix_list[i].prefix), prefix)) &&
(prefix_list[i].netif == netif)) { (prefix_list[i].netif == netif)) {
return i; return i;
} }
@ -1973,7 +1973,7 @@ nd6_get_next_hop_entry(const ip6_addr_t *ip6addr, struct netif *netif)
/* Look for ip6addr in destination cache. */ /* Look for ip6addr in destination cache. */
dest = &destination_cache[nd6_cached_destination_index]; dest = &destination_cache[nd6_cached_destination_index];
if (ip6_addr_cmp(ip6addr, &dest->destination_addr)) { if (ip6_addr_eq(ip6addr, &dest->destination_addr)) {
/* the cached entry index is the right one! */ /* the cached entry index is the right one! */
/* do nothing. */ /* do nothing. */
ND6_STATS_INC(nd6.cachehit); ND6_STATS_INC(nd6.cachehit);
@ -2034,7 +2034,7 @@ nd6_get_next_hop_entry(const ip6_addr_t *ip6addr, struct netif *netif)
} }
/* Look in neighbor cache for the next-hop address. */ /* Look in neighbor cache for the next-hop address. */
if (ip6_addr_cmp(&dest->next_hop_addr, if (ip6_addr_eq(&dest->next_hop_addr,
&(neighbor_cache[dest->cached_neighbor_idx].next_hop_address))) { &(neighbor_cache[dest->cached_neighbor_idx].next_hop_address))) {
/* Cache hit. */ /* Cache hit. */
/* Do nothing. */ /* Do nothing. */
@ -2360,7 +2360,7 @@ nd6_reachability_hint(const ip6_addr_t *ip6addr)
struct nd6_destination_cache_entry *dest; struct nd6_destination_cache_entry *dest;
/* Find destination in cache. */ /* Find destination in cache. */
if (ip6_addr_cmp(ip6addr, &(destination_cache[nd6_cached_destination_index].destination_addr))) { if (ip6_addr_eq(ip6addr, &(destination_cache[nd6_cached_destination_index].destination_addr))) {
dst_idx = nd6_cached_destination_index; dst_idx = nd6_cached_destination_index;
ND6_STATS_INC(nd6.cachehit); ND6_STATS_INC(nd6.cachehit);
} else { } else {
@ -2372,7 +2372,7 @@ nd6_reachability_hint(const ip6_addr_t *ip6addr)
/* Find next hop neighbor in cache. */ /* Find next hop neighbor in cache. */
dest = &destination_cache[dst_idx]; dest = &destination_cache[dst_idx];
if (ip6_addr_cmp(&dest->next_hop_addr, &(neighbor_cache[dest->cached_neighbor_idx].next_hop_address))) { if (ip6_addr_eq(&dest->next_hop_addr, &(neighbor_cache[dest->cached_neighbor_idx].next_hop_address))) {
i = dest->cached_neighbor_idx; i = dest->cached_neighbor_idx;
ND6_STATS_INC(nd6.cachehit); ND6_STATS_INC(nd6.cachehit);
} else { } else {

View File

@ -477,7 +477,7 @@ netif_do_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr, ip_addr_t *ol
LWIP_ASSERT("invalid pointer", old_addr != NULL); LWIP_ASSERT("invalid pointer", old_addr != NULL);
/* address is actually being changed? */ /* address is actually being changed? */
if (ip4_addr_cmp(ipaddr, netif_ip4_addr(netif)) == 0) { if (ip4_addr_eq(ipaddr, netif_ip4_addr(netif)) == 0) {
ip_addr_t new_addr; ip_addr_t new_addr;
*ip_2_ip4(&new_addr) = *ipaddr; *ip_2_ip4(&new_addr) = *ipaddr;
IP_SET_TYPE_VAL(new_addr, IPADDR_TYPE_V4); IP_SET_TYPE_VAL(new_addr, IPADDR_TYPE_V4);
@ -544,7 +544,7 @@ static int
netif_do_set_netmask(struct netif *netif, const ip4_addr_t *netmask, ip_addr_t *old_nm) netif_do_set_netmask(struct netif *netif, const ip4_addr_t *netmask, ip_addr_t *old_nm)
{ {
/* address is actually being changed? */ /* address is actually being changed? */
if (ip4_addr_cmp(netmask, netif_ip4_netmask(netif)) == 0) { if (ip4_addr_eq(netmask, netif_ip4_netmask(netif)) == 0) {
#if LWIP_NETIF_EXT_STATUS_CALLBACK #if LWIP_NETIF_EXT_STATUS_CALLBACK
LWIP_ASSERT("invalid pointer", old_nm != NULL); LWIP_ASSERT("invalid pointer", old_nm != NULL);
ip_addr_copy(*old_nm, *netif_ip_netmask4(netif)); ip_addr_copy(*old_nm, *netif_ip_netmask4(netif));
@ -608,7 +608,7 @@ static int
netif_do_set_gw(struct netif *netif, const ip4_addr_t *gw, ip_addr_t *old_gw) netif_do_set_gw(struct netif *netif, const ip4_addr_t *gw, ip_addr_t *old_gw)
{ {
/* address is actually being changed? */ /* address is actually being changed? */
if (ip4_addr_cmp(gw, netif_ip4_gw(netif)) == 0) { if (ip4_addr_eq(gw, netif_ip4_gw(netif)) == 0) {
#if LWIP_NETIF_EXT_STATUS_CALLBACK #if LWIP_NETIF_EXT_STATUS_CALLBACK
LWIP_ASSERT("invalid pointer", old_gw != NULL); LWIP_ASSERT("invalid pointer", old_gw != NULL);
ip_addr_copy(*old_gw, *netif_ip_gw4(netif)); ip_addr_copy(*old_gw, *netif_ip_gw4(netif));
@ -1532,7 +1532,7 @@ netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr)
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) && if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp_zoneless(netif_ip6_addr(netif, i), ip6addr)) { ip6_addr_zoneless_eq(netif_ip6_addr(netif, i), ip6addr)) {
return i; return i;
} }
} }
@ -1588,7 +1588,7 @@ netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
/* Set a link-local zone. Even though the zone is implied by the owning /* Set a link-local zone. Even though the zone is implied by the owning
* netif, setting the zone anyway has two important conceptual advantages: * netif, setting the zone anyway has two important conceptual advantages:
* 1) it avoids the need for a ton of exceptions in internal code, allowing * 1) it avoids the need for a ton of exceptions in internal code, allowing
* e.g. ip6_addr_cmp() to be used on local addresses; * e.g. ip6_addr_eq() to be used on local addresses;
* 2) the properly zoned address is visible externally, e.g. when any outside * 2) the properly zoned address is visible externally, e.g. when any outside
* code enumerates available addresses or uses one to bind a socket. * code enumerates available addresses or uses one to bind a socket.
* Any external code unaware of address scoping is likely to just ignore the * Any external code unaware of address scoping is likely to just ignore the

View File

@ -106,7 +106,7 @@ raw_input_local_match(struct raw_pcb *pcb, u8_t broadcast)
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */
/* Handle IPv4 and IPv6: catch all or exact match */ /* Handle IPv4 and IPv6: catch all or exact match */
if (ip_addr_isany(&pcb->local_ip) || if (ip_addr_isany(&pcb->local_ip) ||
ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) { ip_addr_eq(&pcb->local_ip, ip_current_dest_addr())) {
return 1; return 1;
} }
} }
@ -166,7 +166,7 @@ raw_input(struct pbuf *p, struct netif *inp)
while (pcb != NULL) { while (pcb != NULL) {
if ((pcb->protocol == proto) && raw_input_local_match(pcb, broadcast) && if ((pcb->protocol == proto) && raw_input_local_match(pcb, broadcast) &&
(((pcb->flags & RAW_FLAGS_CONNECTED) == 0) || (((pcb->flags & RAW_FLAGS_CONNECTED) == 0) ||
ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) { ip_addr_eq(&pcb->remote_ip, ip_current_src_addr()))) {
/* receive callback function available? */ /* receive callback function available? */
if (pcb->recv != NULL) { if (pcb->recv != NULL) {
u8_t eaten; u8_t eaten;
@ -659,7 +659,7 @@ void raw_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_a
if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) { if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
for (rpcb = raw_pcbs; rpcb != NULL; rpcb = rpcb->next) { for (rpcb = raw_pcbs; rpcb != NULL; rpcb = rpcb->next) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if (ip_addr_cmp(&rpcb->local_ip, old_addr)) { if (ip_addr_eq(&rpcb->local_ip, old_addr)) {
/* The PCB is bound to the old ipaddr and /* The PCB is bound to the old ipaddr and
* is set to bound to the new one instead */ * is set to bound to the new one instead */
ip_addr_copy(rpcb->local_ip, *new_addr); ip_addr_copy(rpcb->local_ip, *new_addr);

View File

@ -728,7 +728,7 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
if ((IP_IS_V6(ipaddr) == IP_IS_V6_VAL(cpcb->local_ip)) && if ((IP_IS_V6(ipaddr) == IP_IS_V6_VAL(cpcb->local_ip)) &&
(ip_addr_isany(&cpcb->local_ip) || (ip_addr_isany(&cpcb->local_ip) ||
ip_addr_isany(ipaddr) || ip_addr_isany(ipaddr) ||
ip_addr_cmp(&cpcb->local_ip, ipaddr))) { ip_addr_eq(&cpcb->local_ip, ipaddr))) {
return ERR_USE; return ERR_USE;
} }
} }
@ -871,7 +871,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
this port is only used once for every local IP. */ this port is only used once for every local IP. */
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
if ((lpcb->local_port == pcb->local_port) && if ((lpcb->local_port == pcb->local_port) &&
ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) { ip_addr_eq(&lpcb->local_ip, &pcb->local_ip)) {
/* this address/port is already used */ /* this address/port is already used */
lpcb = NULL; lpcb = NULL;
res = ERR_USE; res = ERR_USE;
@ -1134,8 +1134,8 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
for (cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { for (cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) {
if ((cpcb->local_port == pcb->local_port) && if ((cpcb->local_port == pcb->local_port) &&
(cpcb->remote_port == port) && (cpcb->remote_port == port) &&
ip_addr_cmp(&cpcb->local_ip, &pcb->local_ip) && ip_addr_eq(&cpcb->local_ip, &pcb->local_ip) &&
ip_addr_cmp(&cpcb->remote_ip, ipaddr)) { ip_addr_eq(&cpcb->remote_ip, ipaddr)) {
/* linux returns EISCONN here, but ERR_USE should be OK for us */ /* linux returns EISCONN here, but ERR_USE should be OK for us */
return ERR_USE; return ERR_USE;
} }
@ -2312,7 +2312,7 @@ tcp_netif_ip_addr_changed_pcblist(const ip_addr_t *old_addr, struct tcp_pcb *pcb
while (pcb != NULL) { while (pcb != NULL) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if (ip_addr_cmp(&pcb->local_ip, old_addr) if (ip_addr_eq(&pcb->local_ip, old_addr)
#if LWIP_AUTOIP #if LWIP_AUTOIP
/* connections to link-local addresses must persist (RFC3927 ch. 1.9) */ /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */
&& (!IP_IS_V4_VAL(pcb->local_ip) || !ip4_addr_islinklocal(ip_2_ip4(&pcb->local_ip))) && (!IP_IS_V4_VAL(pcb->local_ip) || !ip4_addr_islinklocal(ip_2_ip4(&pcb->local_ip)))
@ -2347,7 +2347,7 @@ tcp_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if (ip_addr_cmp(&lpcb->local_ip, old_addr)) { if (ip_addr_eq(&lpcb->local_ip, old_addr)) {
/* The PCB is listening to the old ipaddr and /* The PCB is listening to the old ipaddr and
* is set to listen to the new one instead */ * is set to listen to the new one instead */
ip_addr_copy(lpcb->local_ip, *new_addr); ip_addr_copy(lpcb->local_ip, *new_addr);

View File

@ -261,8 +261,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
if (pcb->remote_port == tcphdr->src && if (pcb->remote_port == tcphdr->src &&
pcb->local_port == tcphdr->dest && pcb->local_port == tcphdr->dest &&
ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()) && ip_addr_eq(&pcb->remote_ip, ip_current_src_addr()) &&
ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) { ip_addr_eq(&pcb->local_ip, ip_current_dest_addr())) {
/* Move this PCB to the front of the list so that subsequent /* Move this PCB to the front of the list so that subsequent
lookups will be faster (we exploit locality in TCP segment lookups will be faster (we exploit locality in TCP segment
arrivals). */ arrivals). */
@ -294,8 +294,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
if (pcb->remote_port == tcphdr->src && if (pcb->remote_port == tcphdr->src &&
pcb->local_port == tcphdr->dest && pcb->local_port == tcphdr->dest &&
ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()) && ip_addr_eq(&pcb->remote_ip, ip_current_src_addr()) &&
ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) { ip_addr_eq(&pcb->local_ip, ip_current_dest_addr())) {
/* We don't really care enough to move this PCB to the front /* We don't really care enough to move this PCB to the front
of the list since we are not very likely to receive that of the list since we are not very likely to receive that
many segments for connections in TIME-WAIT. */ many segments for connections in TIME-WAIT. */
@ -333,7 +333,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
break; break;
#endif /* SO_REUSE */ #endif /* SO_REUSE */
} else if (IP_ADDR_PCB_VERSION_MATCH_EXACT(lpcb, ip_current_dest_addr())) { } else if (IP_ADDR_PCB_VERSION_MATCH_EXACT(lpcb, ip_current_dest_addr())) {
if (ip_addr_cmp(&lpcb->local_ip, ip_current_dest_addr())) { if (ip_addr_eq(&lpcb->local_ip, ip_current_dest_addr())) {
/* found an exact match */ /* found an exact match */
break; break;
} else if (ip_addr_isany(&lpcb->local_ip)) { } else if (ip_addr_isany(&lpcb->local_ip)) {

View File

@ -163,14 +163,14 @@ udp_input_local_match(struct udp_pcb *pcb, struct netif *inp, u8_t broadcast)
{ {
if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) || if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) ||
((ip4_current_dest_addr()->addr == IPADDR_BROADCAST)) || ((ip4_current_dest_addr()->addr == IPADDR_BROADCAST)) ||
ip4_addr_netcmp(ip_2_ip4(&pcb->local_ip), ip4_current_dest_addr(), netif_ip4_netmask(inp))) { ip4_addr_net_eq(ip_2_ip4(&pcb->local_ip), ip4_current_dest_addr(), netif_ip4_netmask(inp))) {
return 1; return 1;
} }
} }
} else } else
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */
/* Handle IPv4 and IPv6: all or exact match */ /* Handle IPv4 and IPv6: all or exact match */
if (ip_addr_isany(&pcb->local_ip) || ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) { if (ip_addr_isany(&pcb->local_ip) || ip_addr_eq(&pcb->local_ip, ip_current_dest_addr())) {
return 1; return 1;
} }
} }
@ -268,9 +268,9 @@ udp_input(struct pbuf *p, struct netif *inp)
#if LWIP_IPV4 #if LWIP_IPV4
} else if (broadcast && ip4_current_dest_addr()->addr == IPADDR_BROADCAST) { } else if (broadcast && ip4_current_dest_addr()->addr == IPADDR_BROADCAST) {
/* global broadcast address (only valid for IPv4; match was checked before) */ /* global broadcast address (only valid for IPv4; match was checked before) */
if (!IP_IS_V4_VAL(uncon_pcb->local_ip) || !ip4_addr_cmp(ip_2_ip4(&uncon_pcb->local_ip), netif_ip4_addr(inp))) { if (!IP_IS_V4_VAL(uncon_pcb->local_ip) || !ip4_addr_eq(ip_2_ip4(&uncon_pcb->local_ip), netif_ip4_addr(inp))) {
/* uncon_pcb does not match the input netif, check this pcb */ /* uncon_pcb does not match the input netif, check this pcb */
if (IP_IS_V4_VAL(pcb->local_ip) && ip4_addr_cmp(ip_2_ip4(&pcb->local_ip), netif_ip4_addr(inp))) { if (IP_IS_V4_VAL(pcb->local_ip) && ip4_addr_eq(ip_2_ip4(&pcb->local_ip), netif_ip4_addr(inp))) {
/* better match */ /* better match */
uncon_pcb = pcb; uncon_pcb = pcb;
} }
@ -288,7 +288,7 @@ udp_input(struct pbuf *p, struct netif *inp)
/* compare PCB remote addr+port to UDP source addr+port */ /* compare PCB remote addr+port to UDP source addr+port */
if ((pcb->remote_port == src) && if ((pcb->remote_port == src) &&
(ip_addr_isany_val(pcb->remote_ip) || (ip_addr_isany_val(pcb->remote_ip) ||
ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) { ip_addr_eq(&pcb->remote_ip, ip_current_src_addr()))) {
/* the first fully matching PCB */ /* the first fully matching PCB */
if (prev != NULL) { if (prev != NULL) {
/* move the pcb to the front of udp_pcbs so that is /* move the pcb to the front of udp_pcbs so that is
@ -321,7 +321,7 @@ udp_input(struct pbuf *p, struct netif *inp)
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
#if LWIP_IPV4 #if LWIP_IPV4
if (!ip_current_is_v6()) { if (!ip_current_is_v6()) {
for_us = ip4_addr_cmp(netif_ip4_addr(inp), ip4_current_dest_addr()); for_us = ip4_addr_eq(netif_ip4_addr(inp), ip4_current_dest_addr());
} }
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */
} }
@ -570,7 +570,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
in pcb->mcast_ip4 that is used for routing. If this routing lookup in pcb->mcast_ip4 that is used for routing. If this routing lookup
fails, we try regular routing as though no override was set. */ fails, we try regular routing as though no override was set. */
if (!ip4_addr_isany_val(pcb->mcast_ip4) && if (!ip4_addr_isany_val(pcb->mcast_ip4) &&
!ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) { !ip4_addr_eq(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) {
netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4); netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4);
} }
} }
@ -678,7 +678,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_i
} 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 */
if (!ip4_addr_cmp(ip_2_ip4(&(pcb->local_ip)), netif_ip4_addr(netif))) { if (!ip4_addr_eq(ip_2_ip4(&(pcb->local_ip)), netif_ip4_addr(netif))) {
/* local_ip doesn't match, drop the packet */ /* local_ip doesn't match, drop the packet */
return ERR_RTE; return ERR_RTE;
} }
@ -999,7 +999,7 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
if ((ipcb->local_port == port) && if ((ipcb->local_port == port) &&
(((IP_GET_TYPE(&ipcb->local_ip) == IP_GET_TYPE(ipaddr)) && (((IP_GET_TYPE(&ipcb->local_ip) == IP_GET_TYPE(ipaddr)) &&
/* IP address matches or any IP used? */ /* IP address matches or any IP used? */
(ip_addr_cmp(&ipcb->local_ip, ipaddr) || (ip_addr_eq(&ipcb->local_ip, ipaddr) ||
ip_addr_isany(ipaddr) || ip_addr_isany(ipaddr) ||
ip_addr_isany(&ipcb->local_ip))) || ip_addr_isany(&ipcb->local_ip))) ||
(IP_GET_TYPE(&ipcb->local_ip) == IPADDR_TYPE_ANY) || (IP_GET_TYPE(&ipcb->local_ip) == IPADDR_TYPE_ANY) ||
@ -1288,7 +1288,7 @@ void udp_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_a
if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) { if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) { for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if (ip_addr_cmp(&upcb->local_ip, old_addr)) { if (ip_addr_eq(&upcb->local_ip, old_addr)) {
/* The PCB is bound to the old ipaddr and /* The PCB is bound to the old ipaddr and
* is set to bound to the new one instead */ * is set to bound to the new one instead */
ip_addr_copy(upcb->local_ip, *new_addr); ip_addr_copy(upcb->local_ip, *new_addr);

View File

@ -130,6 +130,11 @@ struct netif;
/** Get the network address by combining host address with netmask */ /** Get the network address by combining host address with netmask */
#define ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0) #define ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0)
/**
* Determine if two address are on the same network.
* @deprecated Renamed to @ref ip4_addr_net_eq
*/
#define ip4_addr_netcmp(addr1, addr2, mask) ip4_addr_net_eq(addr1, addr2, mask)
/** /**
* Determine if two address are on the same network. * Determine if two address are on the same network.
* *
@ -138,11 +143,15 @@ struct netif;
* @arg mask network identifier mask * @arg mask network identifier mask
* @return !0 if the network identifiers of both address match * @return !0 if the network identifiers of both address match
*/ */
#define ip4_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ #define ip4_addr_net_eq(addr1, addr2, mask) (((addr1)->addr & \
(mask)->addr) == \ (mask)->addr) == \
((addr2)->addr & \ ((addr2)->addr & \
(mask)->addr)) (mask)->addr))
#define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) /**
* @deprecated Renamed to @ref ip4_addr_eq
*/
#define ip4_addr_cmp(addr1, addr2) ip4_addr_eq(addr1, addr2)
#define ip4_addr_eq(addr1, addr2) ((addr1)->addr == (addr2)->addr)
#define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY) #define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY)
#define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1))) #define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1)))

View File

@ -146,10 +146,17 @@ typedef struct ip6_addr ip6_addr_t;
ip6_addr_set_zone((dest), (src) == NULL ? IP6_NO_ZONE : ip6_addr_zone(src));}while(0) ip6_addr_set_zone((dest), (src) == NULL ? IP6_NO_ZONE : ip6_addr_zone(src));}while(0)
/** @deprecated Renamed to @ref ip6_addr_net_zoneless_eq */
#define ip6_addr_netcmp_zoneless(addr1, addr2) ip6_addr_net_zoneless_eq(addr1, addr2)
/** Compare IPv6 networks, ignoring zone information. To be used sparingly! */ /** Compare IPv6 networks, ignoring zone information. To be used sparingly! */
#define ip6_addr_netcmp_zoneless(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ #define ip6_addr_net_zoneless_eq(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
((addr1)->addr[1] == (addr2)->addr[1])) ((addr1)->addr[1] == (addr2)->addr[1]))
/**
* Determine if two IPv6 address are on the same network.
* @deprecated Renamed to @ref ip6_addr_net_eq
*/
#define ip6_addr_netcmp(addr1, addr2) ip6_addr_net_eq(addr1, addr2)
/** /**
* Determine if two IPv6 address are on the same network. * Determine if two IPv6 address are on the same network.
* *
@ -157,18 +164,23 @@ typedef struct ip6_addr ip6_addr_t;
* @param addr2 IPv6 address 2 * @param addr2 IPv6 address 2
* @return 1 if the network identifiers of both address match, 0 if not * @return 1 if the network identifiers of both address match, 0 if not
*/ */
#define ip6_addr_netcmp(addr1, addr2) (ip6_addr_netcmp_zoneless((addr1), (addr2)) && \ #define ip6_addr_net_eq(addr1, addr2) (ip6_addr_net_zoneless_eq((addr1), (addr2)) && \
ip6_addr_cmp_zone((addr1), (addr2))) ip6_addr_zone_eq((addr1), (addr2)))
/* Exact-host comparison *after* ip6_addr_netcmp() succeeded, for efficiency. */ #define ip6_addr_nethostcmp(addr1, addr2) ip6_addr_nethost_eq(addr1, addr2)
#define ip6_addr_nethostcmp(addr1, addr2) (((addr1)->addr[2] == (addr2)->addr[2]) && \ /* Exact-host comparison *after* ip6_addr_net_eq() succeeded, for efficiency. */
#define ip6_addr_nethost_eq(addr1, addr2) (((addr1)->addr[2] == (addr2)->addr[2]) && \
((addr1)->addr[3] == (addr2)->addr[3])) ((addr1)->addr[3] == (addr2)->addr[3]))
/** @deprecated Renamed to @ref ip6_addr_zoneless_eq */
#define ip6_addr_cmp_zoneless(addr1, addr2) ip6_addr_zoneless_eq(addr1, addr2)
/** Compare IPv6 addresses, ignoring zone information. To be used sparingly! */ /** Compare IPv6 addresses, ignoring zone information. To be used sparingly! */
#define ip6_addr_cmp_zoneless(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ #define ip6_addr_zoneless_eq(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
((addr1)->addr[1] == (addr2)->addr[1]) && \ ((addr1)->addr[1] == (addr2)->addr[1]) && \
((addr1)->addr[2] == (addr2)->addr[2]) && \ ((addr1)->addr[2] == (addr2)->addr[2]) && \
((addr1)->addr[3] == (addr2)->addr[3])) ((addr1)->addr[3] == (addr2)->addr[3]))
/** @deprecated Renamed to @ref ip6_addr_eq */
#define ip6_addr_cmp(addr1, addr2) ip6_addr_eq(addr1, addr2)
/** /**
* Determine if two IPv6 addresses are the same. In particular, the address * Determine if two IPv6 addresses are the same. In particular, the address
* part of both must be the same, and the zone must be compatible. * part of both must be the same, and the zone must be compatible.
@ -177,11 +189,13 @@ typedef struct ip6_addr ip6_addr_t;
* @param addr2 IPv6 address 2 * @param addr2 IPv6 address 2
* @return 1 if the addresses are considered equal, 0 if not * @return 1 if the addresses are considered equal, 0 if not
*/ */
#define ip6_addr_cmp(addr1, addr2) (ip6_addr_cmp_zoneless((addr1), (addr2)) && \ #define ip6_addr_eq(addr1, addr2) (ip6_addr_zoneless_eq((addr1), (addr2)) && \
ip6_addr_cmp_zone((addr1), (addr2))) ip6_addr_zone_eq((addr1), (addr2)))
/** @deprecated Renamed to @ref ip6_addr_packed_eq */
#define ip6_addr_cmp_packed(ip6addr, paddr, zone_idx) ip6_addr_packed_eq(ip6addr, paddr, zone_idx)
/** Compare IPv6 address to packed address and zone */ /** Compare IPv6 address to packed address and zone */
#define ip6_addr_cmp_packed(ip6addr, paddr, zone_idx) (((ip6addr)->addr[0] == (paddr)->addr[0]) && \ #define ip6_addr_packed_eq(ip6addr, paddr, zone_idx) (((ip6addr)->addr[0] == (paddr)->addr[0]) && \
((ip6addr)->addr[1] == (paddr)->addr[1]) && \ ((ip6addr)->addr[1] == (paddr)->addr[1]) && \
((ip6addr)->addr[2] == (paddr)->addr[2]) && \ ((ip6addr)->addr[2] == (paddr)->addr[2]) && \
((ip6addr)->addr[3] == (paddr)->addr[3]) && \ ((ip6addr)->addr[3] == (paddr)->addr[3]) && \
@ -279,7 +293,8 @@ typedef struct ip6_addr ip6_addr_t;
(ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id)); \ (ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id)); \
ip6_addr_clear_zone(ip6addr); }while(0) ip6_addr_clear_zone(ip6addr); }while(0)
#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ #define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) ip6_addr_solicitednode_eq(ip6addr, sn_addr)
#define ip6_addr_solicitednode_eq(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
((ip6addr)->addr[1] == 0) && \ ((ip6addr)->addr[1] == 0) && \
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3]))) ((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3])))

View File

@ -123,9 +123,11 @@ extern "C" {
/** Is the zone field of the given IPv6 address equal to the given zone index? (0/1) */ /** Is the zone field of the given IPv6 address equal to the given zone index? (0/1) */
#define ip6_addr_equals_zone(ip6addr, zone_idx) ((ip6addr)->zone == (zone_idx)) #define ip6_addr_equals_zone(ip6addr, zone_idx) ((ip6addr)->zone == (zone_idx))
/** @deprecated Renamed to @ref ip6_addr_zone_eq */
#define ip6_addr_cmp_zone(addr1, addr2) ip6_addr_zone_eq(ip6addr1, ip6addr2)
/** Are the zone fields of the given IPv6 addresses equal? (0/1) /** Are the zone fields of the given IPv6 addresses equal? (0/1)
* This macro must only be used on IPv6 addresses of the same scope. */ * This macro must only be used on IPv6 addresses of the same scope. */
#define ip6_addr_cmp_zone(ip6addr1, ip6addr2) ((ip6addr1)->zone == (ip6addr2)->zone) #define ip6_addr_zone_eq(ip6addr1, ip6addr2) ((ip6addr1)->zone == (ip6addr2)->zone)
/** Symbolic constants for the 'type' parameters in some of the macros. /** Symbolic constants for the 'type' parameters in some of the macros.
* These exist for efficiency only, allowing the macros to avoid certain tests * These exist for efficiency only, allowing the macros to avoid certain tests
@ -265,7 +267,7 @@ enum lwip_ipv6_scope_type
#define ip6_addr_clear_zone(ip6addr) #define ip6_addr_clear_zone(ip6addr)
#define ip6_addr_copy_zone(ip6addr1, ip6addr2) #define ip6_addr_copy_zone(ip6addr1, ip6addr2)
#define ip6_addr_equals_zone(ip6addr, zone_idx) (1) #define ip6_addr_equals_zone(ip6addr, zone_idx) (1)
#define ip6_addr_cmp_zone(ip6addr1, ip6addr2) (1) #define ip6_addr_zone_eq(ip6addr1, ip6addr2) (1)
#define IPV6_CUSTOM_SCOPES 0 #define IPV6_CUSTOM_SCOPES 0
#define ip6_addr_has_scope(ip6addr, type) (0) #define ip6_addr_has_scope(ip6addr, type) (0)
#define ip6_addr_assign_zone(ip6addr, type, netif) #define ip6_addr_assign_zone(ip6addr, type, netif)

View File

@ -194,18 +194,33 @@ extern const ip_addr_t ip_addr_any_type;
#define ip_addr_get_network(target, host, netmask) do{if(IP_IS_V6(host)){ \ #define ip_addr_get_network(target, host, netmask) do{if(IP_IS_V6(host)){ \
ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \ ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \
ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); IP_SET_TYPE(target, IPADDR_TYPE_V4); }}while(0) ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); IP_SET_TYPE(target, IPADDR_TYPE_V4); }}while(0)
/**
* @ingroup ipaddr
* @deprecated Renamed to @ref ip_addr_net_eq
*/
#define ip_addr_netcmp(addr1, addr2, mask) ip_addr_net_eq((addr1), (addr2), (mask))
/** @ingroup ipaddr */ /** @ingroup ipaddr */
#define ip_addr_netcmp(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \ #define ip_addr_net_eq(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \
0 : \ 0 : \
ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask)) ip4_addr_net_eq(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
/**
* @ingroup ipaddr
* @deprecated Renamed to @ref ip_addr_eq
*/
#define ip_addr_cmp(addr1, addr2) ip_addr_eq((addr1), (addr2))
/** @ingroup ipaddr */ /** @ingroup ipaddr */
#define ip_addr_cmp(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \ #define ip_addr_eq(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \ ip6_addr_eq(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2)))) ip4_addr_eq(ip_2_ip4(addr1), ip_2_ip4(addr2))))
/**
* @ingroup ipaddr
* @deprecated Renamed to @ref ip_addr_zoneless_eq
*/
#define ip_addr_cmp_zoneless(addr1, addr2) ip_addr_zoneless_eq((addr1), (addr2))
/** @ingroup ipaddr */ /** @ingroup ipaddr */
#define ip_addr_cmp_zoneless(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \ #define ip_addr_zoneless_eq(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
ip6_addr_cmp_zoneless(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \ ip6_addr_zoneless_eq(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2)))) ip4_addr_eq(ip_2_ip4(addr1), ip_2_ip4(addr2))))
/** @ingroup ipaddr */ /** @ingroup ipaddr */
#define ip_addr_isany(ipaddr) (((ipaddr) == NULL) ? 1 : ((IP_IS_V6(ipaddr)) ? \ #define ip_addr_isany(ipaddr) (((ipaddr) == NULL) ? 1 : ((IP_IS_V6(ipaddr)) ? \
ip6_addr_isany(ip_2_ip6(ipaddr)) : \ ip6_addr_isany(ip_2_ip6(ipaddr)) : \
@ -295,8 +310,10 @@ typedef ip4_addr_t ip_addr_t;
#define ip_addr_set_loopback(is_ipv6, ipaddr) ip4_addr_set_loopback(ipaddr) #define ip_addr_set_loopback(is_ipv6, ipaddr) ip4_addr_set_loopback(ipaddr)
#define ip_addr_set_hton(dest, src) ip4_addr_set_hton(dest, src) #define ip_addr_set_hton(dest, src) ip4_addr_set_hton(dest, src)
#define ip_addr_get_network(target, host, mask) ip4_addr_get_network(target, host, mask) #define ip_addr_get_network(target, host, mask) ip4_addr_get_network(target, host, mask)
#define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_netcmp(addr1, addr2, mask) #define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_net_eq(addr1, addr2, mask)
#define ip_addr_cmp(addr1, addr2) ip4_addr_cmp(addr1, addr2) #define ip_addr_net_eq(addr1, addr2, mask) ip4_addr_net_eq(addr1, addr2, mask)
#define ip_addr_cmp(addr1, addr2) ip4_addr_eq(addr1, addr2)
#define ip_addr_eq(addr1, addr2) ip4_addr_eq(addr1, addr2)
#define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr) #define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr)
#define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr) #define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr)
#define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr) #define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr)
@ -343,8 +360,11 @@ typedef ip6_addr_t ip_addr_t;
#define ip_addr_set_hton(dest, src) ip6_addr_set_hton(dest, src) #define ip_addr_set_hton(dest, src) ip6_addr_set_hton(dest, src)
#define ip_addr_get_network(target, host, mask) ip6_addr_set_zero(target) #define ip_addr_get_network(target, host, mask) ip6_addr_set_zero(target)
#define ip_addr_netcmp(addr1, addr2, mask) 0 #define ip_addr_netcmp(addr1, addr2, mask) 0
#define ip_addr_cmp(addr1, addr2) ip6_addr_cmp(addr1, addr2) #define ip_addr_net_eq(addr1, addr2, mask) 0
#define ip_addr_cmp_zoneless(addr1, addr2) ip6_addr_cmp_zoneless(addr1, addr2) #define ip_addr_cmp(addr1, addr2) ip6_addr_eq(addr1, addr2)
#define ip_addr_eq(addr1, addr2) ip6_addr_eq(addr1, addr2)
#define ip_addr_cmp_zoneless(addr1, addr2) ip6_addr_zoneless_eq(addr1, addr2)
#define ip_addr_zoneless_eq(addr1, addr2) ip6_addr_zoneless_eq(addr1, addr2)
#define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr) #define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr)
#define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr) #define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr)
#define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr) #define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr)

View File

@ -116,7 +116,9 @@ PACK_STRUCT_END
#define LL_IP6_MULTICAST_ADDR_0 0x33 #define LL_IP6_MULTICAST_ADDR_0 0x33
#define LL_IP6_MULTICAST_ADDR_1 0x33 #define LL_IP6_MULTICAST_ADDR_1 0x33
#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0) /* eth_addr_cmp is deprecated, use eth_addr_eq */
#define eth_addr_cmp(addr1, addr2) eth_addr_eq((addr1), (addr2))
#define eth_addr_eq(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -610,7 +610,7 @@ lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr)
dest.addr_len = 2; dest.addr_len = 2;
dest.addr[0] = ((u8_t *)q->payload)[38]; dest.addr[0] = ((u8_t *)q->payload)[38];
dest.addr[1] = ((u8_t *)q->payload)[39]; dest.addr[1] = ((u8_t *)q->payload)[39];
if ((src.addr_len == 2) && (ip6_addr_netcmp_zoneless(&ip6_hdr->src, &ip6_hdr->dest)) && if ((src.addr_len == 2) && (ip6_addr_net_zoneless_eq(&ip6_hdr->src, &ip6_hdr->dest)) &&
(lowpan6_get_address_mode(ip6addr, &dest) == 3)) { (lowpan6_get_address_mode(ip6addr, &dest) == 3)) {
MIB2_STATS_NETIF_INC(netif, ifoutucastpkts); MIB2_STATS_NETIF_INC(netif, ifoutucastpkts);
return lowpan6_frag(netif, q, &src, &dest); return lowpan6_frag(netif, q, &src, &dest);

View File

@ -117,7 +117,7 @@ lowpan6_context_lookup(const ip6_addr_t *lowpan6_contexts, const ip6_addr_t *ip6
s8_t i; s8_t i;
for (i = 0; i < LWIP_6LOWPAN_NUM_CONTEXTS; i++) { for (i = 0; i < LWIP_6LOWPAN_NUM_CONTEXTS; i++) {
if (ip6_addr_netcmp(&lowpan6_contexts[i], ip6addr)) { if (ip6_addr_net_eq(&lowpan6_contexts[i], ip6addr)) {
return i; return i;
} }
} }

View File

@ -1128,12 +1128,12 @@ int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) {
nsa = dns_getserver(0); nsa = dns_getserver(0);
ip_addr_set_ip4_u32_val(nsb, ns1); ip_addr_set_ip4_u32_val(nsb, ns1);
if (ip_addr_cmp(nsa, &nsb)) { if (ip_addr_eq(nsa, &nsb)) {
dns_setserver(0, IP_ADDR_ANY); dns_setserver(0, IP_ADDR_ANY);
} }
nsa = dns_getserver(1); nsa = dns_getserver(1);
ip_addr_set_ip4_u32_val(nsb, ns2); ip_addr_set_ip4_u32_val(nsb, ns2);
if (ip_addr_cmp(nsa, &nsb)) { if (ip_addr_eq(nsa, &nsb)) {
dns_setserver(1, IP_ADDR_ANY); dns_setserver(1, IP_ADDR_ANY);
} }
return 1; return 1;

View File

@ -353,7 +353,7 @@ static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, const
goto free_and_return; goto free_and_return;
} }
if (!ip_addr_cmp(&l2tp->remote_ip, addr)) { if (!ip_addr_eq(&l2tp->remote_ip, addr)) {
goto free_and_return; goto free_and_return;
} }

View File

@ -218,8 +218,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb)
* again & we don't have to do any reordering if it's used. * again & we don't have to do any reordering if it's used.
*/ */
INCR(vjs_packets); INCR(vjs_packets);
if (!ip4_addr_cmp(&ip->src, &cs->cs_ip.src) if (!ip4_addr_eq(&ip->src, &cs->cs_ip.src)
|| !ip4_addr_cmp(&ip->dest, &cs->cs_ip.dest) || !ip4_addr_eq(&ip->dest, &cs->cs_ip.dest)
|| (*(struct vj_u32_t*)th).v != (((struct vj_u32_t*)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]).v) { || (*(struct vj_u32_t*)th).v != (((struct vj_u32_t*)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]).v) {
/* /*
* Wasn't the first -- search for it. * Wasn't the first -- search for it.
@ -239,8 +239,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb)
do { do {
lcs = cs; cs = cs->cs_next; lcs = cs; cs = cs->cs_next;
INCR(vjs_searches); INCR(vjs_searches);
if (ip4_addr_cmp(&ip->src, &cs->cs_ip.src) if (ip4_addr_eq(&ip->src, &cs->cs_ip.src)
&& ip4_addr_cmp(&ip->dest, &cs->cs_ip.dest) && ip4_addr_eq(&ip->dest, &cs->cs_ip.dest)
&& (*(struct vj_u32_t*)th).v == (((struct vj_u32_t*)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]).v) { && (*(struct vj_u32_t*)th).v == (((struct vj_u32_t*)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]).v) {
goto found; goto found;
} }

View File

@ -32,8 +32,7 @@ START_TEST(test_dns_set_get_server)
dns_setserver(i, &server); dns_setserver(i, &server);
fail_unless(dns_getserver(i)); fail_unless(dns_getserver(i));
if (i < DNS_MAX_SERVERS) { if (i < DNS_MAX_SERVERS) {
/* ip_addr_cmp returns 1 if they match. */ fail_unless(ip_addr_eq(dns_getserver(i), &server) == 1);
fail_unless(ip_addr_cmp(dns_getserver(i), &server) == 1);
} else { } else {
fail_unless(ip_addr_isany(dns_getserver(i))); fail_unless(ip_addr_isany(dns_getserver(i)));
} }

View File

@ -340,8 +340,8 @@ START_TEST(test_ip6_dest_unreachable_chained_pbuf)
fail_unless(cloned_pbuf); fail_unless(cloned_pbuf);
fail_unless(cloned_pbuf->len == IP6_HLEN + ICMP6_HLEN + sizeof(udp_hdr) + sizeof(udp_payload)); fail_unless(cloned_pbuf->len == IP6_HLEN + ICMP6_HLEN + sizeof(udp_hdr) + sizeof(udp_payload));
outhdr = (struct ip6_hdr*) cloned_pbuf->payload; outhdr = (struct ip6_hdr*) cloned_pbuf->payload;
fail_unless(ip6_addr_cmp_packed(ip_2_ip6(&my_addr), &outhdr->src, IP6_NO_ZONE)); fail_unless(ip6_addr_packed_eq(ip_2_ip6(&my_addr), &outhdr->src, IP6_NO_ZONE));
fail_unless(ip6_addr_cmp_packed(ip_2_ip6(&peer_addr), &outhdr->dest, IP6_NO_ZONE)); fail_unless(ip6_addr_packed_eq(ip_2_ip6(&peer_addr), &outhdr->dest, IP6_NO_ZONE));
icmpptr = &((u8_t*)cloned_pbuf->payload)[IP6_HLEN]; icmpptr = &((u8_t*)cloned_pbuf->payload)[IP6_HLEN];
icmp6hdr = (struct icmp6_hdr*) icmpptr; icmp6hdr = (struct icmp6_hdr*) icmpptr;
fail_unless(icmp6hdr->type == ICMP6_TYPE_DUR); fail_unless(icmp6hdr->type == ICMP6_TYPE_DUR);