[PATCH 1/2] send agent options with bind update
Sytse Wielinga
s.wielinga at lijbrandt-telecom.nl
Fri Jul 10 09:59:26 UTC 2009
---
server/failover.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/server/failover.c b/server/failover.c
index f1283bc..e7d6ec6 100644
--- a/server/failover.c
+++ b/server/failover.c
@@ -4486,6 +4486,8 @@ isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *state,
isc_result_t status;
int flags = 0;
binding_state_t transmit_state;
+ unsigned char request_options[256];
+ int request_options_length = 0;
#if defined (DEBUG_FAILOVER_MESSAGES)
char obuf [64];
unsigned obufix = 0;
@@ -4528,6 +4530,48 @@ isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *state,
lease->last_xid = link->xid++;
+ /* Request options. Only relay agent options are supported
+ * right now. */
+ if (lease -> agent_options) {
+ int agent_options_length = 0;
+ struct option_cache *oc;
+ struct data_string ds;
+ pair p;
+
+ for (p = lease -> agent_options -> first; p; p = p -> cdr) {
+ oc = (struct option_cache *)p -> car;
+ if (!(oc -> data.len))
+ continue;
+ agent_options_length += 2;
+ agent_options_length += oc -> data.len;
+ }
+
+
+ if (agent_options_length > 0 &&
+ agent_options_length < 255 - request_options_length) {
+ memcpy(request_options, DHCP_OPTIONS_COOKIE, 4);
+ request_options_length = 4;
+
+ request_options[request_options_length++] =
+ DHO_DHCP_AGENT_OPTIONS;
+ request_options[request_options_length++] =
+ agent_options_length;
+ for (p = lease -> agent_options -> first; p;
+ p = p -> cdr) {
+ oc = (struct option_cache *)p -> car;
+ if (!(oc -> data.len))
+ continue;
+ request_options[request_options_length++] =
+ oc -> option -> code;
+ request_options[request_options_length++] =
+ oc -> data.len;
+ memcpy(request_options + request_options_length,
+ oc -> data.data, oc -> data.len);
+ request_options_length += oc -> data.len;
+ }
+ }
+ }
+
/* Send the update. */
status = (dhcp_failover_put_message
(link, link -> outer,
@@ -4560,7 +4604,11 @@ isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *state,
flags) :
&skip_failover_option, /* No IP_FLAGS */
&skip_failover_option, /* XXX DDNS */
- &skip_failover_option, /* XXX request options */
+ request_options_length
+ ? dhcp_failover_make_option (FTO_REQUEST_OPTIONS, FMA,
+ request_options_length,
+ request_options)
+ : &skip_failover_option,
&skip_failover_option, /* XXX reply options */
(failover_option_t *)0));
--
1.6.3.3
More information about the dhcp-hackers
mailing list