On Fri, 08 Apr 2011 02:31:49 +0200, Christoph Viethen <christoph.viethen@xxxxxxxxxxxxxx> wrote:
+ uint32_t lower_bounds_value; + uint32_t upper_bounds_value; + uint64_t num_bounds_ips; + uint32_t old_ip_value, new_ip_value;
These can be const.
+ /* determine number of IPs that fit within bounds */+ lower_bounds_value = ((lower_bound->x[0] * 256 + lower_bound->x[1]) * 256 + lower_bound->x[2]) * 256 + lower_bound->x[3]; + upper_bounds_value = ((upper_bound->x[0] * 256 + upper_bound->x[1]) * 256 + upper_bound->x[2]) * 256 + upper_bound->x[3];+ num_bounds_ips = upper_bounds_value - lower_bounds_value + 1; + + /* convert the input IP into a numerical value */+ old_ip_value = ((ip->x[0] * 256 + ip->x[1]) * 256 + ip->x[2]) * 256 + ip->x[3];
Bit shifts are probably more readable.