diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 53c2e407011..a18b628af76 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: December 17, 2014

+

Last Updated: January 24, 2014

@@ -694,7 +694,7 @@

-

  • TCP/IP, UDP, ICMP, IGMPv2 (client) stacks.
  • +
  • IPv4, IPv6, TCP/IP, UDP, ICMP, IGMPv2 (client) stacks.
  • diff --git a/include/net/if.h b/include/net/if.h index cd44f495b46..6970baae10d 100644 --- a/include/net/if.h +++ b/include/net/if.h @@ -65,24 +65,49 @@ #define IFF_SET_DOWN(f) do { (f) |= IFF_DOWN; } while (0) #define IFF_SET_UP(f) do { (f) |= IFF_UP; } while (0) #define IFF_SET_RUNNING(f) do { (f) |= IFF_RUNNING; } while (0) -#define IFF_SET_IPv6(f) do { (f) |= IFF_IPv6; } while (0) #define IFF_SET_NOARP(f) do { (f) |= IFF_NOARP; } while (0) #define IFF_CLR_DOWN(f) do { (f) &= ~IFF_DOWN; } while (0) #define IFF_CLR_UP(f) do { (f) &= ~IFF_UP; } while (0) #define IFF_CLR_RUNNING(f) do { (f) &= ~IFF_RUNNING; } while (0) -#define IFF_CLR_IPv6(f) do { (f) &= ~IFF_IPv6; } while (0) #define IFF_CLR_NOARP(f) do { (f) &= ~IFF_NOARP; } while (0) #define IFF_IS_DOWN(f) (((f) & IFF_DOWN) != 0) #define IFF_IS_UP(f) (((f) & IFF_UP) != 0) #define IFF_IS_RUNNING(f) (((f) & IFF_RUNNING) != 0) -#define IFF_IS_IPv6(f) (((f) & IFF_IPv6) != 0) #define IFF_IS_NOARP(f) (((f) & IFF_NOARP) != 0) -#define IFF_SET_IPv4(f) IFF_CLR_IPv6(f) -#define IFF_CLR_IPv4(f) IFF_SET_IPv6(f) -#define IFF_IS_IPv4(f) (!IFF_IS_IPv6(f)) +/* We only need to manage the IPv6 bit if both IPv6 and IPv4 are supported. Otherwise, + * we can save a few bytes by ignoring it. + */ + +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) +# define IFF_SET_IPv6(f) do { (f) |= IFF_IPv6; } while (0) +# define IFF_CLR_IPv6(f) do { (f) &= ~IFF_IPv6; } while (0) +# define IFF_IS_IPv6(f) (((f) & IFF_IPv6) != 0) + +# define IFF_SET_IPv4(f) IFF_CLR_IPv6(f) +# define IFF_CLR_IPv4(f) IFF_SET_IPv6(f) +# define IFF_IS_IPv4(f) (!IFF_IS_IPv6(f)) + +#elif defined(CONFIG_NET_IPv6) +# define IFF_SET_IPv6(f) +# define IFF_CLR_IPv6(f) +# define IFF_IS_IPv6(f) (1) + +# define IFF_SET_IPv4(f) +# define IFF_CLR_IPv4(f) +# define IFF_IS_IPv4(f) (0) + +#else /* if defined(CONFIG_NET_IPv4) */ +# define IFF_SET_IPv6(f) +# define IFF_CLR_IPv6(f) +# define IFF_IS_IPv6(f) (0) + +# define IFF_SET_IPv4(f) +# define IFF_CLR_IPv4(f) +# define IFF_IS_IPv4(f) (1) +#endif /******************************************************************************************* * Public Type Definitions diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index 394b220a793..fcdf1efd3c6 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -85,6 +85,8 @@ #include #include +#include + #include #include #include @@ -220,7 +222,9 @@ static uint8_t devif_reassembly(void) { g_reassembly_bitmap[i] = 0xff; } - g_reassembly_bitmap[(offset + len) / (8 * 8)] |= ~g_bitmap_bits[((offset + len) / 8 ) & 7]; + + g_reassembly_bitmap[(offset + len) / (8 * 8)] |= + ~g_bitmap_bits[((offset + len) / 8 ) & 7]; } /* If this fragment has the More Fragments flag set to zero, we know that @@ -450,10 +454,14 @@ int ipv4_input(FAR struct net_driver_s *dev) goto drop; } - /* Everything looks good so far. Now process the incoming packet - * according to the protocol. + /* Make sure that all packet processing logic knows that there is an IPv4 + * packet in the device buffer. */ + IFF_SET_IPv4(dev->d_flags); + + /* Now process the incoming packet according to the protocol. */ + switch (pbuf->proto) { #ifdef CONFIG_NET_TCP diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index d508389029c..a613f1975dd 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -85,6 +85,8 @@ #include #include +#include + #include #include #include @@ -249,10 +251,14 @@ int ipv6_input(FAR struct net_driver_s *dev) } } - /* Everything looks good so far. Now process the incoming packet - * according to the protocol. + /* Make sure that all packet processing logic knows that there is an IPv6 + * packet in the device buffer. */ + IFF_SET_IPv6(dev->d_flags); + + /* Now process the incoming packet according to the protocol. */ + switch (ipv6->proto) { #ifdef CONFIG_NET_TCP diff --git a/net/icmp/icmp_ping.c b/net/icmp/icmp_ping.c index e32ef2d3196..8158f2ab4fb 100644 --- a/net/icmp/icmp_ping.c +++ b/net/icmp/icmp_ping.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/icmp/icmp_ping.c * - * Copyright (C) 2008-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -237,6 +237,7 @@ static uint16_t ping_interrupt(FAR struct net_driver_s *dev, FAR void *conn, dev->d_sndlen = pstate->png_datlen + 4; icmp_send(dev, &pstate->png_addr); + pstate->png_sent = true; return flags; } diff --git a/net/icmp/icmp_send.c b/net/icmp/icmp_send.c index e451e67cb35..520fb903561 100644 --- a/net/icmp/icmp_send.c +++ b/net/icmp/icmp_send.c @@ -98,6 +98,8 @@ void icmp_send(FAR struct net_driver_s *dev, FAR in_addr_t *destaddr) if (dev->d_sndlen > 0) { + IFF_SET_IPv4(dev->d_flags); + /* The total length to send is the size of the application data plus * the IP and ICMP headers (and, eventually, the Ethernet header) */ diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index 08e540a9d85..db808a5ceb0 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -122,10 +122,6 @@ void icmpv6_input(FAR struct net_driver_s *dev) g_netstats.icmpv6.recv++; #endif - /* Set a bit in the d_flags to distinguish this from an IPv6 packet */ - - IFF_SET_IPv6(dev->d_flags); - /* If we get a neighbor solicitation for our address we should send * a neighbor advertisement message back. */