summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-11-23 18:22:46 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-11-23 18:22:46 +0000
commitc3db7e4f19b4ef410c966f31d0a38eb63b9a741d (patch)
treeb65fab57026948864732f05c963f1ec4711f8286 /sbin/dhclient/dhclient.c
parent3e801e0b3818a976b3e6af9885ff87a48e3b95cc (diff)
Rename discover_interface() to more meaningful get_hw_address().
Hoist one-time initialization of client identifier out of get_hw_address() to the one-time initialization code in main(). No intentional functional change.
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 03d1bb20c73..8fc644324f3 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.333 2014/11/20 19:27:28 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.334 2014/11/23 18:22:45 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -327,7 +327,7 @@ routehandler(void)
}
memcpy(&hw, &ifi->hw_address, sizeof(hw));
- discover_interface();
+ get_hw_address();
if (memcmp(&hw, &ifi->hw_address, sizeof(hw))) {
warning("LLADDR changed; restarting");
ifi->flags |= IFI_NEW_LLADDR;
@@ -398,6 +398,7 @@ main(int argc, char *argv[])
int ch, fd, i = 0, socket_fd[2];
extern char *__progname;
struct passwd *pw;
+ struct option_data *opt;
char *ignore_list = NULL;
ssize_t tailn;
int rtfilter, tailfd;
@@ -525,8 +526,24 @@ main(int argc, char *argv[])
if ((pw = getpwnam("_dhcp")) == NULL)
error("no such user: _dhcp");
- /* set up the interface */
- discover_interface();
+ get_hw_address();
+ opt = &config->send_options[DHO_DHCP_CLIENT_IDENTIFIER];
+ /*
+ * Check both len && data so
+ * send dhcp-client-identifier "";
+ * can be used to suppress sending the default client
+ * identifier.
+ */
+ if (opt->len == 0 && opt->data == NULL) {
+ /* Build default client identifier. */
+ opt->data = calloc(1, ETHER_ADDR_LEN + 1);
+ if (opt->data != NULL) {
+ opt->data[0] = HTYPE_ETHER;
+ memcpy(&opt->data[1], ifi->hw_address.ether_addr_octet,
+ ETHER_ADDR_LEN);
+ opt->len = ETHER_ADDR_LEN + 1;
+ }
+ }
/* Register the interface. */
if_register_receive();