Blame SOURCES/dhcp-4.2.5-next-server.patch

54343e
From f113ad7822fcd691e72f61cab7412595951222db Mon Sep 17 00:00:00 2001
54343e
From: Tomas Hozza <thozza@redhat.com>
54343e
Date: Wed, 3 Apr 2013 10:20:18 +0200
54343e
Subject: [PATCH] Expose next-server DHCPv4 option to dhclient script
54343e
54343e
Currently dhclient does not exposes next-server option
54343e
to the dhclient script. this patch fixes this.
54343e
54343e
Signed-off-by: Tomas Hozza <thozza@redhat.com>
54343e
---
54343e
 client/dhclient.c | 14 +++++++++++---
54343e
 includes/dhcpd.h  |  2 +-
54343e
 2 files changed, 12 insertions(+), 4 deletions(-)
54343e
54343e
diff --git a/client/dhclient.c b/client/dhclient.c
54343e
index 551ccbf..e8df320 100644
54343e
--- a/client/dhclient.c
54343e
+++ b/client/dhclient.c
54343e
@@ -993,7 +993,7 @@ void state_selecting (cpp)
54343e
 		client -> state = S_REQUESTING;
54343e
 
54343e
 		/* Bind to the address we received. */
54343e
-		bind_lease (client);
54343e
+		bind_lease (client, NULL);
54343e
 		return;
54343e
 	}
54343e
 
54343e
@@ -1183,11 +1183,12 @@ void dhcpack (packet)
54343e
 	if (client -> new -> rebind < cur_time)
54343e
 		client -> new -> rebind = TIME_MAX;
54343e
 
54343e
-	bind_lease (client);
54343e
+	bind_lease (client, &packet -> raw -> siaddr);
54343e
 }
54343e
 
54343e
-void bind_lease (client)
54343e
+void bind_lease (client, siaddr)
54343e
 	struct client_state *client;
54343e
+	struct in_addr *siaddr;
54343e
 {
54343e
 	struct timeval tv;
54343e
 
54343e
@@ -1209,6 +1210,13 @@ void bind_lease (client)
54343e
 	if (client -> alias)
54343e
 		script_write_params (client, "alias_", client -> alias);
54343e
 
54343e
+	if (siaddr) {
54343e
+		char buf[INET_ADDRSTRLEN];
54343e
+
54343e
+		if (inet_ntop (AF_INET, (void *) siaddr, buf, sizeof (buf)))
54343e
+			client_envadd (client, "new_", "next_server", "%s", buf);
54343e
+	}
54343e
+
54343e
 	/* If the BOUND/RENEW code detects another machine using the
54343e
 	   offered address, it exits nonzero.  We need to send a
54343e
 	   DHCPDECLINE and toss the lease. */
54343e
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
54343e
index 12ed2ba..4e93e68 100644
54343e
--- a/includes/dhcpd.h
54343e
+++ b/includes/dhcpd.h
54343e
@@ -2712,7 +2712,7 @@ void state_bound (void *);
54343e
 void state_stop (void *);
54343e
 void state_panic (void *);
54343e
 
54343e
-void bind_lease (struct client_state *);
54343e
+void bind_lease (struct client_state *, struct in_addr *);
54343e
 
54343e
 void make_client_options (struct client_state *,
54343e
 			  struct client_lease *, u_int8_t *,
54343e
-- 
54343e
1.8.1.4
54343e