/** * Calculate the number of hosts covered by the ranges in the database. * * @param db the IP range database * * @return The number of IPv4 hosts listed. */ unsigned iprange_get_host_count4(const struct iprange_db *idb) { size_t i, n; unsigned hosts = 0; n = sorted_array_size(idb->tab4); for (i = 0; i < n; i++) { struct iprange_net4 *item = sorted_array_item(idb->tab4, i); hosts += 1 << item->bits; } return hosts; }
/** * Get the number of IPv6 ranges in the database. * * @param db the IP range database * * @return The total number of IPv6 items. */ unsigned iprange_get_item_count6(const struct iprange_db *idb) { iprange_db_check(idb); return sorted_array_size(idb->tab6); }
/** * Get the number of ranges in the database. * * @param db the IP range database * @return The number of items. */ guint iprange_get_item_count(const struct iprange_db *idb) { iprange_db_check(idb); return sorted_array_size(idb->tab); }