mirror of
https://github.com/martin-ger/esp_wifi_repeater.git
synced 2023-04-24 01:48:22 +03:00
added dynamic NAPT table size
This commit is contained in:
@@ -115,6 +115,8 @@ Most of the set-commands are effective only after save and reset.
|
|||||||
- set ip dhcp: configures dynamic IP address for the STA interface, default
|
- set ip dhcp: configures dynamic IP address for the STA interface, default
|
||||||
- set netmask _netmask_: sets a static netmask for the STA interface
|
- set netmask _netmask_: sets a static netmask for the STA interface
|
||||||
- set gw _gw-addr_: sets a static gateway address for the STA interface
|
- set gw _gw-addr_: sets a static gateway address for the STA interface
|
||||||
|
- set max_nat _no_of_entries_: sets the size of the NAPT table (default 512)
|
||||||
|
- set max_portmap _no_of_entries_: sets the size of the portmap table (default 32)
|
||||||
- set tcp_timeout _secs_: sets the NAPT timeout for TCP connections (0=default (1800 secs))
|
- set tcp_timeout _secs_: sets the NAPT timeout for TCP connections (0=default (1800 secs))
|
||||||
- set udp_timeout _secs_: sets the NAPT timeout for UDP connections (0=default (2 secs))
|
- set udp_timeout _secs_: sets the NAPT timeout for UDP connections (0=default (2 secs))
|
||||||
- show dhcp: prints the current status of the dhcp lease table
|
- show dhcp: prints the current status of the dhcp lease table
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,3 @@
|
|||||||
4242c10cecaa314ec94e9799ed92209a67a0ee77 firmware/0x02000.bin
|
64783fd1d9c4d26e4a4c16a91973ef72b50008d0 firmware/0x02000.bin
|
||||||
f5c525b88e5254bcae044e53bb587b4d4bdc168f firmware/0x82000.bin
|
34635f292d3c62e4207f7bad2a0ded37628861f1 firmware/0x82000.bin
|
||||||
9bd7d25204d71b3db5f35e0b2def8a6aaa7f765c firmware/0x00000.bin
|
9bd7d25204d71b3db5f35e0b2def8a6aaa7f765c firmware/0x00000.bin
|
||||||
|
|||||||
@@ -511,7 +511,7 @@
|
|||||||
* If NAPT is used, ip_napt_init() has to be called explicitly once.
|
* If NAPT is used, ip_napt_init() has to be called explicitly once.
|
||||||
*/
|
*/
|
||||||
#ifndef IP_NAPT_DYNAMIC
|
#ifndef IP_NAPT_DYNAMIC
|
||||||
#define IP_NAPT_DYNAMIC 0
|
#define IP_NAPT_DYNAMIC 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
#include "lwip/ip.h"
|
#include "lwip/ip.h"
|
||||||
|
#include "lwip/lwip_napt.h"
|
||||||
#include "config_flash.h"
|
#include "config_flash.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -85,6 +86,8 @@ uint32_t reg0, reg1, reg3;
|
|||||||
config->automesh_use_ap_ssid= 0;
|
config->automesh_use_ap_ssid= 0;
|
||||||
|
|
||||||
config->nat_enable = 1;
|
config->nat_enable = 1;
|
||||||
|
config->max_nat = IP_NAPT_MAX;
|
||||||
|
config->max_portmap = IP_PORTMAP_MAX;
|
||||||
config->tcp_timeout = 0; // use default
|
config->tcp_timeout = 0; // use default
|
||||||
config->udp_timeout = 0; // use default
|
config->udp_timeout = 0; // use default
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ typedef struct {
|
|||||||
uint32_t am_sleep_time; // Seconds for sleeping
|
uint32_t am_sleep_time; // Seconds for sleeping
|
||||||
uint8_t automesh_use_ap_ssid; // Indicates if ssid or ap_ssid has to be used
|
uint8_t automesh_use_ap_ssid; // Indicates if ssid or ap_ssid has to be used
|
||||||
|
|
||||||
uint8_t nat_enable; // Enable NAT on the AP netif;
|
uint8_t nat_enable; // Enable NAT on the AP netif
|
||||||
|
uint32_t max_nat; // Max number of NAT entires
|
||||||
|
uint32_t max_portmap; // Max number of portmaps
|
||||||
uint32_t tcp_timeout; // NAT timeout of TCP connections
|
uint32_t tcp_timeout; // NAT timeout of TCP connections
|
||||||
uint32_t udp_timeout; // NAT timeout of UDO 'connections'
|
uint32_t udp_timeout; // NAT timeout of UDO 'connections'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef _USER_CONFIG_
|
#ifndef _USER_CONFIG_
|
||||||
#define _USER_CONFIG_
|
#define _USER_CONFIG_
|
||||||
|
|
||||||
#define ESP_REPEATER_VERSION "V2.2.10"
|
#define ESP_REPEATER_VERSION "V2.2.11"
|
||||||
|
|
||||||
#define LOCAL_ACCESS 0x01
|
#define LOCAL_ACCESS 0x01
|
||||||
#define REMOTE_ACCESS 0x02
|
#define REMOTE_ACCESS 0x02
|
||||||
|
|||||||
@@ -1169,7 +1169,7 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn)
|
|||||||
os_sprintf_flash(response, "set [eth_enable|eth_ip|eth_netmask|eth_gw|eth_mac] <val>\r\n");
|
os_sprintf_flash(response, "set [eth_enable|eth_ip|eth_netmask|eth_gw|eth_mac] <val>\r\n");
|
||||||
to_console(response);
|
to_console(response);
|
||||||
#endif
|
#endif
|
||||||
os_sprintf_flash(response, "set [tcp_timeout|udp_timeout] <val>\r\nroute clear|route add <network> <gw>|route delete <network>\r\ninterface <int> [up|down]\r\nportmap [add|remove] [TCP|UDP] <ext_port> <int_addr> <int_port>\r\n");
|
os_sprintf_flash(response, "set [max_nat|max_portmap|tcp_timeout|udp_timeout] <val>\r\nroute clear|route add <network> <gw>|route delete <network>\r\ninterface <int> [up|down]\r\nportmap [add|remove] [TCP|UDP] <ext_port> <int_addr> <int_port>\r\n");
|
||||||
to_console(response);
|
to_console(response);
|
||||||
#if ACLS
|
#if ACLS
|
||||||
os_sprintf_flash(response, "show acl|acl [from_sta|to_sta|from_ap|to_ap] [IP|TCP|UDP] <src_addr> [<src_port>] <dest_addr> [<dest_port>] [allow|deny|allow_monitor|deny_monitor]\r\nacl [from_sta|to_sta|from_ap|to_ap] clear\r\n");
|
os_sprintf_flash(response, "show acl|acl [from_sta|to_sta|from_ap|to_ap] [IP|TCP|UDP] <src_addr> [<src_port>] <dest_addr> [<dest_port>] [allow|deny|allow_monitor|deny_monitor]\r\nacl [from_sta|to_sta|from_ap|to_ap] clear\r\n");
|
||||||
@@ -1353,9 +1353,10 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn)
|
|||||||
to_console(response);
|
to_console(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.tcp_timeout || config.udp_timeout)
|
if (config.max_nat != IP_NAPT_MAX || config.tcp_timeout || config.udp_timeout)
|
||||||
{
|
{
|
||||||
os_sprintf(response, "NAPT timeouts: TCP %ds UDP %ds\r\n",
|
os_sprintf(response, "NAPT table size: %d\r\nNAPT timeouts: TCP %ds UDP %ds\r\n",
|
||||||
|
config.max_nat,
|
||||||
config.tcp_timeout ? config.tcp_timeout : IP_NAPT_TIMEOUT_MS_TCP / 1000,
|
config.tcp_timeout ? config.tcp_timeout : IP_NAPT_TIMEOUT_MS_TCP / 1000,
|
||||||
config.udp_timeout ? config.udp_timeout : IP_NAPT_TIMEOUT_MS_UDP / 1000);
|
config.udp_timeout ? config.udp_timeout : IP_NAPT_TIMEOUT_MS_UDP / 1000);
|
||||||
to_console(response);
|
to_console(response);
|
||||||
@@ -2733,6 +2734,20 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn)
|
|||||||
goto command_handled;
|
goto command_handled;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (strcmp(tokens[1], "max_nat") == 0)
|
||||||
|
{
|
||||||
|
config.max_nat = atoi(tokens[2]);
|
||||||
|
os_sprintf(response, "NAPT table size set to %ds\r\n", config.max_nat);
|
||||||
|
goto command_handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(tokens[1], "max_portmap") == 0)
|
||||||
|
{
|
||||||
|
config.max_portmap = atoi(tokens[2]);
|
||||||
|
os_sprintf(response, "Portmap table size set to %ds\r\n", config.max_portmap);
|
||||||
|
goto command_handled;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(tokens[1], "tcp_timeout") == 0)
|
if (strcmp(tokens[1], "tcp_timeout") == 0)
|
||||||
{
|
{
|
||||||
config.tcp_timeout = atoi(tokens[2]);
|
config.tcp_timeout = atoi(tokens[2]);
|
||||||
@@ -4245,6 +4260,8 @@ void ICACHE_FLASH_ATTR user_init()
|
|||||||
blob_zero(0, sizeof(struct portmap_table) * IP_PORTMAP_MAX);
|
blob_zero(0, sizeof(struct portmap_table) * IP_PORTMAP_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip_napt_init(config.max_nat, config.max_portmap);
|
||||||
|
|
||||||
if (config.tcp_timeout != 0)
|
if (config.tcp_timeout != 0)
|
||||||
ip_napt_set_tcp_timeout(config.tcp_timeout);
|
ip_napt_set_tcp_timeout(config.tcp_timeout);
|
||||||
if (config.udp_timeout != 0)
|
if (config.udp_timeout != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user