getdata: make single address ranges work

The dhcpd.conf can contain single IP range definitions, such as

range 10.20.30.40;

and they must be understood similar way as the range definiton would have
two IP's that are the same IP, e.g.,

range 10.20.30.40 10.20.30.40;

Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-04-22 23:08:21 +01:00
parent b24fc42ec8
commit ffffbc96cc

View file

@ -205,7 +205,7 @@ void parse_config(int is_include, const char *restrict config_file,
struct shared_network_t *restrict shared_p) struct shared_network_t *restrict shared_p)
{ {
FILE *dhcpd_config; FILE *dhcpd_config;
bool newclause = true, comment = false; bool newclause = true, comment = false, one_ip_range = false;
int quote = 0, braces = 0, argument = ITS_NOTHING_INTERESTING; int quote = 0, braces = 0, argument = ITS_NOTHING_INTERESTING;
size_t i = 0; size_t i = 0;
char *word; char *word;
@ -268,10 +268,15 @@ void parse_config(int is_include, const char *restrict config_file,
break; break;
} }
if (comment == false if (comment == false
&& argument != ITS_A_RANGE_FIRST_IP
&& argument != ITS_A_RANGE_SECOND_IP && argument != ITS_A_RANGE_SECOND_IP
&& argument != ITS_AN_INCLUCE) { && argument != ITS_AN_INCLUCE) {
newclause = true; newclause = true;
i = 0; i = 0;
} else if (argument == ITS_A_RANGE_FIRST_IP) {
one_ip_range = true;
argument = ITS_A_RANGE_SECOND_IP;
c = ' ';
} else if (argument == ITS_A_RANGE_SECOND_IP) { } else if (argument == ITS_A_RANGE_SECOND_IP) {
/* Range ends to ; and this hair in code /* Range ends to ; and this hair in code
* make two ranges wrote together like... * make two ranges wrote together like...
@ -368,6 +373,10 @@ void parse_config(int is_include, const char *restrict config_file,
range_p = ranges + num_ranges; range_p = ranges + num_ranges;
parse_ipaddr(word, &addr); parse_ipaddr(word, &addr);
argument = ITS_NOTHING_INTERESTING; argument = ITS_NOTHING_INTERESTING;
if (one_ip_range == true) {
one_ip_range = false;
copy_ipaddr(&range_p->first_ip, &addr);
}
copy_ipaddr(&range_p->last_ip, &addr); copy_ipaddr(&range_p->last_ip, &addr);
range_p->count = 0; range_p->count = 0;
range_p->touched = 0; range_p->touched = 0;