From 633696c1532374c624eb475111e02743e7af2cd1 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 28 Sep 2016 12:56:39 +0200 Subject: [PATCH] Implement consistent IPx_ADDR_ANYx macro naming between IPv4 and IPv6 - rename IP4_ADDR_ANY to IP4_ADDR_ANY4 - IP4_ADDR_ANY (= IP_ADDR_ANY) is now IPv4 any address in ip_addr_t format --- src/api/api_lib.c | 12 ++++++------ src/api/netifapi.c | 12 ++++++------ src/apps/lwiperf/lwiperf.c | 2 +- src/apps/mdns/mdns.c | 4 ++-- src/apps/snmp/snmp_core.c | 2 +- src/apps/snmp/snmp_mib2_ip.c | 6 +++--- src/apps/snmp/snmp_mib2_tcp.c | 6 +++--- src/apps/snmp/snmp_netconn.c | 2 +- src/apps/snmp/snmp_raw.c | 2 +- src/apps/sntp/sntp.c | 2 +- src/core/dns.c | 4 ++-- src/core/ipv4/autoip.c | 4 ++-- src/core/ipv4/dhcp.c | 14 +++++++------- src/core/ipv4/igmp.c | 4 ++-- src/core/ipv4/ip4.c | 8 ++++---- src/core/ipv4/ip4_addr.c | 2 +- src/core/netif.c | 2 +- src/core/raw.c | 2 +- src/core/tcp.c | 4 ++-- src/core/udp.c | 4 ++-- src/include/lwip/ip_addr.h | 22 ++++++++++++++-------- src/netif/ppp/ppp.c | 8 ++++---- src/netif/ppp/pppol2tp.c | 2 +- 23 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 740fe396..e129473d 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -241,8 +241,8 @@ netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) * Binding one netconn twice might not always be checked correctly! * * @param conn the netconn to bind - * @param addr the local IP address to bind the netconn to (use IP_ADDR_ANY - * to bind to all addresses) + * @param addr the local IP address to bind the netconn to + * (use IP4_ADDR_ANY/IP6_ADDR_ANY to bind to all addresses) * @param port the local port to bind the netconn to (not used for RAW) * @return ERR_OK if bound, any other err_t on failure */ @@ -256,7 +256,7 @@ netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port) /* Don't propagate NULL pointer (IP_ADDR_ANY alias) to subsequent functions */ if (addr == NULL) { - addr = IP_ADDR_ANY; + addr = IP4_ADDR_ANY; } API_MSG_VAR_ALLOC(msg); @@ -288,7 +288,7 @@ netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port) /* Don't propagate NULL pointer (IP_ADDR_ANY alias) to subsequent functions */ if (addr == NULL) { - addr = IP_ADDR_ANY; + addr = IP4_ADDR_ANY; } API_MSG_VAR_ALLOC(msg); @@ -867,10 +867,10 @@ netconn_join_leave_group(struct netconn *conn, /* Don't propagate NULL pointer (IP_ADDR_ANY alias) to subsequent functions */ if (multiaddr == NULL) { - multiaddr = IP_ADDR_ANY; + multiaddr = IP4_ADDR_ANY; } if (netif_addr == NULL) { - netif_addr = IP_ADDR_ANY; + netif_addr = IP4_ADDR_ANY; } API_MSG_VAR_REF(msg).conn = conn; diff --git a/src/api/netifapi.c b/src/api/netifapi.c index 265b60c5..6f7e55bf 100644 --- a/src/api/netifapi.c +++ b/src/api/netifapi.c @@ -134,13 +134,13 @@ netifapi_netif_add(struct netif *netif, #if LWIP_IPV4 if (ipaddr == NULL) { - ipaddr = IP4_ADDR_ANY; + ipaddr = IP4_ADDR_ANY4; } if (netmask == NULL) { - netmask = IP4_ADDR_ANY; + netmask = IP4_ADDR_ANY4; } if (gw == NULL) { - gw = IP4_ADDR_ANY; + gw = IP4_ADDR_ANY4; } #endif /* LWIP_IPV4 */ @@ -177,13 +177,13 @@ netifapi_netif_set_addr(struct netif *netif, NETIFAPI_VAR_ALLOC(msg); if (ipaddr == NULL) { - ipaddr = IP4_ADDR_ANY; + ipaddr = IP4_ADDR_ANY4; } if (netmask == NULL) { - netmask = IP4_ADDR_ANY; + netmask = IP4_ADDR_ANY4; } if (gw == NULL) { - gw = IP4_ADDR_ANY; + gw = IP4_ADDR_ANY4; } NETIFAPI_VAR_REF(msg).netif = netif; diff --git a/src/apps/lwiperf/lwiperf.c b/src/apps/lwiperf/lwiperf.c index fea2c06f..255e282a 100644 --- a/src/apps/lwiperf/lwiperf.c +++ b/src/apps/lwiperf/lwiperf.c @@ -579,7 +579,7 @@ lwiperf_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err) void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg) { - return lwiperf_start_tcp_server(IP_ADDR_ANY, LWIPERF_TCP_PORT_DEFAULT, + return lwiperf_start_tcp_server(IP4_ADDR_ANY, LWIPERF_TCP_PORT_DEFAULT, report_fn, report_arg); } diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 5da37bcf..662ccd31 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -1892,7 +1892,7 @@ mdns_resp_netif_settings_changed(struct netif *netif) mdns_announce(netif, IP6_ADDR_ANY); #endif #if LWIP_IPV4 - mdns_announce(netif, IP_ADDR_ANY); + mdns_announce(netif, IP4_ADDR_ANY); #endif } @@ -2044,7 +2044,7 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service mdns_announce(netif, IP6_ADDR_ANY); #endif #if LWIP_IPV4 - mdns_announce(netif, IP_ADDR_ANY); + mdns_announce(netif, IP4_ADDR_ANY); #endif return ERR_OK; diff --git a/src/apps/snmp/snmp_core.c b/src/apps/snmp/snmp_core.c index 1230d62b..a9213727 100644 --- a/src/apps/snmp/snmp_core.c +++ b/src/apps/snmp/snmp_core.c @@ -270,7 +270,7 @@ snmp_oid_to_ip4(const u32_t *oid, ip4_addr_t *ip) (oid[1] > 0xFF) || (oid[2] > 0xFF) || (oid[3] > 0xFF)) { - ip4_addr_copy(*ip, *IP4_ADDR_ANY); + ip4_addr_copy(*ip, *IP4_ADDR_ANY4); return 0; } diff --git a/src/apps/snmp/snmp_mib2_ip.c b/src/apps/snmp/snmp_mib2_ip.c index b14a5565..b28e162f 100644 --- a/src/apps/snmp/snmp_mib2_ip.c +++ b/src/apps/snmp/snmp_mib2_ip.c @@ -326,7 +326,7 @@ ip_RouteTable_get_cell_value_core(struct netif *netif, u8_t default_route, const case 1: /* ipRouteDest */ if (default_route) { /* default rte has 0.0.0.0 dest */ - value->u32 = IP4_ADDR_ANY->addr; + value->u32 = IP4_ADDR_ANY4->addr; } else { /* netifs have netaddress dest */ ip4_addr_t tmp; @@ -378,7 +378,7 @@ ip_RouteTable_get_cell_value_core(struct netif *netif, u8_t default_route, const case 11: /* ipRouteMask */ if (default_route) { /* default rte use 0.0.0.0 mask */ - value->u32 = IP4_ADDR_ANY->addr; + value->u32 = IP4_ADDR_ANY4->addr; } else { /* other rtes use netmask */ value->u32 = netif_ip4_netmask(netif)->addr; @@ -449,7 +449,7 @@ ip_RouteTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_ /* check default route */ if (netif_default != NULL) { - snmp_ip4_to_oid(IP4_ADDR_ANY, &test_oid[0]); + snmp_ip4_to_oid(IP4_ADDR_ANY4, &test_oid[0]); snmp_next_oid_check(&state, test_oid, LWIP_ARRAYSIZE(ip_RouteTable_oid_ranges), netif_default); } diff --git a/src/apps/snmp/snmp_mib2_tcp.c b/src/apps/snmp/snmp_mib2_tcp.c index f72e6a51..21f69656 100644 --- a/src/apps/snmp/snmp_mib2_tcp.c +++ b/src/apps/snmp/snmp_mib2_tcp.c @@ -172,7 +172,7 @@ tcp_ConnTable_get_cell_value_core(struct tcp_pcb *pcb, const u32_t* column, unio break; case 4: /* tcpConnRemAddress */ if (pcb->state == LISTEN) { - value->u32 = IP4_ADDR_ANY->addr; + value->u32 = IP4_ADDR_ANY4->addr; } else { value->u32 = ip_2_ip4(&pcb->remote_ip)->addr; } @@ -224,7 +224,7 @@ tcp_ConnTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */ if (pcb->state == LISTEN) { - if (ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY) && (remote_port == 0)) { + if (ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY4) && (remote_port == 0)) { /* fill in object properties */ return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len); } @@ -268,7 +268,7 @@ tcp_ConnTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_ /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */ if (pcb->state == LISTEN) { - snmp_ip4_to_oid(IP4_ADDR_ANY, &test_oid[5]); + snmp_ip4_to_oid(IP4_ADDR_ANY4, &test_oid[5]); test_oid[9] = 0; } else { if (IP_IS_V6_VAL(pcb->remote_ip)) { /* should never happen */ diff --git a/src/apps/snmp/snmp_netconn.c b/src/apps/snmp/snmp_netconn.c index 7eead2e6..070b41c3 100644 --- a/src/apps/snmp/snmp_netconn.c +++ b/src/apps/snmp/snmp_netconn.c @@ -57,7 +57,7 @@ snmp_netconn_thread(void *arg) netconn_bind(conn, IP6_ADDR_ANY, SNMP_IN_PORT); #else /* LWIP_IPV6 */ conn = netconn_new(NETCONN_UDP); - netconn_bind(conn, IP_ADDR_ANY, SNMP_IN_PORT); + netconn_bind(conn, IP4_ADDR_ANY, SNMP_IN_PORT); #endif /* LWIP_IPV6 */ LWIP_ERROR("snmp_netconn: invalid conn", (conn != NULL), return;); diff --git a/src/apps/snmp/snmp_raw.c b/src/apps/snmp/snmp_raw.c index 8cfe77a6..4a40864f 100644 --- a/src/apps/snmp/snmp_raw.c +++ b/src/apps/snmp/snmp_raw.c @@ -80,7 +80,7 @@ snmp_get_local_ip_for_dst(void* handle, const ip_addr_t *dst, ip_addr_t *result) /** * @ingroup snmp_core * Starts SNMP Agent. - * Allocates UDP pcb and binds it to IP_ADDR_ANY port 161. + * Allocates UDP pcb and binds it to IP_ANY_TYPE port 161. */ void snmp_init(void) diff --git a/src/apps/sntp/sntp.c b/src/apps/sntp/sntp.c index 8d43eb0b..9f8a1dc8 100644 --- a/src/apps/sntp/sntp.c +++ b/src/apps/sntp/sntp.c @@ -688,7 +688,7 @@ sntp_getserver(u8_t idx) if (idx < SNTP_MAX_SERVERS) { return &sntp_servers[idx].addr; } - return IP_ADDR_ANY; + return IP4_ADDR_ANY; } #if SNTP_SERVER_DNS diff --git a/src/core/dns.c b/src/core/dns.c index b19f9b08..e643aa30 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -362,7 +362,7 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver) if (dnsserver != NULL) { dns_servers[numdns] = (*dnsserver); } else { - dns_servers[numdns] = *IP_ADDR_ANY; + dns_servers[numdns] = *IP4_ADDR_ANY; } } } @@ -381,7 +381,7 @@ dns_getserver(u8_t numdns) if (numdns < DNS_MAX_SERVERS) { return &dns_servers[numdns]; } else { - return IP_ADDR_ANY; + return IP4_ADDR_ANY; } } diff --git a/src/core/ipv4/autoip.c b/src/core/ipv4/autoip.c index 01fccf8a..ad494feb 100644 --- a/src/core/ipv4/autoip.c +++ b/src/core/ipv4/autoip.c @@ -264,7 +264,7 @@ autoip_start(struct netif *netif) /* Set IP-Address, Netmask and Gateway to 0 to make sure that * ARP Packets are formed correctly */ - netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY); + netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], @@ -355,7 +355,7 @@ autoip_stop(struct netif *netif) if (autoip != NULL) { autoip->state = AUTOIP_STATE_OFF; if (ip4_addr_islinklocal(netif_ip4_addr(netif))) { - netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY); + netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); } } return ERR_OK; diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index 4ffd86b0..62a32c52 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -212,8 +212,8 @@ dhcp_inc_pcb_refcount(void) ip_set_option(dhcp_pcb, SOF_BROADCAST); /* set up local and remote port for the pcb -> listen on all interfaces on all src/dest IPs */ - udp_bind(dhcp_pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); - udp_connect(dhcp_pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); + udp_bind(dhcp_pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT); + udp_connect(dhcp_pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT); udp_recv(dhcp_pcb, dhcp_recv, NULL); } @@ -258,7 +258,7 @@ dhcp_handle_nak(struct netif *netif) to ensure the callback can use dhcp_supplied_address() */ dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF); /* remove IP address from interface (must no longer be used, as per RFC2131) */ - netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY); + netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); /* We can immediately restart discovery */ dhcp_discover(netif); } @@ -372,7 +372,7 @@ dhcp_select(struct netif *netif) pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); /* send broadcast to any DHCP server */ - udp_sendto_if_src(dhcp_pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP_ADDR_ANY); + udp_sendto_if_src(dhcp_pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP4_ADDR_ANY); dhcp_delete_msg(dhcp); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_select: REQUESTING\n")); } else { @@ -920,7 +920,7 @@ dhcp_decline(struct netif *netif) pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); /* per section 4.4.4, broadcast DECLINE messages */ - udp_sendto_if_src(dhcp_pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP_ADDR_ANY); + udp_sendto_if_src(dhcp_pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP4_ADDR_ANY); dhcp_delete_msg(dhcp); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_decline: BACKING OFF\n")); } else { @@ -971,7 +971,7 @@ dhcp_discover(struct netif *netif) pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)\n")); - udp_sendto_if_src(dhcp_pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP_ADDR_ANY); + udp_sendto_if_src(dhcp_pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP4_ADDR_ANY); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: deleting()ing\n")); dhcp_delete_msg(dhcp); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover: SELECTING\n")); @@ -1314,7 +1314,7 @@ dhcp_release(struct netif *netif) LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_release: could not allocate DHCP request\n")); } /* remove IP address from interface (prevents routing from selecting this interface) */ - netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY); + netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); return result; } diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index f3db5914..ab20b883 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -711,7 +711,7 @@ igmp_delaying_member(struct igmp_group *group, u8_t maxresp) * @param p the packet to send (p->payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * @param src the source IP address to send from (if src == IP4_ADDR_ANY, the * IP address of the netif used to send is used as source address) * @param dest the destination IP address to send the packet to * @param ttl the TTL value to be set in the IP header @@ -743,7 +743,7 @@ igmp_send(struct netif *netif, struct igmp_group *group, u8_t type) { struct pbuf* p = NULL; struct igmp_msg* igmp = NULL; - ip4_addr_t src = *IP4_ADDR_ANY; + ip4_addr_t src = *IP4_ADDR_ANY4; ip4_addr_t* dest = NULL; /* IP header + "router alert" option + IGMP header */ diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 27747ea7..1f1b3ac0 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -724,7 +724,7 @@ ip4_input(struct pbuf *p, struct netif *inp) * @param p the packet to send (p->payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * @param src the source IP address to send from (if src == IP4_ADDR_ANY, the * IP address of the netif used to send is used as source address) * @param dest the destination IP address to send the packet to * @param ttl the TTL value to be set in the IP header @@ -881,7 +881,7 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d ++ip_id; if (src == NULL) { - ip4_addr_copy(iphdr->src, *IP4_ADDR_ANY); + ip4_addr_copy(iphdr->src, *IP4_ADDR_ANY4); } else { /* src cannot be NULL here */ ip4_addr_copy(iphdr->src, *src); @@ -955,7 +955,7 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d * @param p the packet to send (p->payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * @param src the source IP address to send from (if src == IP4_ADDR_ANY, the * IP address of the netif used to send is used as source address) * @param dest the destination IP address to send the packet to * @param ttl the TTL value to be set in the IP header @@ -990,7 +990,7 @@ ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, * @param p the packet to send (p->payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * @param src the source IP address to send from (if src == IP4_ADDR_ANY, the * IP address of the netif used to send is used as source address) * @param dest the destination IP address to send the packet to * @param ttl the TTL value to be set in the IP header diff --git a/src/core/ipv4/ip4_addr.c b/src/core/ipv4/ip4_addr.c index 7fe35c98..d0a81072 100644 --- a/src/core/ipv4/ip4_addr.c +++ b/src/core/ipv4/ip4_addr.c @@ -43,7 +43,7 @@ #include "lwip/ip_addr.h" #include "lwip/netif.h" -/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ +/* used by IP4_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ const ip_addr_t ip_addr_any = IPADDR4_INIT(IPADDR_ANY); const ip_addr_t ip_addr_broadcast = IPADDR4_INIT(IPADDR_BROADCAST); diff --git a/src/core/netif.c b/src/core/netif.c index 2d7c8750..9adb50be 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -497,7 +497,7 @@ void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr) { ip_addr_t new_addr; - *ip_2_ip4(&new_addr) = (ipaddr ? *ipaddr : *IP4_ADDR_ANY); + *ip_2_ip4(&new_addr) = (ipaddr ? *ipaddr : *IP4_ADDR_ANY4); IP_SET_TYPE_VAL(new_addr, IPADDR_TYPE_V4); /* address is actually being changed? */ diff --git a/src/core/raw.c b/src/core/raw.c index 244ab40a..a9174542 100644 --- a/src/core/raw.c +++ b/src/core/raw.c @@ -196,7 +196,7 @@ raw_input(struct pbuf *p, struct netif *inp) * Bind a RAW PCB. * * @param pcb RAW PCB to be bound with a local address ipaddr. - * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to + * @param ipaddr local IP address to bind with. Use IP4_ADDR_ANY to * bind to all local interfaces. * * @return lwIP error code. diff --git a/src/core/tcp.c b/src/core/tcp.c index 9c31f4b8..a91c1f4e 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -529,7 +529,7 @@ tcp_abort(struct tcp_pcb *pcb) * * @param pcb the tcp_pcb to bind (no check is done whether this pcb is * already bound!) - * @param ipaddr the local ip address to bind to (use IP_ADDR_ANY to bind + * @param ipaddr the local ip address to bind to (use IP4_ADDR_ANY to bind * to any local address * @param port the local port to bind to * @return ERR_USE if the port is already in use @@ -546,7 +546,7 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) #if LWIP_IPV4 /* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */ if (ipaddr == NULL) { - ipaddr = IP_ADDR_ANY; + ipaddr = IP4_ADDR_ANY; } #endif /* LWIP_IPV4 */ diff --git a/src/core/udp.c b/src/core/udp.c index 34fbdd14..67b6c94b 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -883,7 +883,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d * Bind an UDP PCB. * * @param pcb UDP PCB to be bound with a local address ipaddr and port. - * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to + * @param ipaddr local IP address to bind with. Use IP4_ADDR_ANY to * bind to all local interfaces. * @param port local UDP port to bind with. Use 0 to automatically bind * to a random port between UDP_LOCAL_PORT_RANGE_START and @@ -907,7 +907,7 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) #if LWIP_IPV4 /* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */ if (ipaddr == NULL) { - ipaddr = IP_ADDR_ANY; + ipaddr = IP4_ADDR_ANY; } #endif /* LWIP_IPV4 */ diff --git a/src/include/lwip/ip_addr.h b/src/include/lwip/ip_addr.h index 864f12f9..c1df7464 100644 --- a/src/include/lwip/ip_addr.h +++ b/src/include/lwip/ip_addr.h @@ -313,19 +313,25 @@ extern const ip_addr_t ip_addr_any; extern const ip_addr_t ip_addr_broadcast; /** - * @ingroup ipaddr - * IP_ADDR_ can be used as a fixed/const ip_addr_t - * for the IPv4 wildcard and the broadcast address + * @ingroup ip4addr + * Provided for compatibility. Use IP4_ADDR_ANY for better readability. */ -#define IP_ADDR_ANY (&ip_addr_any) -/** @ingroup ipaddr */ -#define IP_ADDR_BROADCAST (&ip_addr_broadcast) +#define IP_ADDR_ANY IP4_ADDR_ANY /** * @ingroup ip4addr - * IP4_ADDR_ can be used as a fixed/const ip4_addr_t + * Can be used as a fixed/const ip_addr_t + * for the IPv4 wildcard and the broadcast address + */ +#define IP4_ADDR_ANY (&ip_addr_any) +/** + * @ingroup ip4addr + * Can be used as a fixed/const ip4_addr_t * for the wildcard and the broadcast address */ -#define IP4_ADDR_ANY (ip_2_ip4(&ip_addr_any)) +#define IP4_ADDR_ANY4 (ip_2_ip4(&ip_addr_any)) + +/** @ingroup ip4addr */ +#define IP_ADDR_BROADCAST (&ip_addr_broadcast) /** @ingroup ip4addr */ #define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast)) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 2f6ae11f..4bd17003 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -695,7 +695,7 @@ ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, vo MIB2_INIT_NETIF(pppif, snmp_ifType_ppp, 0); if (!netif_add(pcb->netif, #if LWIP_IPV4 - IP4_ADDR_ANY, IP4_ADDR_BROADCAST, IP4_ADDR_ANY, + IP4_ADDR_ANY4, IP4_ADDR_BROADCAST, IP4_ADDR_ANY4, #endif /* LWIP_IPV4 */ (void *)pcb, ppp_netif_init_cb, NULL)) { LWIP_MEMPOOL_FREE(PPP_PCB, pcb); @@ -1090,7 +1090,7 @@ int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr) { LWIP_UNUSED_ARG(our_adr); LWIP_UNUSED_ARG(his_adr); - netif_set_addr(pcb->netif, IP4_ADDR_ANY, IP4_ADDR_BROADCAST, IP4_ADDR_ANY); + netif_set_addr(pcb->netif, IP4_ADDR_ANY4, IP4_ADDR_BROADCAST, IP4_ADDR_ANY4); return 1; } @@ -1145,12 +1145,12 @@ int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) { nsa = dns_getserver(0); ip_addr_set_ip4_u32(&nsb, ns1); if (ip_addr_cmp(nsa, &nsb)) { - dns_setserver(0, IP_ADDR_ANY); + dns_setserver(0, IP4_ADDR_ANY); } nsa = dns_getserver(1); ip_addr_set_ip4_u32(&nsb, ns2); if (ip_addr_cmp(nsa, &nsb)) { - dns_setserver(1, IP_ADDR_ANY); + dns_setserver(1, IP4_ADDR_ANY); } return 1; } diff --git a/src/netif/ppp/pppol2tp.c b/src/netif/ppp/pppol2tp.c index 7ecbe9eb..c215cff6 100644 --- a/src/netif/ppp/pppol2tp.c +++ b/src/netif/ppp/pppol2tp.c @@ -303,7 +303,7 @@ static err_t pppol2tp_connect(ppp_pcb *ppp, void *ctx) { udp_bind(l2tp->udp, IP6_ADDR_ANY, 0); } else #endif /* LWIP_IPV6 */ - udp_bind(l2tp->udp, IP_ADDR_ANY, 0); + udp_bind(l2tp->udp, IP4_ADDR_ANY, 0); #if PPPOL2TP_AUTH_SUPPORT /* Generate random vector */