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
#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
*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;
*******************************************************************************/
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
DHCPS_LOG("dhcps: len = %d\n", len);
#ifndef __DHCPS_H__
#define __DHCPS_H__
+#include "sdkconfig.h"
#include "lwip/ip_addr.h"
typedef struct dhcps_state{
#define DHCPS_COARSE_TIMER_SECS 1
#define DHCPS_MAX_LEASE 0x64
-#define DHCPS_LEASE_TIME_DEF (120)
+#define DHCPS_LEASE_TIME_DEF (120)
+#define DHCPS_LEASE_UNIT CONFIG_LWIP_DHCPS_LEASE_UNIT
struct dhcps_pool{
ip4_addr_t ip;