mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lwip: Add dhcp servers post processing hook
In order to access DHCP messages from clients in different states and possibly to implement custom handlers that alter the current state, e.g. reject a client with specific hostname using NAK.
This commit is contained in:
parent
e3d71c984a
commit
05911fd4a1
@ -955,6 +955,7 @@ static void handle_dhcp(void *arg,
|
||||
u16_t dhcps_msg_cnt = 0;
|
||||
u8_t *p_dhcps_msg = NULL;
|
||||
u8_t *data;
|
||||
s16_t state;
|
||||
|
||||
#if DHCPS_DEBUG
|
||||
DHCPS_LOG("dhcps: handle_dhcp-> receive a packet\n");
|
||||
@ -1026,7 +1027,12 @@ static void handle_dhcp(void *arg,
|
||||
DHCPS_LOG("dhcps: handle_dhcp-> parse_msg(p)\n");
|
||||
#endif
|
||||
|
||||
switch (parse_msg(pmsg_dhcps, tlen - 240)) {
|
||||
state = parse_msg(pmsg_dhcps, tlen - 240);
|
||||
#ifdef LWIP_HOOK_DHCPS_POST_STATE
|
||||
state = LWIP_HOOK_DHCPS_POST_STATE(pmsg_dhcps, malloc_len, state);
|
||||
#endif /* LWIP_HOOK_DHCPS_POST_STATE */
|
||||
|
||||
switch (state) {
|
||||
case DHCPS_STATE_OFFER://1
|
||||
#if DHCPS_DEBUG
|
||||
DHCPS_LOG("dhcps: handle_dhcp-> DHCPD_STATE_OFFER\n");
|
||||
|
@ -45,6 +45,21 @@ enum dhcps_offer_option{
|
||||
OFFER_END
|
||||
};
|
||||
|
||||
/** @brief DHCP server's description of compile time configuration values in dhcpserver.c
|
||||
*
|
||||
* - DHCPS_DEBUG: Prints very detailed debug messages if set to 1, hardcoded to 0
|
||||
* - USE_CLASS_B_NET: Use class B network mask if enabled, not-defined (could be enabled as CC_FLAGS)
|
||||
* - MAX_STATION_NUM: Maximum number of clients, set to Kconfig value CONFIG_LWIP_DHCPS_MAX_STATION_NUM
|
||||
* - LWIP_HOOK_DHCPS_POST_STATE: Used to inject user code after parsing DHCP message, not defined
|
||||
* - could be enabled in lwipopts.h or via CC_FLAGS
|
||||
* - basic usage of the hook to print hex representation of the entire option field is below:
|
||||
* #define LWIP_HOOK_DHCPS_POST_STATE(msg, len, state) \
|
||||
* ({ s16_t ret = state; if (state == DHCPS_STATE_ACK) { ESP_LOG_BUFFER_HEXDUMP("DHCPS",msg->options, 312, ESP_LOG_INFO);} ret; })
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Definitions related to lease time, units and limits
|
||||
*/
|
||||
#define DHCPS_COARSE_TIMER_SECS 1
|
||||
#define DHCPS_MAX_LEASE 0x64
|
||||
#define DHCPS_LEASE_TIME_DEF (120)
|
||||
|
Loading…
x
Reference in New Issue
Block a user