]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
-J, --broadcast now sets the broadcast flag in DHCP messages.
authorRoy Marples <roy@marples.name>
Thu, 28 Jan 2010 20:12:54 +0000 (20:12 +0000)
committerRoy Marples <roy@marples.name>
Thu, 28 Jan 2010 20:12:54 +0000 (20:12 +0000)
dhcp.c
dhcpcd.8.in
dhcpcd.c
dhcpcd.conf.5.in
if-options.c
if-options.h

diff --git a/dhcp.c b/dhcp.c
index 3f7c04c8e6fcce01c90e5aacfe4a8d144264a962..2c0c4a138165379136a6509143e4c3a2aacd88a0 100644 (file)
--- a/dhcp.c
+++ b/dhcp.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
@@ -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);
index 43c6e929778a5b616825bb2749e7cf82f4f42471..3ab005777ca8900ecd1c5f0e3c9987ae63ea2d75 100644 (file)
@@ -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
index 1e402f042a87b15ad9811b879f4b250d55898fba..f37c801705b73746651c613ea3b9681b0ef44656 100644 (file)
--- 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);
index 475e603646c9da8d65ca9e99c5bd026bb2f6a8d6..2b0ab818c9a04d4e965fb5237f21a19994f79c1a 100644 (file)
@@ -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
index 27d603ab373564adb97f04932da503a7b60ef936..bf318b9469c3ff24c4c30cda328616228dde9b06 100644 (file)
@@ -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;
index adece9f44e62606b1a8bfd27e9a3b4d3a6422282..1a368718d8aa73b3a8cc01d16f7f61d9a6370192 100644 (file)
@@ -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[];