summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2005-09-02 17:35:35 +0000
committerbrooks <brooks@FreeBSD.org>2005-09-02 17:35:35 +0000
commitd8570c33a37c99e8f8414cfd741dc6d6ecefc631 (patch)
treefd9cfb8ca220d23f7a062e940d890c7944783fd7 /sbin/dhclient/dhclient.c
parent7d67985300c2c4436142f24d31bb457ea524a4fc (diff)
downloadFreeBSD-src-d8570c33a37c99e8f8414cfd741dc6d6ecefc631.zip
FreeBSD-src-d8570c33a37c99e8f8414cfd741dc6d6ecefc631.tar.gz
When we supersed the subnet-mask, write the forced value to the lease
file. This is what the ISC client does. Submitted by: Rostislav Krasny <rosti dot bsd at gmail dot com>
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 5a62c3d..36a6478 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1835,22 +1835,26 @@ void
priv_script_write_params(char *prefix, struct client_lease *lease)
{
struct interface_info *ip = ifi;
- u_int8_t dbuf[1500];
- int i, len = 0;
+ u_int8_t dbuf[1500], *dp = NULL;
+ int i, len;
char tbuf[128];
script_set_env(ip->client, prefix, "ip_address",
piaddr(lease->address));
- if (lease->options[DHO_SUBNET_MASK].len &&
- (lease->options[DHO_SUBNET_MASK].len <
- sizeof(lease->address.iabuf))) {
+ if (ip->client->config->default_actions[DHO_SUBNET_MASK] ==
+ ACTION_SUPERSEDE) {
+ dp = ip->client->config->defaults[DHO_SUBNET_MASK].data;
+ len = ip->client->config->defaults[DHO_SUBNET_MASK].len;
+ } else {
+ dp = lease->options[DHO_SUBNET_MASK].data;
+ len = lease->options[DHO_SUBNET_MASK].len;
+ }
+ if (len && (len < sizeof(lease->address.iabuf))) {
struct iaddr netmask, subnet, broadcast;
- memcpy(netmask.iabuf, lease->options[DHO_SUBNET_MASK].data,
- lease->options[DHO_SUBNET_MASK].len);
- netmask.len = lease->options[DHO_SUBNET_MASK].len;
-
+ memcpy(netmask.iabuf, dp, len);
+ netmask.len = len;
subnet = subnet_number(lease->address, netmask);
if (subnet.len) {
script_set_env(ip->client, prefix, "network_number",
@@ -1871,7 +1875,7 @@ priv_script_write_params(char *prefix, struct client_lease *lease)
script_set_env(ip->client, prefix, "server_name",
lease->server_name);
for (i = 0; i < 256; i++) {
- u_int8_t *dp = NULL;
+ len = 0;
if (ip->client->config->defaults[i].len) {
if (lease->options[i].len) {
OpenPOWER on IntegriCloud