diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index 03bd2be3b6..89ccec31fc 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -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"); diff --git a/components/lwip/include/apps/dhcpserver/dhcpserver.h b/components/lwip/include/apps/dhcpserver/dhcpserver.h index d97d9f0a9c..7a95eb499a 100644 --- a/components/lwip/include/apps/dhcpserver/dhcpserver.h +++ b/components/lwip/include/apps/dhcpserver/dhcpserver.h @@ -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)