summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-24 07:29:43 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-24 07:29:43 -0600
commitf331654b9526da69868089165c4e3dabadfd72a1 (patch)
tree87802970abed34a4c2dd85049958a168ac12e034
parentd6d68d7d117318c7e1eadf40e989e28cba579419 (diff)
downloadnuttx-f331654b9526da69868089165c4e3dabadfd72a1.tar.gz
nuttx-f331654b9526da69868089165c4e3dabadfd72a1.tar.bz2
nuttx-f331654b9526da69868089165c4e3dabadfd72a1.zip
Some minor clean-up of IPv4/6 flags
-rw-r--r--nuttx/Documentation/NuttX.html4
-rw-r--r--nuttx/include/net/if.h37
-rw-r--r--nuttx/net/devif/ipv4_input.c14
-rw-r--r--nuttx/net/devif/ipv6_input.c10
-rw-r--r--nuttx/net/icmp/icmp_ping.c3
-rw-r--r--nuttx/net/icmp/icmp_send.c2
-rw-r--r--nuttx/net/icmpv6/icmpv6_input.c4
7 files changed, 56 insertions, 18 deletions
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 53c2e4070..a18b628af 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
- <p>Last Updated: December 17, 2014</p>
+ <p>Last Updated: January 24, 2014</p>
</td>
</tr>
</table>
@@ -694,7 +694,7 @@
<td><br></td>
<td>
<p>
- <li>TCP/IP, UDP, ICMP, IGMPv2 (client) stacks.</li>
+ <li>IPv4, IPv6, TCP/IP, UDP, ICMP, IGMPv2 (client) stacks.</li>
</p>
</td>
</tr>
diff --git a/nuttx/include/net/if.h b/nuttx/include/net/if.h
index cd44f495b..6970baae1 100644
--- a/nuttx/include/net/if.h
+++ b/nuttx/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/nuttx/net/devif/ipv4_input.c b/nuttx/net/devif/ipv4_input.c
index 394b220a7..fcdf1efd3 100644
--- a/nuttx/net/devif/ipv4_input.c
+++ b/nuttx/net/devif/ipv4_input.c
@@ -85,6 +85,8 @@
#include <debug.h>
#include <string.h>
+#include <net/if.h>
+
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/netstats.h>
@@ -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/nuttx/net/devif/ipv6_input.c b/nuttx/net/devif/ipv6_input.c
index d50838902..a613f1975 100644
--- a/nuttx/net/devif/ipv6_input.c
+++ b/nuttx/net/devif/ipv6_input.c
@@ -85,6 +85,8 @@
#include <debug.h>
#include <string.h>
+#include <net/if.h>
+
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/netstats.h>
@@ -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/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c
index e32ef2d31..8158f2ab4 100644
--- a/nuttx/net/icmp/icmp_ping.c
+++ b/nuttx/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 <gnutt@nuttx.org>
*
* 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/nuttx/net/icmp/icmp_send.c b/nuttx/net/icmp/icmp_send.c
index e451e67cb..520fb9035 100644
--- a/nuttx/net/icmp/icmp_send.c
+++ b/nuttx/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/nuttx/net/icmpv6/icmpv6_input.c b/nuttx/net/icmpv6/icmpv6_input.c
index 08e540a9d..db808a5ce 100644
--- a/nuttx/net/icmpv6/icmpv6_input.c
+++ b/nuttx/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.
*/