You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/09/27 04:20:39 UTC
[incubator-nuttx-apps] branch master updated: netutils/dhcpc: Add dhcp client id option
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 162dc0996 netutils/dhcpc: Add dhcp client id option
162dc0996 is described below
commit 162dc0996cb4c594f5517154a9099494ef2179be
Author: SunJ <js...@bouffalolab.com>
AuthorDate: Mon Sep 26 11:28:28 2022 +0800
netutils/dhcpc: Add dhcp client id option
Signed-off-by: SunJ <js...@bouffalolab.com>
---
netutils/dhcpc/dhcpc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c
index 43c2edc48..b1553a799 100644
--- a/netutils/dhcpc/dhcpc.c
+++ b/netutils/dhcpc/dhcpc.c
@@ -99,6 +99,7 @@
#define DHCP_OPTION_MSG_TYPE 53
#define DHCP_OPTION_SERVER_ID 54
#define DHCP_OPTION_REQ_LIST 55
+#define DHCP_OPTION_CLIENT_ID 61
#define DHCP_OPTION_END 255
#define BUFFER_SIZE 256
@@ -196,6 +197,17 @@ static FAR uint8_t *dhcpc_addreqipaddr(FAR struct in_addr *ipaddr,
return optptr + 4;
}
+static FAR uint8_t *dhcpc_addclientid(FAR uint8_t *clientid,
+ FAR uint8_t len,
+ FAR uint8_t *optptr)
+{
+ *optptr++ = DHCP_OPTION_CLIENT_ID;
+ *optptr++ = 1 + len;
+ *optptr++ = 0x1;
+ memcpy(optptr, clientid, len);
+ return optptr + len;
+}
+
static FAR uint8_t *dhcpc_addreqoptions(FAR uint8_t *optptr)
{
*optptr++ = DHCP_OPTION_REQ_LIST;
@@ -265,6 +277,7 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
pend = dhcpc_addhostname(hostname, pend);
pend = dhcpc_addreqoptions(pend);
+ pend = dhcpc_addclientid(pdhcpc->macaddr, pdhcpc->maclen, pend);
break;
/* Send REQUEST message to the server that sent the *first* OFFER */
@@ -281,6 +294,7 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
pend = dhcpc_addhostname(hostname, pend);
pend = dhcpc_addserverid(&pdhcpc->serverid, pend);
pend = dhcpc_addreqipaddr(&pdhcpc->ipaddr, pend);
+ pend = dhcpc_addclientid(pdhcpc->macaddr, pdhcpc->maclen, pend);
break;
/* Send DECLINE message to the server that sent the *last* OFFER */