Mercurial > hg > dhcpcd
changeset 1480:0420a2a298f6 draft
-J, --broadcast now sets the broadcast flag in DHCP messages.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 28 Jan 2010 20:12:54 +0000 |
| parents | 91d30380a9c5 |
| children | c208be3a5592 |
| files | dhcp.c dhcpcd.8.in dhcpcd.c dhcpcd.conf.5.in if-options.c if-options.h |
| diffstat | 6 files changed, 42 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcp.c Wed Jan 27 11:51:30 2010 +0000 +++ b/dhcp.c Thu Jan 28 20:12:54 2010 +0000 @@ -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 @@ -863,18 +863,17 @@ switch (iface->family) { case ARPHRD_ETHER: case ARPHRD_IEEE802: - dhcp->hwlen = ETHER_ADDR_LEN; - memcpy(&dhcp->chaddr, &iface->hwaddr, ETHER_ADDR_LEN); - break; - case ARPHRD_IEEE1394: - case ARPHRD_INFINIBAND: - dhcp->hwlen = 0; - if (dhcp->ciaddr == 0 && - type != DHCP_DECLINE && type != DHCP_RELEASE) - dhcp->flags = htons(BROADCAST_FLAG); + dhcp->hwlen = iface->hwlen; + memcpy(&dhcp->chaddr, &iface->hwaddr, iface->hwlen); break; } + if (ifo->options & DHCPCD_BROADCAST && + dhcp->ciaddr == 0 && + type != DHCP_DECLINE && + type != DHCP_RELEASE) + dhcp->flags = htons(BROADCAST_FLAG); + if (type != DHCP_DECLINE && type != DHCP_RELEASE) { if (up < 0 || up > (time_t)UINT16_MAX) dhcp->secs = htons((uint16_t)UINT16_MAX);
--- a/dhcpcd.8.in Wed Jan 27 11:51:30 2010 +0000 +++ b/dhcpcd.8.in Thu Jan 28 20:12:54 2010 +0000 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 14, 2009 +.Dd January 18, 2010 .Dt DHCPCD 8 SMM .Os .Sh NAME @@ -30,7 +30,7 @@ .Nd an RFC 2131 compliant DHCP client .Sh SYNOPSIS .Nm -.Op Fl bdgknpqwABDEGHKLTV +.Op Fl bdgknpqwABDEGHJKLTV .Op Fl c , -script Ar script .Op Fl e , -env Ar value .Op Fl f , -config Ar file @@ -450,6 +450,13 @@ .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 J , -broadcast +Instructs the DHCP server to broadcast replies back to the client. +Normally this is only set for non Ethernet interfaces, +such as FireWire and InfiniBand. +In most instances, +.Nm +will set this automatically. .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
--- a/dhcpcd.c Wed Jan 27 11:51:30 2010 +0000 +++ b/dhcpcd.c Thu Jan 28 20:12:54 2010 +0000 @@ -142,7 +142,7 @@ static void usage(void) { - printf("usage: "PACKAGE" [-dgknpqwxyADEGHKLOTV] [-c script] [-f file]" + printf("usage: "PACKAGE" [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file]" " [-e var=val]\n" " [-h hostname] [-i classID ] [-l leasetime]" " [-m metric] [-o option]\n" @@ -777,6 +777,15 @@ if (iface->hwlen > DHCP_CHADDR_LEN) ifo->options |= DHCPCD_CLIENTID; + /* Firewire and InfiniBand interfaces require ClientID and + * the broadcast option being set. */ + switch (iface->family) { + case ARPHRD_IEEE1394: /* FALLTHROUGH */ + case ARPHRD_INFINIBAND: + ifo->options |= DHCPCD_CLIENTID | DHCPCD_BROADCAST; + break; + } + free(iface->clientid); if (*ifo->clientid) { iface->clientid = xmalloc(ifo->clientid[0] + 1);
--- a/dhcpcd.conf.5.in Wed Jan 27 11:51:30 2010 +0000 +++ b/dhcpcd.conf.5.in Thu Jan 28 20:12:54 2010 +0000 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 14, 2010 +.Dd January 28, 2010 .Dt DHCPCD.CONF 5 SMM .Os .Sh NAME @@ -83,6 +83,13 @@ is ignored if .Ic whitelist is set. +.It Ic broadcast +Instructs the DHCP server to broadcast replies back to the client. +Normally this is only set for non Ethernet interfaces, +such as FireWire and InfiniBand. +In most cases, +.Nm dhcpcd +will set this automatically. .It Ic env Ar value Push .Ar value
--- a/if-options.c Wed Jan 27 11:51:30 2010 +0000 +++ b/if-options.c Thu Jan 28 20:12:54 2010 +0000 @@ -85,6 +85,7 @@ {"nogateway", no_argument, NULL, 'G'}, {"xidhwaddr", no_argument, NULL, 'H'}, {"clientid", optional_argument, NULL, 'I'}, + {"broadcast", no_argument, NULL, 'J'}, {"nolink", no_argument, NULL, 'K'}, {"noipv4ll", no_argument, NULL, 'L'}, {"destination", required_argument, NULL, 'N'}, @@ -587,6 +588,9 @@ ifo->options |= DHCPCD_CLIENTID; ifo->clientid[0] = (uint8_t)s; break; + case 'J': + ifo->options |= DHCPCD_BROADCAST; + break; case 'K': ifo->options &= ~DHCPCD_LINK; break;
--- a/if-options.h Wed Jan 27 11:51:30 2010 +0000 +++ b/if-options.h Thu Jan 28 20:12:54 2010 +0000 @@ -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:GHI: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:JKLN:O:Q:S:TVW:X:Z:" #define DEFAULT_TIMEOUT 30 #define DEFAULT_REBOOT 10 @@ -75,6 +75,7 @@ #define DHCPCD_WAITUP (1 << 26) #define DHCPCD_CSR_WARNED (1 << 27) #define DHCPCD_XID_HWADDR (1 << 28) +#define DHCPCD_BROADCAST (1 << 29) extern const struct option cf_options[];
