mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
getdata: flip ranges if they are in greater smaller order
Apparently ISC dhcpd allows marking ranges in order from greater IP to smaller. In these cases first and last IPs are fliped, so that the rest of the processing can be done without alterations. Reported-by: Ivanov Ivan <mgfnv9@gmail.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
3d0c510475
commit
10b06d88f0
2 changed files with 15 additions and 0 deletions
1
THANKS
1
THANKS
|
|
@ -37,3 +37,4 @@ Tim Cantin
|
|||
Martijn van Brummelen
|
||||
Anton Tkachev
|
||||
Derrick Lin
|
||||
Ivanov Ivan
|
||||
|
|
|
|||
|
|
@ -163,6 +163,19 @@ static int is_interesting_config_clause(char const *restrict s)
|
|||
return ITS_NOTHING_INTERESTING;
|
||||
}
|
||||
|
||||
/*! \brief Flip first and last IP in range if they are in unusual order.
|
||||
*/
|
||||
void reorder_last_first(struct range_t *range_p)
|
||||
{
|
||||
if (ipcomp(&range_p->first_ip, &range_p->last_ip) > 0) {
|
||||
union ipaddr_t tmp;
|
||||
|
||||
tmp = range_p->first_ip;
|
||||
range_p->first_ip = range_p->last_ip;
|
||||
range_p->last_ip = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief The dhcpd.conf file parser.
|
||||
* FIXME: This spaghetti monster function need to be rewrote at least
|
||||
* ones.
|
||||
|
|
@ -334,6 +347,7 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
copy_ipaddr(&range_p->first_ip, &addr);
|
||||
}
|
||||
copy_ipaddr(&range_p->last_ip, &addr);
|
||||
reorder_last_first(range_p);
|
||||
newrange:
|
||||
range_p->count = 0;
|
||||
range_p->touched = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue