Skip to content

Commit fe2c92b

Browse files
committed
Allow configurable max hostname length
1 parent 9877e1c commit fe2c92b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

components/tcpip_adapter/Kconfig

+7
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@ config TCPIP_ADAPTER_GLOBAL_DATA_LINK_IRAM
2121
help
2222
Link TCPIP adapter global data(.bss .data COMMON) from DRAM to IRAM.
2323

24+
config TCPIP_ADAPTER_HOSTNAME_MAX_LENGTH
25+
int "Max hostname length"
26+
range 1 253
27+
default 32
28+
help
29+
Maximum number of characters in the local hostname
30+
2431
endmenu

components/tcpip_adapter/include/tcpip_adapter.h

-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ esp_interface_t tcpip_adapter_get_esp_if(void *dev);
609609
*/
610610
esp_err_t tcpip_adapter_get_sta_list(wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list);
611611

612-
#define TCPIP_HOSTNAME_MAX_SIZE 32
613612
/**
614613
* @brief Set the hostname to the interface
615614
*

components/tcpip_adapter/tcpip_adapter_lwip.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#include "FreeRTOS.h"
4747
#include "timers.h"
4848

49+
#include "sdkconfig.h"
50+
4951
struct tcpip_adapter_pbuf {
5052
struct pbuf_custom pbuf;
5153

@@ -1217,13 +1219,13 @@ esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *ho
12171219
{
12181220
#if LWIP_NETIF_HOSTNAME
12191221
struct netif *p_netif;
1220-
static char hostinfo[TCPIP_ADAPTER_IF_MAX][TCPIP_HOSTNAME_MAX_SIZE + 1];
1222+
static char hostinfo[TCPIP_ADAPTER_IF_MAX][CONFIG_TCPIP_ADAPTER_HOSTNAME_MAX_LENGTH + 1];
12211223

12221224
if (tcpip_if >= TCPIP_ADAPTER_IF_MAX || hostname == NULL) {
12231225
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
12241226
}
12251227

1226-
if (strlen(hostname) > TCPIP_HOSTNAME_MAX_SIZE) {
1228+
if (strlen(hostname) > CONFIG_TCPIP_ADAPTER_HOSTNAME_MAX_LENGTH) {
12271229
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
12281230
}
12291231

0 commit comments

Comments
 (0)