updated picoTCP to 1.4.0, lowered build optimization levels to -O2, improved selftest

This commit is contained in:
Joseph Henry
2017-06-05 14:26:06 -07:00
parent 47a80e8954
commit 19839eeac9
367 changed files with 107850 additions and 3813 deletions

View File

@@ -1,6 +1,6 @@
/*********************************************************************
PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
See LICENSE and COPYING for usage.
PicoTCP. Copyright (c) 2012-2017 Altran Intelligent Systems. Some rights reserved.
See COPYING, LICENSE.GPLv2 and LICENSE.GPLv3 for usage.
.
@@ -19,8 +19,12 @@
#ifdef PICO_SUPPORT_IPV4
#ifdef PICO_SUPPORT_NAT
#ifdef DEBUG_NAT
#define nat_dbg dbg
#else
#define nat_dbg(...) do {} while(0)
/* #define nat_dbg dbg */
#endif
#define PICO_NAT_TIMEWAIT 240000 /* msec (4 mins) */
#define PICO_NAT_INBOUND 0
@@ -116,8 +120,8 @@ static int nat_cmp_outbound(void *ka, void *kb)
return nat_cmp_proto(a, b);
}
PICO_TREE_DECLARE(NATOutbound, nat_cmp_outbound);
PICO_TREE_DECLARE(NATInbound, nat_cmp_inbound);
static PICO_TREE_DECLARE(NATOutbound, nat_cmp_outbound);
static PICO_TREE_DECLARE(NATInbound, nat_cmp_inbound);
void pico_ipv4_nat_print_table(void)
{
@@ -366,6 +370,7 @@ static void pico_ipv4_nat_table_cleanup(pico_time now, void *_unused)
pico_ipv4_nat_del(t->nat_port, t->proto);
else
t->conn_active++;
break;
default:
/* unknown protocol in NAT table, delete when it has existed NAT_TIMEWAIT */
@@ -378,7 +383,10 @@ static void pico_ipv4_nat_table_cleanup(pico_time now, void *_unused)
nat_dbg("NAT: after table cleanup:\n");
pico_ipv4_nat_print_table();
pico_timer_add(PICO_NAT_TIMEWAIT, pico_ipv4_nat_table_cleanup, NULL);
if (!pico_timer_add(PICO_NAT_TIMEWAIT, pico_ipv4_nat_table_cleanup, NULL)) {
nat_dbg("NAT: Failed to start cleanup timer\n");
/* TODO no more NAT table cleanup now */
}
}
int pico_ipv4_port_forward(struct pico_ip4 nat_addr, uint16_t nat_port, struct pico_ip4 src_addr, uint16_t src_port, uint8_t proto, uint8_t flag)
@@ -550,8 +558,13 @@ int pico_ipv4_nat_enable(struct pico_ipv4_link *link)
return -1;
}
if (!pico_timer_add(PICO_NAT_TIMEWAIT, pico_ipv4_nat_table_cleanup, NULL)) {
nat_dbg("NAT: Failed to start cleanup timer\n");
return -1;
}
nat_link = link;
pico_timer_add(PICO_NAT_TIMEWAIT, pico_ipv4_nat_table_cleanup, NULL);
return 0;
}