NET: Add a few missing configuration options to the Kconfig files

This commit is contained in:
Gregory Nutt 2014-07-06 13:04:27 -06:00
parent 715fb30f95
commit 1f11a452dd
11 changed files with 99 additions and 54 deletions

View File

@ -107,25 +107,16 @@
#define UIP_TTL 64
/* Turn on support for IP packet reassembly.
*
* uIP supports reassembly of fragmented IP packets. This features
* requires an additonal amount of RAM to hold the reassembly buffer
* and the reassembly code size is approximately 700 bytes. The
* reassembly buffer is of the same size as the d_buf buffer
* (configured by CONFIG_NET_BUFSIZE).
*
* Note: IP packet reassembly is not heavily tested.
*/
#ifdef CONFIG_NET_TCP_REASSEMBLY
# ifndef CONFIG_NET_TCP_REASS_MAXAGE
/* The maximum time an IP fragment should wait in the reassembly
* buffer before it is dropped. Units are deci-seconds, the range
* of the timer is 8-bits.
*/
#define UIP_REASSEMBLY 0
/* The maximum time an IP fragment should wait in the reassembly
* buffer before it is dropped. Units are deci-seconds, the range
* of the timer is 8-bits.
*/
#define UIP_REASS_MAXAGE (20*10) /* 20 seconds */
# define CONFIG_NET_TCP_REASS_MAXAGE (20*10) /* 20 seconds */
# endif
#endif
/* Network drivers often receive packets with garbage at the end
* and are longer than the size of packet in the TCP header. The
@ -249,23 +240,25 @@
/* ARP configuration options */
#ifndef CONFIG_NET_ARPTAB_SIZE
/* The size of the ARP table.
*
* This option should be set to a larger value if this uIP node will
* have many connections from the local network.
*/
#ifndef CONFIG_NET_ARPTAB_SIZE
# define CONFIG_NET_ARPTAB_SIZE 8
#endif
/* The maxium age of ARP table entries measured in 10ths of seconds.
#ifndef CONFIG_NET_ARPTAB_SIZE
/* The maximum age of ARP table entries measured in 10ths of seconds.
*
* An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
* An CONFIG_NET_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
* default).
*/
#define UIP_ARP_MAXAGE 120
# define CONFIG_NET_ARP_MAXAGE 120
#endif
/* General configuration options */

View File

@ -20,6 +20,13 @@ config NET_ARPTAB_SIZE
---help---
The size of the ARP table (in entries).
config NET_ARP_MAXAGE
int "Max ARP entry age"
default 120
---help---
The maximum age of ARP table entries measured in deciseconds. The
default value of 120 corresponds to 20 minutes (BSD default).
config NET_ARP_IPIN
bool "ARP address harvesting"
default n

View File

@ -125,7 +125,9 @@ void arp_timer(void)
for (i = 0; i < CONFIG_NET_ARPTAB_SIZE; ++i)
{
tabptr = &g_arptable[i];
if (tabptr->at_ipaddr != 0 && g_arptime - tabptr->at_time >= UIP_ARP_MAXAGE)
if (tabptr->at_ipaddr != 0 &&
g_arptime - tabptr->at_time >= CONFIG_NET_ARP_MAXAGE)
{
tabptr->at_ipaddr = 0;
}

View File

@ -157,7 +157,7 @@ extern uint16_t g_ipid;
/* Reassembly timer (units: deci-seconds) */
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
extern uint8_t g_reassembly_timer;
#endif

View File

@ -85,7 +85,7 @@ const net_ipaddr_t g_allzeroaddr =
/* Reassembly timer (units: deci-seconds) */
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
uint8_t g_reassembly_timer;
#endif

View File

@ -105,16 +105,16 @@
* Pre-processor Definitions
****************************************************************************/
/* Macros. */
/* Macros */
#define BUF ((FAR struct net_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN])
#define FBUF ((FAR struct net_iphdr_s *)&g_reassembly_buffer[0])
#define BUF ((FAR struct net_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN])
#define FBUF ((FAR struct net_iphdr_s *)&g_reassembly_buffer[0])
/* IP fragment re-assembly */
#define IP_MF 0x20
#define UIP_REASS_BUFSIZE (CONFIG_NET_BUFSIZE - NET_LL_HDRLEN)
#define UIP_REASS_FLAG_LASTFRAG 0x01
#define IP_MF 0x20
#define TCP_REASS_BUFSIZE (CONFIG_NET_BUFSIZE - NET_LL_HDRLEN)
#define TCP_REASS_LASTFRAG 0x01
/****************************************************************************
* Public Variables
@ -124,13 +124,18 @@
* Private Variables
****************************************************************************/
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
static uint8_t g_reassembly_buffer[UIP_REASS_BUFSIZE];
static uint8_t g_reassembly_bitmap[UIP_REASS_BUFSIZE / (8 * 8)];
static const uint8_t g_bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
static uint8_t g_reassembly_buffer[TCP_REASS_BUFSIZE];
static uint8_t g_reassembly_bitmap[TCP_REASS_BUFSIZE / (8 * 8)];
static const uint8_t g_bitmap_bits[8] =
{0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
static uint16_t g_reassembly_len;
static uint8_t g_reassembly_flags;
#endif /* UIP_REASSEMBLY */
#endif /* CONFIG_NET_TCP_REASSEMBLY */
/****************************************************************************
* Private Functions
@ -146,7 +151,7 @@ static uint8_t g_reassembly_flags;
*
****************************************************************************/
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
static uint8_t devif_reassembly(void)
{
FAR struct net_iphdr_s *pbuf = BUF;
@ -163,7 +168,7 @@ static uint8_t devif_reassembly(void)
if (!g_reassembly_timer)
{
memcpy(g_reassembly_buffer, &pbuf->vhl, IP_HDRLEN);
g_reassembly_timer = UIP_REASS_MAXAGE;
g_reassembly_timer = CONFIG_NET_TCP_REASS_MAXAGE;
g_reassembly_flags = 0;
/* Clear the bitmap. */
@ -187,7 +192,7 @@ static uint8_t devif_reassembly(void)
* reassembly buffer, we discard the entire packet.
*/
if (offset > UIP_REASS_BUFSIZE || offset + len > UIP_REASS_BUFSIZE)
if (offset > TCP_REASS_BUFSIZE || offset + len > TCP_REASS_BUFSIZE)
{
g_reassembly_timer = 0;
goto nullreturn;
@ -229,7 +234,7 @@ static uint8_t devif_reassembly(void)
if ((pbuf->ipoffset[0] & IP_MF) == 0)
{
g_reassembly_flags |= UIP_REASS_FLAG_LASTFRAG;
g_reassembly_flags |= TCP_REASS_LASTFRAG;
g_reassembly_len = offset + len;
}
@ -238,7 +243,7 @@ static uint8_t devif_reassembly(void)
* are set.
*/
if (g_reassembly_flags & UIP_REASS_FLAG_LASTFRAG)
if (g_reassembly_flags & TCP_REASS_LASTFRAG)
{
/* Check all bytes up to and including all but the last byte in
* the bitmap.
@ -286,7 +291,7 @@ static uint8_t devif_reassembly(void)
nullreturn:
return 0;
}
#endif /* UIP_REASSEMBLY */
#endif /* CONFIG_NET_TCP_REASSEMBLY */
/****************************************************************************
* Public Functions
@ -387,20 +392,20 @@ int devif_input(FAR struct net_driver_s *dev)
if ((pbuf->ipoffset[0] & 0x3f) != 0 || pbuf->ipoffset[1] != 0)
{
#if UIP_REASSEMBLY
#if defined(CONFIG_NET_TCP_REASSEMBLY)
dev->d_len = devif_reassembly();
if (dev->d_len == 0)
{
goto drop;
}
#else /* UIP_REASSEMBLY */
#else /* CONFIG_NET_TCP_REASSEMBLY */
#ifdef CONFIG_NET_STATISTICS
g_netstats.ip.drop++;
g_netstats.ip.fragerr++;
#endif
nlldbg("IP fragment dropped\n");
goto drop;
#endif /* UIP_REASSEMBLY */
#endif /* CONFIG_NET_TCP_REASSEMBLY */
}
#endif /* CONFIG_NET_IPv6 */

View File

@ -372,12 +372,13 @@ int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback,
/* Increment the timer used by the IP reassembly logic */
#if UIP_REASSEMBLY
if (g_reassembly_timer != 0 && g_reassembly_timer < UIP_REASS_MAXAGE)
#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
if (g_reassembly_timer != 0 &&
g_reassembly_timer < CONFIG_NET_TCP_REASS_MAXAGE)
{
g_reassembly_timer += hsec;
}
#endif /* UIP_REASSEMBLY */
#endif
/* Traverse all of the active packet connections and perform the poll
* action.

View File

@ -9,3 +9,13 @@ config NET_IPv6
depends on EXPERIMENTAL
---help---
Build in support for IPv6. Not fully implemented.
if NET_IPv6
config NET_IPV6_NCONF_ENTRIES
int "Number of neighbors"
default 8
#config NET_IPV6_NEIGHBOR_ADDRTYPE
endif # NET_IPv6

View File

@ -57,8 +57,8 @@
struct net_neighbor_addr_s
{
#if UIP_NEIGHBOR_CONF_ADDRTYPE
UIP_NEIGHBOR_CONF_ADDRTYPE addr;
#if CONFIG_NET_IPV6_NEIGHBOR_ADDRTYPE
CONFIG_NET_IPV6_NEIGHBOR_ADDRTYPE addr;
#else
struct ether_addr addr;
#endif

View File

@ -53,11 +53,11 @@
#define MAX_TIME 128
#ifdef UIP_NEIGHBOR_CONF_ENTRIES
# define ENTRIES UIP_NEIGHBOR_CONF_ENTRIES
#else /* UIP_NEIGHBOR_CONF_ENTRIES */
#ifdef CONFIG_NET_IPV6_NCONF_ENTRIES
# define ENTRIES CONFIG_NET_IPV6_NCONF_ENTRIES
#else /* CONFIG_NET_IPV6_NCONF_ENTRIES */
# define ENTRIES 8
#endif /* UIP_NEIGHBOR_CONF_ENTRIES */
#endif /* CONFIG_NET_IPV6_NCONF_ENTRIES */
/****************************************************************************
* Private Types

View File

@ -21,6 +21,33 @@ config NET_TCPURGDATA
compiled in. Urgent data (out-of-band data) is a rarely used TCP feature
that is very seldom would be required.
config NET_TCP_REASSEMBLY
bool "TCP reassembly"
default n
depends on EXPERIMENTAL
---help---
Enable support for IP packet reassembly of fragmented IP packets.
This features requires an additional amount of RAM to hold the
reassembly buffer and the reassembly code size is approximately 700
bytes. The reassembly buffer is of the same size as the d_buf buffer
(configured by CONFIG_NET_BUFSIZE).
Note: IP packet reassembly is not heavily tested (and, hence,
EXPERIMENTAL).
if NET_TCP_REASSEMBLY
config NET_TCP_REASS_MAXAGE
int "IP fragment timeout"
default 200
---help---
The maximum time an IP fragment should wait in the reassembly buffer
before it is dropped. Units are deci-seconds, the range of the timer
is 8-bits. Default: 20 seconds.
endif # NET_TCP_REASSEMBLY
config NET_TCP_CONNS
int "Number of TCP/IP connections"
default 8