mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-27 02:26:55 +08:00
opt.h, netif.h, dhcp.h, dhcp.c: New configuration option LWIP_NETIF_HOSTNAME allow to define a hostname in netif struct (this is just a pointer, so, you can use a hardcoded string, point on one of your's ethernetif field, or alloc a string you will free yourself). It will be used by DHCP to register a client hostname, but can also be use when you call snmp_set_sysname.
This commit is contained in:
@@ -217,6 +217,10 @@ static err_t dhcp_select(struct netif *netif)
|
||||
struct dhcp *dhcp = netif->dhcp;
|
||||
err_t result;
|
||||
u16_t msecs;
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
const char *p;
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||
|
||||
/* create and initialize the DHCP message header */
|
||||
@@ -242,6 +246,16 @@ static err_t dhcp_select(struct netif *netif)
|
||||
dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST);
|
||||
dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER);
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
p = ( const char *)netif->hostname;
|
||||
if (p!=NULL) {
|
||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, strlen(p));
|
||||
while(*p) {
|
||||
dhcp_option_byte(dhcp, *p++);
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
dhcp_option_trailer(dhcp);
|
||||
/* shrink the pbuf to the actual content length */
|
||||
pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);
|
||||
|
||||
Reference in New Issue
Block a user