Skip to content

Commit

Permalink
Merge pull request #183 from kmroz/dhcp4-extra-options-rc
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Mar 6, 2014
2 parents b2a0465 + a2d0bce commit 29f0f56
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions client/compat.c
Expand Up @@ -1067,13 +1067,28 @@ __ni_compat_generate_dhcp4_addrconf(xml_node_t *ifnode, const ni_compat_netdev_t
if (compat->dhcp4.hostname)
xml_node_dict_set(dhcp, "hostname", compat->dhcp4.hostname);

if (compat->dhcp4.start_delay)
xml_node_dict_set(dhcp, "start-delay",
ni_sprint_timeout(compat->dhcp4.start_delay));

if (compat->dhcp4.acquire_timeout)
xml_node_dict_set(dhcp, "acquire-timeout",
ni_sprint_timeout(compat->dhcp4.acquire_timeout));

if (compat->dhcp4.lease_time)
xml_node_dict_set(dhcp, "lease-time",
ni_sprint_timeout(compat->dhcp4.lease_time));

if (compat->dhcp4.recover_lease)
xml_node_dict_set(dhcp, "recover-lease", "true");
else
xml_node_dict_set(dhcp, "recover-lease", "false");

if (compat->dhcp4.release_lease)
xml_node_dict_set(dhcp, "release-lease", "true");
else
xml_node_dict_set(dhcp, "release-lease", "false");

if (compat->dhcp4.client_id)
xml_node_dict_set(dhcp, "client-id", compat->dhcp4.client_id);

Expand Down
4 changes: 4 additions & 0 deletions dhcp4/dbus-api.c
Expand Up @@ -318,7 +318,11 @@ static ni_dbus_property_t dhcp4_request_properties[] = {
DHCP4REQ_BOOL_PROPERTY(enabled, enabled, RO),
DHCP4REQ_UUID_PROPERTY(uuid, uuid, RO),
DHCP4REQ_UINT_PROPERTY(settle-timeout, settle_timeout, RO),
DHCP4REQ_UINT_PROPERTY(start-delay, start_delay, RO),
DHCP4REQ_UINT_PROPERTY(acquire-timeout, acquire_timeout, RO),
DHCP4REQ_UINT_PROPERTY(lease-time, lease_time, RO),
DHCP4REQ_BOOL_PROPERTY(recover-lease, recover_lease, RO),
DHCP4REQ_BOOL_PROPERTY(release-lease, release_lease, RO),
DHCP4REQ_STRING_PROPERTY(hostname, hostname, RO),
DHCP4REQ_STRING_PROPERTY(client-id, clientid, RO),
DHCP4REQ_STRING_PROPERTY(vendor-class, vendor_class, RO),
Expand Down
6 changes: 6 additions & 0 deletions dhcp4/device.c
Expand Up @@ -262,6 +262,9 @@ ni_dhcp4_acquire(ni_dhcp4_device_t *dev, const ni_dhcp4_request_t *info)
config->uuid = info->uuid;
config->update = info->update;
config->route_priority = info->route_priority;
config->start_delay = info->start_delay;
config->recover_lease = info->recover_lease;
config->release_lease = info->release_lease;

config->max_lease_time = ni_dhcp4_config_max_lease_time();
if (config->max_lease_time == 0)
Expand Down Expand Up @@ -298,11 +301,14 @@ ni_dhcp4_acquire(ni_dhcp4_device_t *dev, const ni_dhcp4_request_t *info)
ni_trace("Received request:");
ni_trace(" acquire-timeout %u", config->request_timeout);
ni_trace(" lease-time %u", config->max_lease_time);
ni_trace(" start-delay %u", config->start_delay);
ni_trace(" hostname %s", config->hostname[0]? config->hostname : "<none>");
ni_trace(" vendor-class %s", config->classid[0]? config->classid : "<none>");
ni_trace(" client-id %s", ni_print_hex(config->client_id.data, config->client_id.len));
ni_trace(" uuid %s", ni_uuid_print(&config->uuid));
ni_trace(" flags %s", __ni_dhcp4_print_flags(config->flags));
ni_trace(" recover_lease %s", config->recover_lease ? "true" : "false");
ni_trace(" release_lease %s", config->release_lease ? "true" : "false");
}

ni_dhcp4_device_set_config(dev, config);
Expand Down
8 changes: 8 additions & 0 deletions dhcp4/dhcp.h
Expand Up @@ -132,6 +132,7 @@ struct ni_dhcp4_request {

ni_dhcp4_run_t dry_run; /* normal run or get offer/lease only */
unsigned int settle_timeout; /* wait that long before starting DHCP4 */
unsigned int start_delay;
unsigned int acquire_timeout;/* how long we try before we give up */

/* Options controlling what to put into the lease request */
Expand All @@ -142,6 +143,9 @@ struct ni_dhcp4_request {

unsigned int route_priority;

ni_bool_t recover_lease;
ni_bool_t release_lease;

/* Options what to update based on the info received from
* the DHCP4 server.
* This is a bitmap; individual bits correspond to
Expand Down Expand Up @@ -169,11 +173,15 @@ struct ni_dhcp4_config {

unsigned int initial_discovery_timeout;
unsigned int request_timeout;
unsigned int start_delay;
unsigned int resend_timeout;
unsigned int max_lease_time;
unsigned int update;

unsigned int route_priority;

ni_bool_t recover_lease;
ni_bool_t release_lease;
};

enum ni_dhcp4_event {
Expand Down
16 changes: 16 additions & 0 deletions dhcp4/tester.c
Expand Up @@ -159,6 +159,22 @@ dhcp4_tester_req_xml_init(ni_dhcp4_request_t *req, xml_document_t *doc)
if (ni_parse_hex(child->cdata, duid.data, sizeof(duid.data)) <= 0)
goto failure;
ni_string_dup(&req->clientid, child->cdata);
} else
if(ni_string_eq(child->name, "start-delay")) {
if (ni_parse_uint(child->cdata, &req->start_delay, 10) != 0)
goto failure;
} else
if (ni_string_eq(child->name, "lease-time")) {
if (ni_parse_uint(child->cdata, &req->lease_time, 10) != 0)
goto failure;
} else
if (ni_string_eq(child->name, "recover-lease")) {
if (ni_parse_boolean(child->cdata, &req->recover_lease) != 0)
goto failure;
} else
if (ni_string_eq(child->name, "release-lease")) {
if (ni_parse_boolean(child->cdata, &req->release_lease) != 0)
goto failure;
}
}

Expand Down
4 changes: 4 additions & 0 deletions schema/addrconf.xml
Expand Up @@ -160,8 +160,12 @@
<client-id type="string" />
<vendor-class type="string" />
<initial-delay type="uint32" />

<start-delay type="uint32" />
<acquire-timeout type="uint32" />
<lease-time type="uint32" />
<recover-lease type="boolean" />
<release-lease type="boolean" />

<update type="builtin-addrconf-update-mask" />
<route-priority type="uint32" />
Expand Down

0 comments on commit 29f0f56

Please sign in to comment.