diff options
author | Ambroz Bizjak <ambrop7@gmail.com> | 2017-09-26 20:16:15 +0300 |
---|---|---|
committer | Ambroz Bizjak <ambrop7@gmail.com> | 2017-09-26 20:16:15 +0300 |
commit | ed5131134448e1c977a1dc18ae9fb23aef3beaf4 (patch) | |
tree | 6d7e47fcbcdea895d67aa12edb7afb1213f11a24 | |
parent | 6ab97ef3bcb1f665ddaf6fd7bc91dfe3af1e0c4f (diff) |
tun2socks: Call the other lwip timer functions that should be
Also define IPV6_FRAG_COPYHEADER to fix assertion failure in lwip on 64-bit
systems.
-rw-r--r-- | lwip/custom/lwipopts.h | 4 | ||||
-rw-r--r-- | tun2socks/tun2socks.c | 27 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lwip/custom/lwipopts.h b/lwip/custom/lwipopts.h index 4bf0913..9605d2f 100644 --- a/lwip/custom/lwipopts.h +++ b/lwip/custom/lwipopts.h @@ -72,6 +72,10 @@ #define SYS_LIGHTWEIGHT_PROT 0 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS +// needed on 64-bit systems, enable it always so that the same configuration +// is used regardless of the platform +#define IPV6_FRAG_COPYHEADER 1 + /* #define LWIP_DEBUG 1 #define IP_DEBUG LWIP_DBG_ON diff --git a/tun2socks/tun2socks.c b/tun2socks/tun2socks.c index 9541bba..36c72c7 100644 --- a/tun2socks/tun2socks.c +++ b/tun2socks/tun2socks.c @@ -61,6 +61,9 @@ #include <lwip/priv/tcp_priv.h> #include <lwip/netif.h> #include <lwip/tcp.h> +#include <lwip/ip4_frag.h> +#include <lwip/nd6.h> +#include <lwip/ip6_frag.h> #include <tun2socks/SocksUdpGwClient.h> #ifndef BADVPN_USE_WINAPI @@ -182,6 +185,7 @@ int udp_mtu; // TCP timer BTimer tcp_timer; +int tcp_timer_mod4; // job for initializing lwip BPending lwip_init_job; @@ -391,6 +395,7 @@ int main (int argc, char **argv) // it won't trigger before lwip is initialized, becuase the lwip init is a job BTimer_Init(&tcp_timer, TCP_TMR_INTERVAL, tcp_timer_handler, NULL); BReactor_SetTimer(&ss, &tcp_timer); + tcp_timer_mod4 = 0; // set no netif have_netif = 0; @@ -969,7 +974,29 @@ void tcp_timer_handler (void *unused) // schedule next timer BReactor_SetTimer(&ss, &tcp_timer); + // call the TCP timer function (every 1/4 second) tcp_tmr(); + + // increment tcp_timer_mod4 + tcp_timer_mod4 = (tcp_timer_mod4 + 1) % 4; + + // every second, call other timer functions + if (tcp_timer_mod4 == 0) { +#if IP_REASSEMBLY + ASSERT(IP_TMR_INTERVAL == 4 * TCP_TMR_INTERVAL) + ip_reass_tmr(); +#endif + +#if LWIP_IPV6 + ASSERT(ND6_TMR_INTERVAL == 4 * TCP_TMR_INTERVAL) + nd6_tmr(); +#endif + +#if LWIP_IPV6 && LWIP_IPV6_REASS + ASSERT(IP6_REASS_TMR_INTERVAL == 4 * TCP_TMR_INTERVAL) + ip6_reass_tmr(); +#endif + } } void device_error_handler (void *unused) |