Merged in masayuki2009/nuttx.apps/dhcpc_host_name (pull request #197)
netutils/dhcpc: Add host name support to dhcp client Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
144a0180e2
commit
811086ff85
@ -12,4 +12,8 @@ config NETUTILS_DHCPC
|
|||||||
|
|
||||||
if NETUTILS_DHCPC
|
if NETUTILS_DHCPC
|
||||||
|
|
||||||
|
config NETUTILS_DHCPC_HOST_NAME
|
||||||
|
string "DHCP client host name"
|
||||||
|
default "nuttx"
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -93,6 +93,7 @@
|
|||||||
#define DHCP_OPTION_SUBNET_MASK 1
|
#define DHCP_OPTION_SUBNET_MASK 1
|
||||||
#define DHCP_OPTION_ROUTER 3
|
#define DHCP_OPTION_ROUTER 3
|
||||||
#define DHCP_OPTION_DNS_SERVER 6
|
#define DHCP_OPTION_DNS_SERVER 6
|
||||||
|
#define DHCP_OPTION_HOST_NAME 12
|
||||||
#define DHCP_OPTION_REQ_IPADDR 50
|
#define DHCP_OPTION_REQ_IPADDR 50
|
||||||
#define DHCP_OPTION_LEASE_TIME 51
|
#define DHCP_OPTION_LEASE_TIME 51
|
||||||
#define DHCP_OPTION_MSG_TYPE 53
|
#define DHCP_OPTION_MSG_TYPE 53
|
||||||
@ -153,6 +154,16 @@ static const uint8_t magic_cookie[4] = {99, 130, 83, 99};
|
|||||||
* Name: dhcpc_add<option>
|
* Name: dhcpc_add<option>
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
static FAR uint8_t *dhcpc_addhostname(FAR const char *hostname,
|
||||||
|
FAR uint8_t *optptr)
|
||||||
|
{
|
||||||
|
int len = strlen(hostname);
|
||||||
|
*optptr++ = DHCP_OPTION_HOST_NAME;
|
||||||
|
*optptr++ = len;
|
||||||
|
memcpy(optptr, hostname, len);
|
||||||
|
return optptr + len;
|
||||||
|
}
|
||||||
|
|
||||||
static FAR uint8_t *dhcpc_addmsgtype(FAR uint8_t *optptr, uint8_t type)
|
static FAR uint8_t *dhcpc_addmsgtype(FAR uint8_t *optptr, uint8_t type)
|
||||||
{
|
{
|
||||||
*optptr++ = DHCP_OPTION_MSG_TYPE;
|
*optptr++ = DHCP_OPTION_MSG_TYPE;
|
||||||
@ -235,6 +246,8 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pdhcpc->packet.flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
|
pdhcpc->packet.flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
|
||||||
|
|
||||||
|
pend = dhcpc_addhostname(CONFIG_NETUTILS_DHCPC_HOST_NAME, pend);
|
||||||
pend = dhcpc_addreqoptions(pend);
|
pend = dhcpc_addreqoptions(pend);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -246,6 +259,8 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pdhcpc->packet.flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
|
pdhcpc->packet.flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
|
||||||
|
|
||||||
|
pend = dhcpc_addhostname(CONFIG_NETUTILS_DHCPC_HOST_NAME, pend);
|
||||||
pend = dhcpc_addserverid(&pdhcpc->serverid, pend);
|
pend = dhcpc_addserverid(&pdhcpc->serverid, pend);
|
||||||
pend = dhcpc_addreqipaddr(&pdhcpc->ipaddr, pend);
|
pend = dhcpc_addreqipaddr(&pdhcpc->ipaddr, pend);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user