From: Roy Marples Date: Thu, 28 Jan 2010 20:12:54 +0000 (+0000) Subject: -J, --broadcast now sets the broadcast flag in DHCP messages. X-Git-Tag: v5.1.5~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=900b3da40ee638f1bd99db31b8656c634a457267;p=thirdparty%2Fdhcpcd.git -J, --broadcast now sets the broadcast flag in DHCP messages. --- diff --git a/dhcp.c b/dhcp.c index 3f7c04c8..2c0c4a13 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * 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 @@ -863,18 +863,17 @@ make_message(struct dhcp_message **message, 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); diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 43c6e929..3ab00577 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -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 @@ 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 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 diff --git a/dhcpcd.c b/dhcpcd.c index 1e402f04..f37c8017 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -142,7 +142,7 @@ read_pid(void) 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 @@ configure_interface1(struct interface *iface) 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); diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in index 475e6036..2b0ab818 100644 --- a/dhcpcd.conf.5.in +++ b/dhcpcd.conf.5.in @@ -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 @@ Only accept packets from 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 diff --git a/if-options.c b/if-options.c index 27d603ab..bf318b94 100644 --- a/if-options.c +++ b/if-options.c @@ -85,6 +85,7 @@ const struct option cf_options[] = { {"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 @@ parse_option(struct if_options *ifo, int opt, const char *arg) 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; diff --git a/if-options.h b/if-options.h index adece9f4..1a368718 100644 --- a/if-options.h +++ b/if-options.h @@ -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[];