philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-dhclient_ipv6_prefix.patch

45d60a
diff --git a/client/dhc6.c b/client/dhc6.c
45d60a
index 47bf0a2..6f12a86 100644
45d60a
--- a/client/dhc6.c
45d60a
+++ b/client/dhc6.c
45d60a
@@ -120,6 +120,7 @@ static int check_timing6(struct client_state *client, u_int8_t msg_type,
45d60a
 
45d60a
 extern int onetry;
45d60a
 extern int stateless;
45d60a
+extern int address_prefix_len;
45d60a
 
45d60a
 /*
45d60a
  * The "best" default DUID, since we cannot predict any information
45d60a
@@ -3968,7 +3969,7 @@ dhc6_marshall_values(const char *prefix, struct client_state *client,
45d60a
 			 * some suspect this may not be permanent.
45d60a
 			 */
45d60a
 			client_envadd(client, prefix, "ip6_prefixlen",
45d60a
-				      "%d", 64);
45d60a
+				      "%d", address_prefix_len);
45d60a
 			client_envadd(client, prefix, "ip6_address",
45d60a
 				      "%s", piaddr(addr->address));
45d60a
 		}
45d60a
diff --git a/client/dhclient.c b/client/dhclient.c
45d60a
index f9d0493..d1ab473 100644
45d60a
--- a/client/dhclient.c
45d60a
+++ b/client/dhclient.c
45d60a
@@ -106,6 +106,7 @@ int wanted_ia_na = -1;		/* the absolute value is the real one. */
45d60a
 int wanted_ia_ta = 0;
45d60a
 int wanted_ia_pd = 0;
45d60a
 char *mockup_relay = NULL;
45d60a
+int address_prefix_len = DHCLIENT_DEFAULT_PREFIX_LEN;
45d60a
 int bootp_broadcast_always = 0;
45d60a
 
45d60a
 extern struct option *default_requested_options[];
45d60a
@@ -288,6 +289,15 @@ main(int argc, char **argv) {
45d60a
 			tmp->next = client_env;
45d60a
 			client_env = tmp;
45d60a
 			client_env_count++;
45d60a
+		} else if (!strcmp(argv[i], "--address-prefix-len")) {
45d60a
+			if (++i == argc) {
45d60a
+				usage();
45d60a
+			}
45d60a
+			errno = 0;
45d60a
+			address_prefix_len = (int)strtol(argv[i], &s, 10);
45d60a
+			if (errno || (*s != '\0') ||
45d60a
+			    (address_prefix_len < 0)) {
45d60a
+				usage();			}
45d60a
 #ifdef DHCPv6
45d60a
 		} else if (!strcmp(argv[i], "-S")) {
45d60a
 			if (local_family_set && (local_family == AF_INET)) {
45d60a
@@ -1127,6 +1137,7 @@ static void usage()
45d60a
 		  "[-4|-6] [-SNTPI1dvrxc] [-nw] [-p <port>] [-D LL|LLT] \n"
45d60a
 #else /* DHCPv6 */
45d60a
 		  "[-C1dvrxc] [-nw] [-p <port>] [-D LL|LLT] \n"
45d60a
+                  "                [--address-prefix-len length]\n"
45d60a
 #endif /* DHCPv6 */
45d60a
 		  "                [-s server-addr] [-cf config-file] "
45d60a
 		  "[-lf lease-file]\n"
45d60a
diff --git a/includes/site.h b/includes/site.h
45d60a
index 1c7ec96..c87cfe9 100644
45d60a
--- a/includes/site.h
45d60a
+++ b/includes/site.h
45d60a
@@ -295,3 +295,12 @@
45d60a
    up. */
45d60a
 #define DDNS_UPDATE_SLOW_TRANSITION
45d60a
    
45d60a
+/* Define the default prefix length passed from the client to
45d60a
+   the script when modifying an IPv6 IA_NA or IA_TA address.
45d60a
+   The two most useful values are 128 which is what the current
45d60a
+   specifications call for or 64 which is what has been used in
45d60a
+   the past.  For most OSes 128 will indicate that the address
45d60a
+   is a host address and doesn't include any on-link information.
45d60a
+   64 indicates that the first 64 bits are the subnet or on-link
45d60a
+   prefix. */
45d60a
+#define DHCLIENT_DEFAULT_PREFIX_LEN 128