mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-11-23 13:22:36 +01:00
Aligned code correctly
This commit is contained in:
parent
1c5484c3d9
commit
04791d5868
@ -1114,39 +1114,39 @@ void subnet_vectors_allocator(prefix_t* prefix, void* data) {
|
|||||||
|
|
||||||
subnet_counter_t zero_map_element{};
|
subnet_counter_t zero_map_element{};
|
||||||
|
|
||||||
for (int i = 0; i < network_size_in_ips; i++) {
|
for (int i = 0; i < network_size_in_ips; i++) {
|
||||||
// We need to increment IP address by X but we have to do so in little endian / host byte order
|
// We need to increment IP address by X but we have to do so in little endian / host byte order
|
||||||
// incrementing big endian will not work as we expect
|
// incrementing big endian will not work as we expect
|
||||||
uint32_t ip_as_little_endian = fast_ntoh(subnet_as_integer);
|
uint32_t ip_as_little_endian = fast_ntoh(subnet_as_integer);
|
||||||
|
|
||||||
// Increment it for specific number
|
// Increment it for specific number
|
||||||
ip_as_little_endian += i;
|
ip_as_little_endian += i;
|
||||||
|
|
||||||
if (enable_connection_tracking) {
|
if (enable_connection_tracking) {
|
||||||
// On creating it initializes by zeros
|
// On creating it initializes by zeros
|
||||||
conntrack_main_struct_t zero_conntrack_main_struct{};
|
conntrack_main_struct_t zero_conntrack_main_struct{};
|
||||||
|
|
||||||
SubnetVectorMapFlow[ip_as_little_endian] = zero_conntrack_main_struct;
|
SubnetVectorMapFlow[ip_as_little_endian] = zero_conntrack_main_struct;
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t result_ip_as_big_endian = fast_hton(ip_as_little_endian);
|
|
||||||
|
|
||||||
// logger << log4cpp::Priority::INFO << "Allocate: " << convert_ip_as_uint_to_string(result_ip_as_big_endian);
|
|
||||||
|
|
||||||
if (hash_counters) {
|
|
||||||
|
|
||||||
// We use big endian values as keys
|
|
||||||
try {
|
|
||||||
ipv4_host_counters.average_speed_map[result_ip_as_big_endian] = zero_map_element;
|
|
||||||
ipv4_host_counters.counter_map[result_ip_as_big_endian] = zero_map_element;
|
|
||||||
} catch (std::bad_alloc& ba) {
|
|
||||||
logger << log4cpp::Priority::ERROR << "Can't allocate memory for hash counters";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t result_ip_as_big_endian = fast_hton(ip_as_little_endian);
|
||||||
|
|
||||||
|
// logger << log4cpp::Priority::INFO << "Allocate: " << convert_ip_as_uint_to_string(result_ip_as_big_endian);
|
||||||
|
|
||||||
|
if (hash_counters) {
|
||||||
|
|
||||||
|
// We use big endian values as keys
|
||||||
|
try {
|
||||||
|
ipv4_host_counters.average_speed_map[result_ip_as_big_endian] = zero_map_element;
|
||||||
|
ipv4_host_counters.counter_map[result_ip_as_big_endian] = zero_map_element;
|
||||||
|
} catch (std::bad_alloc& ba) {
|
||||||
|
logger << log4cpp::Priority::ERROR << "Can't allocate memory for hash counters";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hash_counters) {
|
if (hash_counters) {
|
||||||
logger << log4cpp::Priority::INFO << "Successfully allocated " << ipv4_host_counters.average_speed_map.size() << " counters";
|
logger << log4cpp::Priority::INFO << "Successfully allocated " << ipv4_host_counters.average_speed_map.size() << " counters";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user