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:
fbernon
2007-03-28 09:39:12 +00:00
parent cd1c96db56
commit c1fe7517ec
5 changed files with 36 additions and 1 deletions

View File

@@ -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);