mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-28 04:25:19 +08:00
-H, --xidhwaddr will use the last four bytes of the hardware address
as the xid instead of generating a random number. Thanks to Aurelien.
This commit is contained in:
parent
0ce75ba4e2
commit
4242c9b3dd
@ -1,4 +1,4 @@
|
||||
.\" Copyright (c) 2006-2009 Roy Marples
|
||||
.\" Copyright (c) 2006-2010 Roy Marples
|
||||
.\" All rights reserved
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd October 25, 2009
|
||||
.Dd January 14, 2009
|
||||
.Dt DHCPCD 8 SMM
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -30,7 +30,7 @@
|
||||
.Nd an RFC 2131 compliant DHCP client
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl bdgknpqwABDEGKLTV
|
||||
.Op Fl bdgknpqwABDEGHKLTV
|
||||
.Op Fl c , -script Ar script
|
||||
.Op Fl e , -env Ar value
|
||||
.Op Fl f , -config Ar file
|
||||
@ -447,6 +447,9 @@ from touching your DNS or MTU settings you would do:-
|
||||
.D1 dhcpcd -C resolv.conf -C mtu eth0
|
||||
.It Fl G , -nogateway
|
||||
Don't set any default routes.
|
||||
.It Fl H , -xidhwaddr
|
||||
Use the last four bytes of the hardware address as the DHCP xid instead
|
||||
of a randomly generated number.
|
||||
.It Fl K , -nolink
|
||||
Don't receive link messages for carrier status.
|
||||
You should only have to use this with buggy device drivers or running
|
||||
|
32
dhcpcd.c
32
dhcpcd.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
* Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
|
||||
* All rights reserved
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -25,7 +25,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const char copyright[] = "Copyright (c) 2006-2009 Roy Marples";
|
||||
const char copyright[] = "Copyright (c) 2006-2010 Roy Marples";
|
||||
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
@ -271,6 +271,22 @@ stop_interface(struct interface *iface)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
dhcp_xid(struct interface *iface)
|
||||
{
|
||||
uint32_t xid;
|
||||
|
||||
if (iface->state->options->options & DHCPCD_XID_HWADDR &&
|
||||
iface->hwlen >= sizeof(xid))
|
||||
/* The lower bits are probably more unique on the network */
|
||||
memcpy(&xid, (iface->hwaddr + iface->hwlen) - sizeof(xid),
|
||||
sizeof(xid));
|
||||
else
|
||||
xid = arc4random();
|
||||
|
||||
return xid;
|
||||
}
|
||||
|
||||
static void
|
||||
send_message(struct interface *iface, int type,
|
||||
void (*callback)(void *))
|
||||
@ -717,7 +733,7 @@ send_release(struct interface *iface)
|
||||
syslog(LOG_INFO, "%s: releasing lease of %s",
|
||||
iface->name, inet_ntoa(iface->state->lease.addr));
|
||||
open_sockets(iface);
|
||||
iface->state->xid = arc4random();
|
||||
iface->state->xid = dhcp_xid(iface);
|
||||
send_message(iface, DHCP_RELEASE, NULL);
|
||||
/* Give the packet a chance to go before dropping the ip */
|
||||
ts.tv_sec = RELEASE_DELAY_S;
|
||||
@ -886,7 +902,7 @@ start_discover(void *arg)
|
||||
struct if_options *ifo = iface->state->options;
|
||||
|
||||
iface->state->state = DHS_DISCOVER;
|
||||
iface->state->xid = arc4random();
|
||||
iface->state->xid = dhcp_xid(iface);
|
||||
open_sockets(iface);
|
||||
delete_timeout(NULL, iface);
|
||||
if (ifo->fallback)
|
||||
@ -920,7 +936,7 @@ start_renew(void *arg)
|
||||
syslog(LOG_INFO, "%s: renewing lease of %s",
|
||||
iface->name, inet_ntoa(iface->state->lease.addr));
|
||||
iface->state->state = DHS_RENEW;
|
||||
iface->state->xid = arc4random();
|
||||
iface->state->xid = dhcp_xid(iface);
|
||||
open_sockets(iface);
|
||||
send_renew(iface);
|
||||
}
|
||||
@ -1020,7 +1036,7 @@ start_inform(struct interface *iface)
|
||||
}
|
||||
|
||||
iface->state->state = DHS_INFORM;
|
||||
iface->state->xid = arc4random();
|
||||
iface->state->xid = dhcp_xid(iface);
|
||||
open_sockets(iface);
|
||||
send_inform(iface);
|
||||
}
|
||||
@ -1058,7 +1074,7 @@ start_reboot(struct interface *iface)
|
||||
iface->name, inet_ntoa(iface->state->lease.addr));
|
||||
}
|
||||
iface->state->state = DHS_REBOOT;
|
||||
iface->state->xid = arc4random();
|
||||
iface->state->xid = dhcp_xid(iface);
|
||||
iface->state->lease.server.s_addr = 0;
|
||||
delete_timeout(NULL, iface);
|
||||
if (ifo->fallback)
|
||||
@ -1302,7 +1318,7 @@ handle_ifa(int type, const char *ifname,
|
||||
run_script(ifp);
|
||||
if (ifo->options & DHCPCD_INFORM) {
|
||||
ifp->state->state = DHS_INFORM;
|
||||
ifp->state->xid = arc4random();
|
||||
ifp->state->xid = dhcp_xid(ifp);
|
||||
ifp->state->lease.server.s_addr =
|
||||
dst ? dst->s_addr : INADDR_ANY;
|
||||
ifp->addr = *addr;
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" Copyright (c) 2006-2009 Roy Marples
|
||||
.\" Copyright (c) 2006-2010 Roy Marples
|
||||
.\" All rights reserved
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd October 16, 2009
|
||||
.Dd January 14, 2010
|
||||
.Dt DHCPCD.CONF 5 SMM
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -274,6 +274,9 @@ Change the default vendorclassid sent from dhcpcd-version.
|
||||
If not set then none is sent.
|
||||
.It Ic waitip
|
||||
Wait for an address to be assigned before forking to the background.
|
||||
.It Ic xidhwaddr
|
||||
Use the last four bytes of the hardware address as the DHCP xid instead
|
||||
of a randomly generated number.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dhcpcd-run-hooks 8 ,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
* Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
|
||||
* All rights reserved
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -83,6 +83,7 @@ const struct option cf_options[] = {
|
||||
{"lastlease", no_argument, NULL, 'E'},
|
||||
{"fqdn", optional_argument, NULL, 'F'},
|
||||
{"nogateway", no_argument, NULL, 'G'},
|
||||
{"xidhwaddr", no_argument, NULL, 'H'},
|
||||
{"clientid", optional_argument, NULL, 'I'},
|
||||
{"nolink", no_argument, NULL, 'K'},
|
||||
{"noipv4ll", no_argument, NULL, 'L'},
|
||||
@ -568,6 +569,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
|
||||
case 'G':
|
||||
ifo->options &= ~DHCPCD_GATEWAY;
|
||||
break;
|
||||
case 'H':
|
||||
ifo->options |= DHCPCD_XID_HWADDR;
|
||||
break;
|
||||
case 'I':
|
||||
/* Strings have a type of 0 */;
|
||||
ifo->clientid[1] = 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
* Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
|
||||
* All rights reserved
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
/* Don't set any optional arguments here so we retain POSIX
|
||||
* compatibility with getopt */
|
||||
#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GI:KLN:O:Q:S:TVW:X:Z:"
|
||||
#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:KLN:O:Q:S:TVW:X:Z:"
|
||||
|
||||
#define DEFAULT_TIMEOUT 30
|
||||
#define DEFAULT_REBOOT 10
|
||||
@ -74,6 +74,7 @@
|
||||
#define DHCPCD_WAITIP (1 << 25)
|
||||
#define DHCPCD_WAITUP (1 << 26)
|
||||
#define DHCPCD_CSR_WARNED (1 << 27)
|
||||
#define DHCPCD_XID_HWADDR (1 << 28)
|
||||
|
||||
extern const struct option cf_options[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user