mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-25 15:42:56 +00:00
Only add hostname if it's not empty (strlen > 0)
This commit is contained in:
parent
d5531a239b
commit
1c23bfdc7f
@ -271,9 +271,6 @@ dhcp_select(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
#if LWIP_NETIF_HOSTNAME
|
|
||||||
const char *p;
|
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
dhcp_set_state(dhcp, DHCP_REQUESTING);
|
dhcp_set_state(dhcp, DHCP_REQUESTING);
|
||||||
@ -298,13 +295,15 @@ dhcp_select(struct netif *netif)
|
|||||||
dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER);
|
dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER);
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
p = (const char*)netif->hostname;
|
if (netif->hostname != NULL) {
|
||||||
if (p != NULL) {
|
const char *p = (const char*)netif->hostname;
|
||||||
u8_t namelen = (u8_t)strlen(p);
|
u8_t namelen = (u8_t)strlen(p);
|
||||||
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
if (namelen > 0) {
|
||||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
||||||
while (*p) {
|
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
||||||
dhcp_option_byte(dhcp, *p++);
|
while (*p) {
|
||||||
|
dhcp_option_byte(dhcp, *p++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
#endif /* LWIP_NETIF_HOSTNAME */
|
||||||
@ -993,9 +992,6 @@ dhcp_renew(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
#if LWIP_NETIF_HOSTNAME
|
|
||||||
const char *p;
|
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_renew()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_renew()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_RENEWING);
|
dhcp_set_state(dhcp, DHCP_RENEWING);
|
||||||
|
|
||||||
@ -1006,13 +1002,15 @@ dhcp_renew(struct netif *netif)
|
|||||||
dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif));
|
dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif));
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
p = (const char*)netif->hostname;
|
if (netif->hostname != NULL) {
|
||||||
if (p != NULL) {
|
const char *p = (const char*)netif->hostname;
|
||||||
u8_t namelen = (u8_t)strlen(p);
|
u8_t namelen = (u8_t)strlen(p);
|
||||||
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
if (namelen > 0) {
|
||||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
||||||
while (*p) {
|
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
||||||
dhcp_option_byte(dhcp, *p++);
|
while (*p) {
|
||||||
|
dhcp_option_byte(dhcp, *p++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
#endif /* LWIP_NETIF_HOSTNAME */
|
||||||
@ -1057,9 +1055,6 @@ dhcp_rebind(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
#if LWIP_NETIF_HOSTNAME
|
|
||||||
const char *p;
|
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_REBINDING);
|
dhcp_set_state(dhcp, DHCP_REBINDING);
|
||||||
|
|
||||||
@ -1070,13 +1065,15 @@ dhcp_rebind(struct netif *netif)
|
|||||||
dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif));
|
dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif));
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
p = (const char*)netif->hostname;
|
if (netif->hostname != NULL) {
|
||||||
if (p != NULL) {
|
const char *p = (const char*)netif->hostname;
|
||||||
u8_t namelen = (u8_t)strlen(p);
|
u8_t namelen = (u8_t)strlen(p);
|
||||||
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
if (namelen > 0) {
|
||||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
||||||
while (*p) {
|
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
||||||
dhcp_option_byte(dhcp, *p++);
|
while (*p) {
|
||||||
|
dhcp_option_byte(dhcp, *p++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
#endif /* LWIP_NETIF_HOSTNAME */
|
||||||
|
Loading…
Reference in New Issue
Block a user