diff --git a/README.md b/README.md index 33e37e5..256412c 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ Any part of a command line input after a single "#" until the end of the line wi - 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 udp_timeout _secs_: sets the NAPT timeout for UDP connections (0=default (2 secs)) +- set lease _min_: sets the lease time in minutes for the internal network DHCP server (default 120) - show dhcp: prints the current status of the dhcp lease table ### Routing diff --git a/user/config_flash.c b/user/config_flash.c index a92e57e..1c29bb7 100644 --- a/user/config_flash.c +++ b/user/config_flash.c @@ -158,6 +158,7 @@ uint32_t reg0, reg1, reg3; config->no_routes = 0; config->dhcps_entries = 0; + config->dhcps_lease_time = 120; #if ACLS acl_init(); // initializes the ACLs, written in config during save #endif diff --git a/user/config_flash.h b/user/config_flash.h index 5b523ad..3b65cc4 100644 --- a/user/config_flash.h +++ b/user/config_flash.h @@ -142,6 +142,7 @@ typedef struct { uint16_t dhcps_entries; // number of allocated entries in the following table struct dhcps_pool dhcps_p[MAX_DHCP]; // DHCP entries + uint32_t dhcps_lease_time; // DHCP server lease time, 120 minutes by default [1, 2880] #if ACLS acl_entry acl[MAX_NO_ACLS][MAX_ACL_ENTRIES]; // ACL entries uint8_t acl_freep[MAX_NO_ACLS]; // ACL free pointers diff --git a/user/user_main.c b/user/user_main.c index 4ca26ac..b718cb7 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -1603,6 +1603,8 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { int i; struct dhcps_pool *p; + os_sprintf(response, "DHCP lease time: %dmin\r\n", config.dhcps_lease_time); + to_console(response); os_sprintf_flash(response, "DHCP table:\r\n"); to_console(response); for (i = 0; (p = dhcps_get_mapping(i)); i++) @@ -2873,6 +2875,14 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) goto command_handled; } + if (strcmp(tokens[1], "lease") == 0) + { + config.dhcps_lease_time = atoi(tokens[2]); + os_sprintf(response, "Lease time set to %dmin\r\n", + config.dhcps_lease_time); + goto command_handled; + } + if (strcmp(tokens[1], "ap_mac") == 0) { if (!parse_mac(config.AP_MAC_address, tokens[2])) @@ -4045,6 +4055,7 @@ void ICACHE_FLASH_ATTR user_set_softap_ip_config(void) dhcp_lease.end_ip = config.network_addr; ip4_addr4(&dhcp_lease.end_ip) = 128; wifi_softap_set_dhcps_lease(&dhcp_lease); + wifi_softap_set_dhcps_lease_time(config.dhcps_lease_time); // in minutes wifi_softap_dhcps_start();