|
From: | Juan Jose Schiavoni |
Subject: | [lwip-devel] Problems with DHCP hostname len |
Date: | Mon, 26 Sep 2011 19:59:37 +0000 |
Hi, my application hang when I enable the hostname for dhcp, that use lwip by default.
I found two problems: 1) the macro LWIP_MAX always set len in 255. 2) the loop while(len--) do not count of options bytes available. #if LWIP_NETIF_HOSTNAME static void dhcp_option_hostname(struct dhcp *dhcp, struct netif *netif) { if (netif->hostname != NULL) { size_t namelen = strlen(netif->hostname); if (namelen > 0) { u8_t len; const char *p = netif->hostname; LWIP_ASSERT("DHCP: hostname is too long!", namelen <= 255); //len = LWIP_MAX(namelen, 255); len = LWIP_MIN(namelen, 255); // Shrink len to available bytes. if(((dhcp->options_out_len + 2) + len) > DHCP_OPTIONS_LEN){ len = DHCP_OPTIONS_LEN - (dhcp->options_out_len + 2); } dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, len); while (len--) { dhcp_option_byte(dhcp, *p++); } } } } #endif /* LWIP_NETIF_HOSTNAME */ |
[Prev in Thread] | Current Thread | [Next in Thread] |