mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
dhcpserver: Option to change lease time multiplier and number of max
stations connected to it. Merges: https://github.com/espressif/esp-idf/pull/1206
This commit is contained in:
parent
02304ad83e
commit
626ad5f577
@ -111,6 +111,28 @@ config LWIP_DHCP_DOES_ARP_CHECK
|
||||
Enabling this option performs a check (via ARP request) if the offered IP address
|
||||
is not already in use by another host on the network.
|
||||
|
||||
menu "DHCP server"
|
||||
|
||||
config LWIP_DHCPS_LEASE_UNIT
|
||||
int "Multiplier for lease time, in seconds"
|
||||
range 1 3600
|
||||
default 60
|
||||
help
|
||||
The DHCP server is calculating lease time multiplying the sent
|
||||
and received times by this number of seconds per unit.
|
||||
The default is 60, that equals one minute.
|
||||
|
||||
config LWIP_DHCPS_MAX_STATION_NUM
|
||||
int "Maximum number of stations"
|
||||
range 1 64
|
||||
default 8
|
||||
help
|
||||
The maximum number of DHCP clients that are connected to the server.
|
||||
After this number is exceeded, DHCP server removes of the oldest device
|
||||
from it's address pool, without notification.
|
||||
|
||||
endmenu # DHCPS
|
||||
|
||||
menuconfig LWIP_AUTOIP
|
||||
bool "Enable IPV4 Link-Local Addressing (AUTOIP)"
|
||||
default n
|
||||
|
@ -63,7 +63,7 @@
|
||||
#define DHCPS_DEBUG 0
|
||||
#define DHCPS_LOG printf
|
||||
|
||||
#define MAX_STATION_NUM 8
|
||||
#define MAX_STATION_NUM CONFIG_LWIP_DHCPS_MAX_STATION_NUM
|
||||
|
||||
#define DHCPS_STATE_OFFER 1
|
||||
#define DHCPS_STATE_DECLINE 2
|
||||
@ -311,10 +311,10 @@ static u8_t *add_offer_options(u8_t *optptr)
|
||||
|
||||
*optptr++ = DHCP_OPTION_LEASE_TIME;
|
||||
*optptr++ = 4;
|
||||
*optptr++ = ((dhcps_lease_time * 60) >> 24) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * 60) >> 16) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * 60) >> 8) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * 60) >> 0) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 24) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 16) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 8) & 0xFF;
|
||||
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 0) & 0xFF;
|
||||
|
||||
*optptr++ = DHCP_OPTION_SERVER_ID;
|
||||
*optptr++ = 4;
|
||||
@ -800,7 +800,7 @@ static u8_t parse_options(u8_t *optptr, s16_t len)
|
||||
*******************************************************************************/
|
||||
static s16_t parse_msg(struct dhcps_msg *m, u16_t len)
|
||||
{
|
||||
u32_t lease_timer = (dhcps_lease_time * 60)/DHCPS_COARSE_TIMER_SECS;
|
||||
u32_t lease_timer = (dhcps_lease_time * DHCPS_LEASE_UNIT)/DHCPS_COARSE_TIMER_SECS;
|
||||
|
||||
if (memcmp((char *)m->options, &magic_cookie, sizeof(magic_cookie)) == 0) {
|
||||
#if DHCPS_DEBUG
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef __DHCPS_H__
|
||||
#define __DHCPS_H__
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
typedef struct dhcps_state{
|
||||
@ -51,6 +52,7 @@ enum dhcps_offer_option{
|
||||
#define DHCPS_COARSE_TIMER_SECS 1
|
||||
#define DHCPS_MAX_LEASE 0x64
|
||||
#define DHCPS_LEASE_TIME_DEF (120)
|
||||
#define DHCPS_LEASE_UNIT CONFIG_LWIP_DHCPS_LEASE_UNIT
|
||||
|
||||
struct dhcps_pool{
|
||||
ip4_addr_t ip;
|
||||
|
Loading…
Reference in New Issue
Block a user