Some minor clean-up of IPv4/6 flags

This commit is contained in:
Gregory Nutt 2015-01-24 07:29:43 -06:00
parent a19bec3be1
commit 96a53254dd
7 changed files with 56 additions and 18 deletions

View file

@ -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>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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)
*/

View file

@ -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.
*/