From ebbf2fc072c421aa58ee0f6d2064bc2b0199c68b Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Mon, 18 Jan 2021 17:57:33 +0800 Subject: [PATCH] netutils/dhcpc: configurable Bootstrap flags Signed-off-by: chao.an --- netutils/dhcpc/Kconfig | 8 ++++++++ netutils/dhcpc/dhcpc.c | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/netutils/dhcpc/Kconfig b/netutils/dhcpc/Kconfig index 1a2839e66..368b162d5 100644 --- a/netutils/dhcpc/Kconfig +++ b/netutils/dhcpc/Kconfig @@ -29,4 +29,12 @@ config NETUTILS_DHCPC_RETRIES This setting determines how many times resolver retries request until failing. +config NETUTILS_DHCPC_BOOTP_FLAGS + hex "Flags of Bootstrap" + default 0x8000 + ---help--- + This setting to set the BOOTP broadcast flags. + Reference RFC1542: Clarifications and Extensions for the + Bootstrap Protocol. + endif diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c index 93e92cd14..dd643c0ba 100644 --- a/netutils/dhcpc/dhcpc.c +++ b/netutils/dhcpc/dhcpc.c @@ -71,8 +71,6 @@ #define STATE_HAVE_OFFER 1 #define STATE_HAVE_LEASE 2 -#define BOOTP_BROADCAST 0x8000 - #define DHCP_REQUEST 1 #define DHCP_REPLY 2 #define DHCP_HTYPE_ETHERNET 1 @@ -261,7 +259,9 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc, * unicast traffic before being fully configured. */ - pdhcpc->packet.flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */ + /* Broadcast bit. */ + + pdhcpc->packet.flags = HTONS(CONFIG_NETUTILS_DHCPC_BOOTP_FLAGS); pend = dhcpc_addhostname(hostname, pend); pend = dhcpc_addreqoptions(pend); @@ -274,7 +274,9 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc, * unicast traffic before being fully configured. */ - pdhcpc->packet.flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */ + /* Broadcast bit. */ + + pdhcpc->packet.flags = HTONS(CONFIG_NETUTILS_DHCPC_BOOTP_FLAGS); pend = dhcpc_addhostname(hostname, pend); pend = dhcpc_addserverid(&pdhcpc->serverid, pend);