|
8 | 8 | #include "lwip/prot/dhcp.h" |
9 | 9 | #include "lwip/dhcp.h" |
10 | 10 | #include "lwip/prot/iana.h" |
| 11 | +#include "esp_log.h" |
11 | 12 | #include <string.h> |
12 | 13 |
|
13 | 14 | #define __weak __attribute__((weak)) |
14 | 15 |
|
| 16 | +/** |
| 17 | + * Default lwip behavior is to silence LWIP_ERROR() if LWIP_DEBUG is not set. |
| 18 | + * In some case (if IDF hooks are used), we need to log the error message |
| 19 | + * instead of silently ignoring it -- using this macro |
| 20 | + */ |
| 21 | +#define LWIP_ERROR_LOG(message, expression, handler) do { if (!(expression)) { \ |
| 22 | + ESP_LOGE("LWIP_ERROR", message); \ |
| 23 | + handler;}} while(0) |
| 24 | + |
15 | 25 | #ifdef CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT |
16 | 26 | struct netif *__weak |
17 | 27 | lwip_hook_ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest) |
@@ -259,8 +269,9 @@ void dhcp_append_extra_opts(struct netif *netif, uint8_t state, struct dhcp_msg |
259 | 269 | state == DHCP_STATE_REQUESTING || state == DHCP_STATE_BACKING_OFF || state == DHCP_STATE_SELECTING) { |
260 | 270 | size_t i; |
261 | 271 | u8_t *options = msg_out->options + *options_out_len; |
262 | | - LWIP_ERROR("dhcp_append(client_id): options_out_len + 3 + netif->hwaddr_len <= DHCP_OPTIONS_LEN", |
263 | | - *options_out_len + 3U + netif->hwaddr_len <= DHCP_OPTIONS_LEN, return;); |
| 272 | + /* size of this option is not hwaddr_len, but hwaddr_len + 1 (IANA_HWTYPE_ETHERNET) */ |
| 273 | + LWIP_ERROR_LOG("dhcp_append(client_id): options_out_len + 3 + (netif->hwaddr_len + 1) <= DHCP_OPTIONS_LEN, please increase LWIP_DHCP_OPTIONS_LEN", |
| 274 | + *options_out_len + 3U + (netif->hwaddr_len + 1) <= DHCP_OPTIONS_LEN, return;); |
264 | 275 | *options_out_len = *options_out_len + netif->hwaddr_len + 3; |
265 | 276 | *options++ = DHCP_OPTION_CLIENT_ID; |
266 | 277 | *options++ = netif->hwaddr_len + 1; /* option size */ |
@@ -290,7 +301,7 @@ void dhcp_append_extra_opts(struct netif *netif, uint8_t state, struct dhcp_msg |
290 | 301 | } |
291 | 302 | #endif /* LWIP_NETIF_HOSTNAME */ |
292 | 303 | } |
293 | | - LWIP_ERROR("dhcp_append(vci): options_out_len + 3 + vci_size <= DHCP_OPTIONS_LEN", |
| 304 | + LWIP_ERROR_LOG("dhcp_append(vci): options_out_len + 3 + vci_size <= DHCP_OPTIONS_LEN, please increase LWIP_DHCP_OPTIONS_LEN", |
294 | 305 | *options_out_len + 3U + len <= DHCP_OPTIONS_LEN, return;); |
295 | 306 | if (p) { |
296 | 307 | u8_t *options = msg_out->options + *options_out_len; |
|
0 commit comments