philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

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

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