Merge branch 'feature/dhcp_server_options_menuconfig' into 'master'
dhcpserver: Option to change lease time multiplier and number of max See merge request !1595
This commit is contained in:
commit
1d5389668b
3 changed files with 32 additions and 8 deletions
|
@ -111,6 +111,28 @@ config LWIP_DHCP_DOES_ARP_CHECK
|
||||||
Enabling this option performs a check (via ARP request) if the offered IP address
|
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.
|
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
|
menuconfig LWIP_AUTOIP
|
||||||
bool "Enable IPV4 Link-Local Addressing (AUTOIP)"
|
bool "Enable IPV4 Link-Local Addressing (AUTOIP)"
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#define DHCPS_DEBUG 0
|
#define DHCPS_DEBUG 0
|
||||||
#define DHCPS_LOG printf
|
#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_OFFER 1
|
||||||
#define DHCPS_STATE_DECLINE 2
|
#define DHCPS_STATE_DECLINE 2
|
||||||
|
@ -311,10 +311,10 @@ static u8_t *add_offer_options(u8_t *optptr)
|
||||||
|
|
||||||
*optptr++ = DHCP_OPTION_LEASE_TIME;
|
*optptr++ = DHCP_OPTION_LEASE_TIME;
|
||||||
*optptr++ = 4;
|
*optptr++ = 4;
|
||||||
*optptr++ = ((dhcps_lease_time * 60) >> 24) & 0xFF;
|
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 24) & 0xFF;
|
||||||
*optptr++ = ((dhcps_lease_time * 60) >> 16) & 0xFF;
|
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 16) & 0xFF;
|
||||||
*optptr++ = ((dhcps_lease_time * 60) >> 8) & 0xFF;
|
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 8) & 0xFF;
|
||||||
*optptr++ = ((dhcps_lease_time * 60) >> 0) & 0xFF;
|
*optptr++ = ((dhcps_lease_time * DHCPS_LEASE_UNIT) >> 0) & 0xFF;
|
||||||
|
|
||||||
*optptr++ = DHCP_OPTION_SERVER_ID;
|
*optptr++ = DHCP_OPTION_SERVER_ID;
|
||||||
*optptr++ = 4;
|
*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)
|
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 (memcmp((char *)m->options, &magic_cookie, sizeof(magic_cookie)) == 0) {
|
||||||
#if DHCPS_DEBUG
|
#if DHCPS_DEBUG
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#ifndef __DHCPS_H__
|
#ifndef __DHCPS_H__
|
||||||
#define __DHCPS_H__
|
#define __DHCPS_H__
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
|
|
||||||
typedef struct dhcps_state{
|
typedef struct dhcps_state{
|
||||||
|
@ -51,6 +52,7 @@ enum dhcps_offer_option{
|
||||||
#define DHCPS_COARSE_TIMER_SECS 1
|
#define DHCPS_COARSE_TIMER_SECS 1
|
||||||
#define DHCPS_MAX_LEASE 0x64
|
#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{
|
struct dhcps_pool{
|
||||||
ip4_addr_t ip;
|
ip4_addr_t ip;
|
||||||
|
|
Loading…
Reference in a new issue