Add dhcp option 61

This commit is contained in:
xueyunfei
2021-01-25 15:57:24 +08:00
parent 9c62fd4e22
commit 2117f049dc
2 changed files with 23 additions and 1 deletions
+15 -1
View File
@@ -403,6 +403,14 @@ dhcp_select(struct netif *netif)
options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_REQUESTED_IP, 4);
options_out_len = dhcp_option_long(options_out_len, msg_out->options, lwip_ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr)));
#if ESP_DHCP
options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_CLIENT_ID, DHCP_OPTION_CLIENT_ID_MAC_LEN);
options_out_len = dhcp_option_byte(options_out_len, msg_out->options, DHCP_OPTION_CLIENT_ID_MAC);
for (i = 0; i < netif->hwaddr_len; i++) {
options_out_len = dhcp_option_byte(options_out_len, msg_out->options, netif->hwaddr[i]);
}
#endif/* ESP_DHCP */
options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_SERVER_ID, 4);
options_out_len = dhcp_option_long(options_out_len, msg_out->options, lwip_ntohl(ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr))));
@@ -1085,7 +1093,13 @@ dhcp_discover(struct netif *netif)
#if LWIP_NETIF_HOSTNAME
options_out_len = dhcp_option_hostname(options_out_len, msg_out->options, netif);
#endif /* LWIP NETIF HOSTNAME */
#endif /* ESP_DHCP */
options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_CLIENT_ID, DHCP_OPTION_CLIENT_ID_MAC_LEN);
options_out_len = dhcp_option_byte(options_out_len, msg_out->options, DHCP_OPTION_CLIENT_ID_MAC);
for (i = 0; i < netif->hwaddr_len; i++) {
options_out_len = dhcp_option_byte(options_out_len, msg_out->options, netif->hwaddr[i]);
}
#endif/* ESP_DHCP */
options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_PARAMETER_REQUEST_LIST, LWIP_ARRAYSIZE(dhcp_discover_request_options));
for (i = 0; i < LWIP_ARRAYSIZE(dhcp_discover_request_options); i++) {
+8
View File
@@ -170,6 +170,14 @@ typedef enum {
#define DHCP_OVERLOAD_SNAME 2
#define DHCP_OVERLOAD_SNAME_FILE 3
/* DHCP OPTION 61 TYPE */
#if ESP_DHCP
#define DHCP_OPTION_CLIENT_ID_MAC 0x01
#define DHCP_OPTION_CLIENT_ID_DUID 0x02
#define DHCP_OPTION_CLIENT_ID_IAID 0xff
#define DHCP_OPTION_CLIENT_ID_MAC_LEN 7
#endif
#ifdef __cplusplus
}