.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 2, 2020
+.Dd September 15, 2020
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
sends a default
.Ar clientid
of the hardware family and the hardware address.
-.It Ic duid
+.It Ic duid Op ll | lt | uuid
Use a DHCP Unique Identifier.
If a system UUID is available, that will be used to create a DUID-UUID,
otheriwse if persistent storage is available then a DUID-LLT
(link local address + time) is generated,
otherwise DUID-LL is generated (link local address).
+The DUID type can be hinted as an optional parameter if the file
+.Pa @DBDIR@/duid
+does not exist.
This, plus the IAID will be used as the
.Ic clientid .
The DUID generated will be held in
char **ifv; /* listed interfaces */
int ifcc; /* configured interfaces */
char **ifcv; /* configured interfaces */
+ uint8_t duid_type;
unsigned char *duid;
size_t duid_len;
struct if_head *ifaces;
/* No file? OK, lets make one based the machines UUID */
if (ifp == NULL) {
+ if (ctx->duid_type != DUID_DEFAULT &&
+ ctx->duid_type != DUID_UUID)
+ return 0;
len = duid_make_uuid(data);
if (len == 0)
free(data);
logwarnx("picked interface %s to generate a DUID",
ifp->name);
} else {
- logwarnx("no interfaces have a fixed hardware "
- "address");
+ if (ctx->duid_type != DUID_LL)
+ logwarnx("no interfaces have a fixed hardware "
+ "address");
return duid_make(data, ifp, DUID_LL);
}
}
- len = duid_make(data, ifp, DUID_LLT);
+ len = duid_make(data, ifp,
+ ctx->duid_type == DUID_LL ? DUID_LL : DUID_LLT);
hwaddr_ntoa(data, len, line, sizeof(line));
slen = strlen(line);
if (slen < sizeof(line) - 2) {
}
if (dhcp_writefile(ctx, DUID, 0640, line, slen) == -1) {
logerr("%s: cannot write duid", __func__);
- return duid_make(data, ifp, DUID_LL);
+ if (ctx->duid_type != DUID_LL)
+ return duid_make(data, ifp, DUID_LL);
}
return len;
}
#define DUID_H
#define DUID_LEN 128 + 2
+#define DUID_DEFAULT 0
#define DUID_LLT 1
#define DUID_LL 3
#define DUID_UUID 4
#include "dhcp.h"
#include "dhcp6.h"
#include "dhcpcd-embedded.h"
+#include "duid.h"
#include "if.h"
#include "if-options.h"
#include "ipv4.h"
{"noarp", no_argument, NULL, 'A'},
{"nobackground", no_argument, NULL, 'B'},
{"nohook", required_argument, NULL, 'C'},
- {"duid", no_argument, NULL, 'D'},
+ {"duid", optional_argument, NULL, 'D'},
{"lastlease", no_argument, NULL, 'E'},
{"fqdn", optional_argument, NULL, 'F'},
{"nogateway", no_argument, NULL, 'G'},
break;
case 'D':
ifo->options |= DHCPCD_CLIENTID | DHCPCD_DUID;
+ if (ifname != NULL) /* duid type only a global option */
+ break;
+ if (arg == NULL)
+ ctx->duid_type = DUID_DEFAULT;
+ else if (strcmp(arg, "ll") == 0)
+ ctx->duid_type = DUID_LL;
+ else if (strcmp(arg, "llt") == 0)
+ ctx->duid_type = DUID_LLT;
+ else if (strcmp(arg, "uuid") == 0)
+ ctx->duid_type = DUID_UUID;
+ else {
+ logwarnx("%s: invalid duid type", arg);
+ ctx->duid_type = DUID_DEFAULT;
+ }
break;
case 'E':
ifo->options |= DHCPCD_LASTLEASE;