Networking: Get rid of g_ipv4_allzeroaddr and g_ipv4_alloneaddr. It is more efficient and more intuitive to use INADDR_ANY and INADDR_BROADCAST

This commit is contained in:
Gregory Nutt
2015-05-29 15:16:11 -06:00
parent 34509a9ad5
commit ab50e9d04d
10 changed files with 31 additions and 34 deletions
+2 -10
View File
@@ -69,19 +69,11 @@ struct net_stats_s g_netstats;
uint16_t g_ipid;
#ifdef CONFIG_NET_IPv4
const in_addr_t g_ipv4_alloneaddr = 0xffffffff;
const in_addr_t g_ipv4_allzeroaddr = 0x00000000;
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_TCP_REASSEMBLY)
/* Reassembly timer (units: deci-seconds) */
#ifdef CONFIG_NET_TCP_REASSEMBLY
uint8_t g_reassembly_timer;
#endif /* CONFIG_NET_TCP_REASSEMBLY */
#endif /* CONFIG_NET_IPv4 */
#endif
#ifdef CONFIG_NET_IPv6
+7 -6
View File
@@ -85,6 +85,7 @@
#include <debug.h>
#include <string.h>
#include <netinet/in.h>
#include <net/if.h>
#include <nuttx/net/netconfig.h>
@@ -377,16 +378,16 @@ int ipv4_input(FAR struct net_driver_s *dev)
#endif /* CONFIG_NET_TCP_REASSEMBLY */
}
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
/* If IP broadcast support is configured, we check for a broadcast
* UDP packet, which may be destined to us (even if there is no IP
* address yet assigned to the device as is the case when we are
* negotiating over DHCP for an address).
*/
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
if (pbuf->proto == IP_PROTO_UDP &&
net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr),
g_ipv4_alloneaddr))
INADDR_BROADCAST))
{
return udp_ipv4_input(dev);
}
@@ -399,14 +400,14 @@ int ipv4_input(FAR struct net_driver_s *dev)
else
#endif
#ifdef CONFIG_NET_ICMP
if (net_ipv4addr_cmp(dev->d_ipaddr, g_ipv4_allzeroaddr))
if (net_ipv4addr_cmp(dev->d_ipaddr, INADDR_ANY))
{
#ifdef CONFIG_NET_PINGADDRCONF
/* If we are configured to use ping IP address configuration and
* hasn't been assigned an IP address yet, we accept all ICMP
* packets.
*/
#ifdef CONFIG_NET_PINGADDRCONF
if (pbuf->proto == IP_PROTO_ICMP)
{
nlldbg("Possible ping config packet received\n");
@@ -476,17 +477,17 @@ int ipv4_input(FAR struct net_driver_s *dev)
break;
#endif
#ifdef CONFIG_NET_ICMP
/* Check for ICMP input */
#ifdef CONFIG_NET_ICMP
case IP_PROTO_ICMP: /* ICMP input */
icmp_input(dev);
break;
#endif
#ifdef CONFIG_NET_IGMP
/* Check for IGMP input */
#ifdef CONFIG_NET_IGMP
case IP_PROTO_IGMP: /* IGMP input */
igmp_input(dev);
break;