Browse Source

fix incompatible unit in LWIP_NAT_TMR_INTERVAL_SEC

LWIP_NAT_TMR_INTERVAL_SEC defined in ipv4_nat.h is in miliseconds,
but ip_nat_check_timeout() thinks it's in seconds.

With this bug, all nat entries will expire immediately when
ip_nat_check_timeout() is called.

Note sys_timeout() is in miliseconds.
He Chunhui 9 years ago
parent
commit
5439580833
2 changed files with 3 additions and 3 deletions
  1. 2 2
      components/net/lwip_nat/ipv4_nat.c
  2. 1 1
      components/net/lwip_nat/ipv4_nat.h

+ 2 - 2
components/net/lwip_nat/ipv4_nat.c

@@ -229,7 +229,7 @@ nat_timer(void *arg)
   LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: nat_timer()\n"));
 
   ip_nat_tmr();
-  sys_timeout(LWIP_NAT_TMR_INTERVAL_SEC, nat_timer, NULL);
+  sys_timeout(LWIP_NAT_TMR_INTERVAL_SEC * 1000, nat_timer, NULL);
 }
 
 /** Initialize this module */
@@ -255,7 +255,7 @@ ip_nat_init(void)
   rt_enter_critical();
 
   /* add a lwip timer for NAT */
-  sys_timeout(LWIP_NAT_TMR_INTERVAL_SEC, nat_timer, NULL);
+  sys_timeout(LWIP_NAT_TMR_INTERVAL_SEC * 1000, nat_timer, NULL);
 
   /* un-protect */
   rt_exit_critical();

+ 1 - 1
components/net/lwip_nat/ipv4_nat.h

@@ -67,7 +67,7 @@
 #include "lwip/opt.h"
 
 /** Timer interval at which to call ip_nat_tmr() */
-#define LWIP_NAT_TMR_INTERVAL_SEC        (30*1000)
+#define LWIP_NAT_TMR_INTERVAL_SEC        (30)
 
 #ifdef __cplusplus
 extern "C" {