changeset 5573:5bf8e1fc0634 draft

DHCP: For anonymous, just use a generic clientid
author Roy Marples <roy@marples.name>
date Sun, 27 Dec 2020 23:52:44 +0000
parents aae13416e9b7
children 2a519da0f1a2
files src/dhcp.c
diffstat 1 files changed, 4 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcp.c	Sun Dec 27 22:31:02 2020 +0000
+++ b/src/dhcp.c	Sun Dec 27 23:52:44 2020 +0000
@@ -3886,20 +3886,9 @@
 	state->clientid = NULL;
 
 	if (ifo->options & DHCPCD_ANONYMOUS) {
-		uint8_t duid[DUID_LEN];
-		uint8_t duid_len;
-
-		duid_len = (uint8_t)duid_make(duid, ifp, DUID_LL);
-		if (duid_len != 0) {
-			state->clientid = malloc((size_t)duid_len + 6);
-			if (state->clientid == NULL)
-				goto eexit;
-			state->clientid[0] =(uint8_t)(duid_len + 5);
-			state->clientid[1] = 255; /* RFC 4361 */
-			memcpy(state->clientid + 2, ifo->iaid, 4);
-			memset(state->clientid + 2, 0, 4); /* IAID */
-			memcpy(state->clientid + 6, duid, duid_len);
-		}
+		/* Removing the option could show that we want anonymous.
+		 * As such keep it as it's already in the hwaddr field. */
+		goto make_clientid;
 	} else if (*ifo->clientid) {
 		state->clientid = malloc((size_t)(ifo->clientid[0] + 1));
 		if (state->clientid == NULL)
@@ -3917,6 +3906,7 @@
 			memcpy(state->clientid + 6, ifp->ctx->duid,
 			    ifp->ctx->duid_len);
 		} else {
+make_clientid:
 			len = (uint8_t)(ifp->hwlen + 1);
 			state->clientid = malloc((size_t)len + 1);
 			if (state->clientid == NULL)