mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-11-23 00:52:00 +01:00
Code cleanup from unused things
This commit is contained in:
parent
0b76fc02ae
commit
d389fd147d
@ -225,65 +225,6 @@ bool folder_exists(std::string path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#define BIG_CONSTANT(x) (x##LLU)
|
||||
|
||||
/*
|
||||
|
||||
// calculate hash
|
||||
unsigned int seed = 11;
|
||||
uint64_t hash = MurmurHash64A(¤t_packet, sizeof(current_packet), seed);
|
||||
|
||||
*/
|
||||
|
||||
// https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash2.cpp
|
||||
// 64-bit hash for 64-bit platforms
|
||||
uint64_t MurmurHash64A(const void* key, int len, uint64_t seed) {
|
||||
const uint64_t m = BIG_CONSTANT(0xc6a4a7935bd1e995);
|
||||
const int r = 47;
|
||||
|
||||
uint64_t h = seed ^ (len * m);
|
||||
|
||||
const uint64_t* data = (const uint64_t*)key;
|
||||
const uint64_t* end = data + (len / 8);
|
||||
|
||||
while (data != end) {
|
||||
uint64_t k = *data++;
|
||||
|
||||
k *= m;
|
||||
k ^= k >> r;
|
||||
k *= m;
|
||||
|
||||
h ^= k;
|
||||
h *= m;
|
||||
}
|
||||
|
||||
const unsigned char* data2 = (const unsigned char*)data;
|
||||
|
||||
switch (len & 7) {
|
||||
case 7:
|
||||
h ^= uint64_t(data2[6]) << 48;
|
||||
case 6:
|
||||
h ^= uint64_t(data2[5]) << 40;
|
||||
case 5:
|
||||
h ^= uint64_t(data2[4]) << 32;
|
||||
case 4:
|
||||
h ^= uint64_t(data2[3]) << 24;
|
||||
case 3:
|
||||
h ^= uint64_t(data2[2]) << 16;
|
||||
case 2:
|
||||
h ^= uint64_t(data2[1]) << 8;
|
||||
case 1:
|
||||
h ^= uint64_t(data2[0]);
|
||||
h *= m;
|
||||
};
|
||||
|
||||
h ^= h >> r;
|
||||
h *= m;
|
||||
h ^= h >> r;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html
|
||||
int timeval_subtract(struct timeval* result, struct timeval* x, struct timeval* y) {
|
||||
/* Perform the carry for the later subtraction by updating y. */
|
||||
@ -1333,7 +1274,7 @@ bool read_simple_packet(uint8_t* buffer, size_t buffer_length, simple_packet_t&
|
||||
packet.payload_full_length = root.getPacketPayloadFullLength();
|
||||
packet.packet_direction = (direction_t)root.getPacketDirection();
|
||||
packet.source = (source_t)root.getSource();
|
||||
} catch (kj::Exception e) {
|
||||
} catch (kj::Exception& e) {
|
||||
logger << log4cpp::Priority::WARN
|
||||
<< "Exception happened during attempt to parse tera flow packet: " << e.getDescription().cStr();
|
||||
return false;
|
||||
|
@ -55,7 +55,6 @@ int set_bit_value(uint8_t& num, int bit);
|
||||
int set_bit_value(uint16_t& num, int bit);
|
||||
|
||||
std::string print_tcp_flags(uint8_t flag_value);
|
||||
uint64_t MurmurHash64A(const void* key, int len, uint64_t seed);
|
||||
std::string print_tcp_flags(uint8_t flag_value);
|
||||
int timeval_subtract(struct timeval* result, struct timeval* x, struct timeval* y);
|
||||
bool folder_exists(std::string path);
|
||||
|
@ -201,8 +201,6 @@ bool process_ipfix_template(const uint8_t* pkt, size_t flowset_length, uint32_t
|
||||
return false;
|
||||
}
|
||||
|
||||
bool template_cache_update_required = false;
|
||||
|
||||
// These fields use quite complicated encoding and we need to identify them first
|
||||
bool ipfix_variable_length_elements_used = false;
|
||||
|
||||
@ -270,7 +268,6 @@ bool process_ipfix_template(const uint8_t* pkt, size_t flowset_length, uint32_t
|
||||
|
||||
// If we have any changes for this template, let's flush them to disk
|
||||
if (updated) {
|
||||
template_cache_update_required = true;
|
||||
}
|
||||
|
||||
if (updated_existing_template) {
|
||||
@ -1248,8 +1245,6 @@ void update_ipfix_sampling_rate(uint32_t sampling_rate, const std::string& clien
|
||||
|
||||
logger << log4cpp::Priority::DEBUG << "I extracted sampling rate: " << new_sampling_rate << " for " << client_addres_in_string_format;
|
||||
|
||||
bool any_changes_for_sampling = false;
|
||||
|
||||
{
|
||||
// Replace old sampling rate value
|
||||
std::lock_guard<std::mutex> lock(ipfix_sampling_rates_mutex);
|
||||
@ -1265,7 +1260,6 @@ void update_ipfix_sampling_rate(uint32_t sampling_rate, const std::string& clien
|
||||
logger << log4cpp::Priority::INFO << "Learnt new IPFIX sampling rate " << new_sampling_rate << " for "
|
||||
<< client_addres_in_string_format;
|
||||
|
||||
any_changes_for_sampling = true;
|
||||
} else {
|
||||
auto old_sampling_rate = known_sampling_rate->second;
|
||||
|
||||
@ -1277,7 +1271,6 @@ void update_ipfix_sampling_rate(uint32_t sampling_rate, const std::string& clien
|
||||
logger << log4cpp::Priority::INFO << "Detected IPFIX sampling rate change from " << old_sampling_rate << " to "
|
||||
<< new_sampling_rate << " for " << client_addres_in_string_format;
|
||||
|
||||
any_changes_for_sampling = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,8 +130,6 @@ bool process_netflow_v9_template(const uint8_t* pkt,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool template_cache_update_required = false;
|
||||
|
||||
for (uint32_t offset = sizeof(*template_header); offset < flowset_length;) {
|
||||
const netflow9_template_flowset_header_t* netflow9_template_flowset_header =
|
||||
(const netflow9_template_flowset_header_t*)(pkt + offset);
|
||||
@ -197,7 +195,6 @@ bool process_netflow_v9_template(const uint8_t* pkt,
|
||||
|
||||
// If we have any changes for this template, let's flush them to disk
|
||||
if (updated) {
|
||||
template_cache_update_required = true;
|
||||
}
|
||||
|
||||
if (updated_existing_template) {
|
||||
@ -1062,8 +1059,6 @@ void update_netflow_v9_sampling_rate(uint32_t sampling_rate, const std::string&
|
||||
// logger<< log4cpp::Priority::INFO << "I extracted sampling rate: " << new_sampling_rate
|
||||
// << "for " << client_address_in_string_format;
|
||||
|
||||
bool any_changes_for_sampling = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(netflow9_sampling_rates_mutex);
|
||||
|
||||
@ -1078,7 +1073,6 @@ void update_netflow_v9_sampling_rate(uint32_t sampling_rate, const std::string&
|
||||
logger << log4cpp::Priority::INFO << "Learnt new Netflow v9 sampling rate " << new_sampling_rate << " for "
|
||||
<< client_addres_in_string_format;
|
||||
|
||||
any_changes_for_sampling = true;
|
||||
} else {
|
||||
auto old_sampling_rate = known_sampling_rate->second;
|
||||
|
||||
@ -1090,7 +1084,6 @@ void update_netflow_v9_sampling_rate(uint32_t sampling_rate, const std::string&
|
||||
logger << log4cpp::Priority::INFO << "Detected sampling rate change from " << old_sampling_rate << " to "
|
||||
<< new_sampling_rate << " for " << client_addres_in_string_format;
|
||||
|
||||
any_changes_for_sampling = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user