From ffffbc96cc86a139407683f2f92c90f6ccc6b5cc Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 22 Apr 2013 23:08:21 +0100 Subject: [PATCH] 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. Signed-off-by: Sami Kerola --- src/getdata.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/getdata.c b/src/getdata.c index 1a2e882..38d9e74 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -205,7 +205,7 @@ void parse_config(int is_include, const char *restrict config_file, struct shared_network_t *restrict shared_p) { 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; size_t i = 0; char *word; @@ -268,10 +268,15 @@ void parse_config(int is_include, const char *restrict config_file, break; } if (comment == false + && argument != ITS_A_RANGE_FIRST_IP && argument != ITS_A_RANGE_SECOND_IP && argument != ITS_AN_INCLUCE) { newclause = true; 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) { /* Range ends to ; and this hair in code * 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; parse_ipaddr(word, &addr); 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); range_p->count = 0; range_p->touched = 0;