mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Fix dhcp-name-match to function when name supplied in --dhcp-host.
This commit is contained in:
@@ -54,6 +54,10 @@ version 2.81
|
|||||||
identifier option (option 61), so clients are only identified by
|
identifier option (option 61), so clients are only identified by
|
||||||
MAC addresses.
|
MAC addresses.
|
||||||
|
|
||||||
|
Fix a bug which stopped --dhcp-name-match from working when a hostname
|
||||||
|
is supplied in --dhcp-host. Thanks to James Feeney for spotting this.
|
||||||
|
|
||||||
|
|
||||||
version 2.80
|
version 2.80
|
||||||
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
||||||
for the initial patch and motivation.
|
for the initial patch and motivation.
|
||||||
|
|||||||
@@ -740,12 +740,9 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
}
|
}
|
||||||
else if (client_hostname)
|
else if (client_hostname)
|
||||||
{
|
{
|
||||||
struct dhcp_match_name *m;
|
|
||||||
size_t nl;
|
|
||||||
|
|
||||||
domain = strip_hostname(client_hostname);
|
domain = strip_hostname(client_hostname);
|
||||||
|
|
||||||
if ((nl = strlen(client_hostname)) != 0)
|
if (strlen(client_hostname) != 0)
|
||||||
{
|
{
|
||||||
hostname = client_hostname;
|
hostname = client_hostname;
|
||||||
|
|
||||||
@@ -766,6 +763,13 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
netid = &known_id;
|
netid = &known_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostname)
|
||||||
|
{
|
||||||
|
struct dhcp_match_name *m;
|
||||||
|
size_t nl = strlen(hostname);
|
||||||
|
|
||||||
for (m = daemon->dhcp_name_match; m; m = m->next)
|
for (m = daemon->dhcp_name_match; m; m = m->next)
|
||||||
{
|
{
|
||||||
@@ -776,11 +780,11 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
continue;
|
continue;
|
||||||
if (nl > ml)
|
if (nl > ml)
|
||||||
{
|
{
|
||||||
save = client_hostname[ml];
|
save = hostname[ml];
|
||||||
client_hostname[ml] = 0;
|
hostname[ml] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostname_isequal(client_hostname, m->name) &&
|
if (hostname_isequal(hostname, m->name) &&
|
||||||
(save == 0 || m->wildcard))
|
(save == 0 || m->wildcard))
|
||||||
{
|
{
|
||||||
m->netid->next = netid;
|
m->netid->next = netid;
|
||||||
@@ -788,8 +792,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (save != 0)
|
if (save != 0)
|
||||||
client_hostname[ml] = save;
|
hostname[ml] = save;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -508,11 +508,9 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->clid)
|
if (state->clid &&
|
||||||
{
|
(config = find_config(daemon->dhcp_conf, state->context, state->clid, state->clid_len, state->mac, state->mac_len, state->mac_type, NULL)) &&
|
||||||
config = find_config(daemon->dhcp_conf, state->context, state->clid, state->clid_len, state->mac, state->mac_len, state->mac_type, NULL);
|
have_config(config, CONFIG_NAME))
|
||||||
|
|
||||||
if (have_config(config, CONFIG_NAME))
|
|
||||||
{
|
{
|
||||||
state->hostname = config->hostname;
|
state->hostname = config->hostname;
|
||||||
state->domain = config->domain;
|
state->domain = config->domain;
|
||||||
@@ -520,11 +518,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
}
|
}
|
||||||
else if (state->client_hostname)
|
else if (state->client_hostname)
|
||||||
{
|
{
|
||||||
struct dhcp_match_name *m;
|
|
||||||
size_t nl;
|
|
||||||
|
|
||||||
state->domain = strip_hostname(state->client_hostname);
|
state->domain = strip_hostname(state->client_hostname);
|
||||||
nl = strlen(state->client_hostname);
|
|
||||||
|
|
||||||
if (strlen(state->client_hostname) != 0)
|
if (strlen(state->client_hostname) != 0)
|
||||||
{
|
{
|
||||||
@@ -539,6 +533,13 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
if (new && !have_config(new, CONFIG_CLID) && !new->hwaddr)
|
if (new && !have_config(new, CONFIG_CLID) && !new->hwaddr)
|
||||||
config = new;
|
config = new;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state->hostname)
|
||||||
|
{
|
||||||
|
struct dhcp_match_name *m;
|
||||||
|
size_t nl = strlen(state->hostname);
|
||||||
|
|
||||||
for (m = daemon->dhcp_name_match; m; m = m->next)
|
for (m = daemon->dhcp_name_match; m; m = m->next)
|
||||||
{
|
{
|
||||||
@@ -549,11 +550,11 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
continue;
|
continue;
|
||||||
if (nl > ml)
|
if (nl > ml)
|
||||||
{
|
{
|
||||||
save = state->client_hostname[ml];
|
save = state->hostname[ml];
|
||||||
state->client_hostname[ml] = 0;
|
state->hostname[ml] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostname_isequal(state->client_hostname, m->name) &&
|
if (hostname_isequal(state->hostname, m->name) &&
|
||||||
(save == 0 || m->wildcard))
|
(save == 0 || m->wildcard))
|
||||||
{
|
{
|
||||||
m->netid->next = state->tags;
|
m->netid->next = state->tags;
|
||||||
@@ -561,9 +562,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (save != 0)
|
if (save != 0)
|
||||||
state->client_hostname[ml] = save;
|
state->hostname[ml] = save;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user