diff --git a/THANKS b/THANKS index 8c8f80b..1302c03 100644 --- a/THANKS +++ b/THANKS @@ -37,3 +37,4 @@ Tim Cantin Martijn van Brummelen Anton Tkachev Derrick Lin +Ivanov Ivan diff --git a/src/getdata.c b/src/getdata.c index 03a0b13..3e3be1f 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -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;