Bind address for OMAPI listener

Robin Breathe robin-dhcp at isometry.net
Fri Jun 25 14:33:21 UTC 2004


Hi,
I'm trying to add a configuration parameter, omapi-address, with which 
to set the bind address for the OMAPI listener (currently INADDR_ANY, 
unless I'm mistaken).

I think that I've managed to patch all the code needed to get the 
configuration parameter read (diff attached).

Now I'm not sure how best to route the address through the 
omapi_listener_start() -> omapi_protocol_listen() -> omapi_listen() -> 
omapi_listen_addr() chain, as some of these functions are called 
elsewhere (e.g. in the failover code). Adding additional parameters to 
omapi_protocol_listen() through omapi_listen() seems sensible, but I'd 
like the opinion of others as to whether this is wise.

Obviously once this patch is complete, I'd like to see it integrated, so 
any style bugs or suggestions are also gratefully received.

Regards,
- Robin
-- 
Robin Breathe  /  robin at isometry.net  /  +44-1865-741800


-- Attached file included as plaintext by Ecartis --
-- File: omapi_address.diff

diff -ru ../dhcp-3.0.1rc14/includes/dhcpd.h ./includes/dhcpd.h
--- ../dhcp-3.0.1rc14/includes/dhcpd.h	Thu Jun 10 18:59:29 2004
+++ ./includes/dhcpd.h	Thu Jun 24 14:24:52 2004
@@ -412,6 +412,7 @@
 #define SV_LOG_FACILITY			44
 #define SV_DO_FORWARD_UPDATES		45
 #define SV_PING_TIMEOUT         46
+#define SV_OMAPI_ADDRESS		47
 
 #if !defined (DEFAULT_PING_TIMEOUT)
 # define DEFAULT_PING_TIMEOUT 1
@@ -718,6 +719,7 @@
 	int omapi_port;			/* port on which to accept OMAPI
 					   connections, or -1 for no
 					   listener. */
+	struct in_addr omapi_address;	/* address upon which to bind the OMAPI listener */
 	int do_forward_update;		/* If nonzero, and if we have the
 					   information we need, update the
 					   A record for the address we get. */
diff -ru ../dhcp-3.0.1rc14/server/dhcpd.c ./server/dhcpd.c
--- ../dhcp-3.0.1rc14/server/dhcpd.c	Thu Jun 10 18:59:52 2004
+++ ./server/dhcpd.c	Thu Jun 24 13:30:56 2004
@@ -811,6 +811,21 @@
 		}
 	}
 
+	oc = lookup_option (&server_universe, options,
+				SV_OMAPI_ADDRESS);
+	if (oc &&
+		evaluate_option_cache (&db, (struct packet *)0,
+				   (struct lease *)0, (struct client_state *)0,
+				   options, (struct option_state *)0,
+				   &global_scope, oc, MDL)) {
+		if (db.len == 4) {
+			memcpy (&omapi_address, db.data, 4);
+		} else
+			log_fatal ("invalid remote port data length");
+		data_string_forget (&db, MDL);
+	}
+
+
 	/* Don't need the options anymore. */
 	option_state_dereference (&options, MDL);
 	
diff -ru ../dhcp-3.0.1rc14/server/stables.c ./server/stables.c
--- ../dhcp-3.0.1rc14/server/stables.c	Thu Jun 10 18:59:58 2004
+++ ./server/stables.c	Thu Jun 24 14:21:25 2004
@@ -483,7 +483,7 @@
 	{ "log-facility", "Nsyslog-facilities.",	&server_universe, 44 },
 	{ "do-forward-updates", "f",			&server_universe, 45 },
 	{ "ping-timeout", "T",				&server_universe, 46 },
-	{ "unknown-47", "X",				&server_universe, 47 },
+	{ "omapi-address", "I",				&server_universe, 47 },
 	{ "unknown-48", "X",				&server_universe, 48 },
 	{ "unknown-49", "X",				&server_universe, 49 },
 	{ "unknown-50", "X",				&server_universe, 50 },





More information about the dhcp-hackers mailing list