lwIP can't assign hostname (until I modify STM32CubeIDE generated code...)
Hello folks,
I'm working on a TCP Server implementation on a custom board using Ethernet communication with a STM32F107VCT6 in STM32CubeIDE and I've found a problem in the LWIP generated code (to be sincere the same problem has been verified by me occurring also on a NUCLEO-F439ZI board).
No matter as long I set Device Configuration Tool (.ioc file) in LWIP/Key Options/Network Interfaces Options
LWIP_ENABLE_NETIF_HOSTNAME > Enabled
LWIP_NETIF_HOSTNAME > myhostname
No hostname is provided by the board which I correctly ping via IP (but not via hostname) and run correctly the TCP Server application). The board have been tested in different networks and checked both via "ping -a my_ip" and directly in the router tables).
Diving a little into the generated code in LWIP/Target/lwipopts.h correctly get:
/*----- Default Value for LWIP_ENABLE_NETIF_HOSTNAME: 0 ---*/
#define LWIP_ENABLE_NETIF_HOSTNAME 1
/*----- Default Value for LWIP_NETIF_HOSTNAME: lwip ---*/
#define LWIP_NETIF_HOSTNAME "myhostname"
but in LWIP/Target/ethernetif.h I get:
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
netif->hostname = "myhostname";
#endif /* LWIP_NETIF_HOSTNAME */
other occurrences in Middlewares/Third_Party/ LwIP/netif.h are similar, just as example:
#if LWIP_NETIF_HOSTNAME
/** @ingroup netif */
#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
/** @ingroup netif */
#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
#endif /* LWIP_NETIF_HOSTNAME */
Debugging the code all the pragmas "#if LWIP_NETIF_HOSTNAME" appear to be ignored therefore the code is not compiled, hint: before compiling the Macro Expansion on the LWIP_NETIF_HOSTNAME says "0".
But if I deliberately modify manually (after the automatic code generation):
#define LWIP_NETIF_HOSTNAME 1 //myhostname
It start working flawlessly (the #if are enabled, the code is compiled, and i can ping the hostname directly). :\
Am I doing something wrong in configuring the ioc file or...maybe...all the "#if LWIP_NETIF_HOSTNAME" in the generated code should actually be a more reasoneable "#if LWIP_ENABLE_NETIF_HOSTNAME"?
Thanks
