diff --git a/include/Grouper.h b/attic/include/Grouper.h similarity index 100% rename from include/Grouper.h rename to attic/include/Grouper.h diff --git a/src/Grouper.cpp b/attic/src/Grouper.cpp similarity index 100% rename from src/Grouper.cpp rename to attic/src/Grouper.cpp diff --git a/include/NetworkInterface.h b/include/NetworkInterface.h index 0c6b8ec06a..ab267122eb 100644 --- a/include/NetworkInterface.h +++ b/include/NetworkInterface.h @@ -622,16 +622,6 @@ class NetworkInterface : public AlertableEntity { const AddressTree * const cidr_filter, char *sortColumn, u_int32_t maxHits, u_int32_t toSkip, bool a2zSortOrder); - int getActiveHostsGroup(lua_State* vm, - u_int32_t *begin_slot, - bool walk_all, - AddressTree *allowed_hosts, - bool host_details, LocationPolicy location, - char *countryFilter, - u_int16_t vlan_id, OSType osFilter, - u_int32_t asnFilter, int16_t networkFilter, - u_int16_t pool_filter, bool filtered_hosts, u_int8_t ipver_filter, - char *groupColumn); int getActiveASList(lua_State* vm, const Paginator *p); int getActiveOSList(lua_State* vm, const Paginator *p); int getActiveCountriesList(lua_State* vm, const Paginator *p); diff --git a/include/OperatingSystem.h b/include/OperatingSystem.h index 9d56a86468..faf19ab0de 100644 --- a/include/OperatingSystem.h +++ b/include/OperatingSystem.h @@ -29,7 +29,6 @@ class OperatingSystem : public GenericHashEntry, public GenericTrafficElement, public SerializableElement { private: OSType os_type; - u_int32_t round_trip_time; inline void incSentStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) { if(first_seen == 0) first_seen = t, @@ -61,7 +60,6 @@ class OperatingSystem : public GenericHashEntry, public GenericTrafficElement, p incRcvdStats(when, rcvd_packets, rcvd_bytes); } - void updateRoundTripTime(u_int32_t rtt_msecs); void lua(lua_State* vm, DetailsLevel details_level, bool asListElement); inline void deserialize(json_object *obj) { diff --git a/include/OperatingSystemHash.h b/include/OperatingSystemHash.h index c279b829fc..482cfdf052 100644 --- a/include/OperatingSystemHash.h +++ b/include/OperatingSystemHash.h @@ -32,10 +32,6 @@ class OperatingSystemHash : public GenericHash { OperatingSystemHash(NetworkInterface *iface, u_int _num_hashes, u_int _max_hash_size); OperatingSystem* get(OSType os, bool is_inline_call); - -#ifdef AS_DEBUG - void printHash(); -#endif }; #endif /* _AUTONOMOUS_SYSTEM_HASH_H_ */ diff --git a/include/ntop_includes.h b/include/ntop_includes.h index cb7b339c98..3d110b651b 100644 --- a/include/ntop_includes.h +++ b/include/ntop_includes.h @@ -273,7 +273,6 @@ using namespace std; #include "NetworkDiscovery.h" #include "ICMPstats.h" #include "ICMPinfo.h" -#include "Grouper.h" #include "FlowGrouper.h" #include "PacketStats.h" #include "EthStats.h" diff --git a/src/LuaEngineInterface.cpp b/src/LuaEngineInterface.cpp index b1882d8daa..501d277e07 100644 --- a/src/LuaEngineInterface.cpp +++ b/src/LuaEngineInterface.cpp @@ -1620,49 +1620,6 @@ static int ntop_add_macs_ip_addresses(lua_State* vm) { /* ****************************************** */ -static int ntop_get_grouped_interface_hosts(lua_State* vm) { - NetworkInterface *ntop_interface = getCurrentInterface(vm); - bool show_details = true; - char *country = NULL; - OSType os_filter = os_any; - char *groupBy = (char*)"column_ip"; - bool filtered_hosts = false; - u_int16_t vlan_filter = (u_int16_t)-1; - u_int32_t asn_filter = (u_int32_t)-1; - u_int16_t pool_filter = (u_int16_t)-1; - u_int8_t ipver_filter = (u_int8_t)-1; - int16_t network_filter = -2; - u_int32_t begin_slot = 0; - bool walk_all = true; - - ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); - - if(lua_type(vm, 1) == LUA_TBOOLEAN) show_details = lua_toboolean(vm, 1) ? true : false; - if(lua_type(vm, 2) == LUA_TSTRING) groupBy = (char*)lua_tostring(vm, 2); - if(lua_type(vm, 3) == LUA_TSTRING) country = (char*)lua_tostring(vm, 3); - if(lua_type(vm, 4) == LUA_TNUMBER) os_filter = (OSType)lua_tointeger(vm, 4); - if(lua_type(vm, 5) == LUA_TNUMBER) vlan_filter = (u_int16_t)lua_tonumber(vm, 5); - if(lua_type(vm, 6) == LUA_TNUMBER) asn_filter = (u_int32_t)lua_tonumber(vm, 6); - if(lua_type(vm, 7) == LUA_TNUMBER) network_filter = (int16_t)lua_tonumber(vm, 7); - if(lua_type(vm, 8) == LUA_TNUMBER) pool_filter = (u_int16_t)lua_tonumber(vm, 8); - if(lua_type(vm, 9) == LUA_TNUMBER) ipver_filter = (u_int8_t)lua_tonumber(vm, 9); - - if((!ntop_interface) - || ntop_interface->getActiveHostsGroup(vm, - &begin_slot, walk_all, - get_allowed_nets(vm), - show_details, location_all, - country, - vlan_filter, os_filter, - asn_filter, network_filter, - pool_filter, filtered_hosts, ipver_filter, groupBy) < 0) - return(CONST_LUA_ERROR); - - return(CONST_LUA_OK); -} - -/* ****************************************** */ - static u_int8_t str_2_location(const char *s) { if(! strcmp(s, "lan")) return located_on_lan_interface; else if(! strcmp(s, "wan")) return located_on_wan_interface; @@ -2366,38 +2323,6 @@ static int ntop_get_interface_host_country(lua_State* vm) { } } -/* ****************************************** */ -#ifdef NOTUSED -static int ntop_get_grouped_interface_host(lua_State* vm) { - NetworkInterface *ntop_interface = getCurrentInterface(vm); - char *country_s = NULL, *os_s = NULL; - u_int16_t vlan_n, *vlan_ptr = NULL; - u_int32_t as_n, *as_ptr = NULL; - int16_t network_n, *network_ptr = NULL; - u_int32_t begin_slot = 0; - bool walk_all = true; - - ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); - - if(lua_type(vm, 1) == LUA_TNUMBER) vlan_n = (u_int16_t)lua_tonumber(vm, 1), vlan_ptr = &vlan_n; - if(lua_type(vm, 2) == LUA_TNUMBER) as_n = (u_int32_t)lua_tonumber(vm, 2), as_ptr = &as_n; - if(lua_type(vm, 3) == LUA_TNUMBER) network_n = (int16_t)lua_tonumber(vm, 3), network_ptr = &network_n; - if(lua_type(vm, 4) == LUA_TSTRING) country_s = (char*)lua_tostring(vm, 4); - if(lua_type(vm, 5) == LUA_TSTRING) os_s = (char*)lua_tostring(vm, 5); - - if(!ntop_interface - || ntop_interface->getActiveHostsGroup(vm, - &begin_slot, walk_all, - get_allowed_nets(vm), false, false, - country_s, vlan_ptr, os_s, as_ptr, - network_ptr, (char*)"column_ip", (char*)"country", - CONST_MAX_NUM_HITS, 0 /* toSkip */, true /* a2zSortOrder */) < 0) - return(CONST_LUA_ERROR); - - return(CONST_LUA_OK); -} -#endif - /* ****************************************** */ #ifdef NTOPNG_PRO @@ -4443,7 +4368,6 @@ static luaL_Reg _ntop_interface_reg[] = { { "getHostInfo", ntop_get_interface_host_info }, { "getHostName", ntop_get_interface_host_visual_name }, { "getHostCountry", ntop_get_interface_host_country }, - { "getGroupedHosts", ntop_get_grouped_interface_hosts }, { "addMacsIpAddresses", ntop_add_macs_ip_addresses }, { "getNetworksStats", ntop_get_interface_networks_stats }, { "getNetworkStats", ntop_get_interface_network_stats }, diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index 17a46c41ef..a3488174f6 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -5168,86 +5168,6 @@ int NetworkInterface::getMacsIpAddresses(lua_State *vm, int idx) { /* **************************************************** */ -int NetworkInterface::getActiveHostsGroup(lua_State* vm, - u_int32_t *begin_slot, - bool walk_all, - AddressTree *allowed_hosts, - bool host_details, LocationPolicy location, - char *countryFilter, - u_int16_t vlan_id, OSType osFilter, - u_int32_t asnFilter, int16_t networkFilter, - u_int16_t pool_filter, bool filtered_hosts, - u_int8_t ipver_filter, - char *groupColumn) { - struct flowHostRetriever retriever; - Grouper *gper; - - // sort hosts according to the grouping criterion - if(sortHosts(begin_slot, walk_all, - &retriever, 0 /* bridge_iface_idx TODO */, - allowed_hosts, host_details, location, - countryFilter, NULL /* Mac */, vlan_id, - osFilter, asnFilter, networkFilter, pool_filter, - filtered_hosts, false /* no blacklisted hosts filter */, false, false, false, - NULL, /* no cidr filter */ - ipver_filter, -1 /* no protocol filter */, - traffic_type_all /* no traffic type filter */, - groupColumn) < 0 ) { - return(-1); - } - - // build a new grouper that will help in aggregating stats - if((gper = new(std::nothrow) Grouper(retriever.sorter)) == NULL) { - ntop->getTrace()->traceEvent(TRACE_ERROR, - "Unable to allocate memory for a Grouper."); - return(-1); - } - - lua_newtable(vm); - - for(int i = 0; i < (int)retriever.actNumEntries; i++) { - Host *h = retriever.elems[i].hostValue; - - if(h) { - if(gper->inGroup(h) == false) { - if(gper->getNumEntries() > 0) - gper->lua(vm); - gper->newGroup(h); - } - - gper->incStats(h); - - h->decUses(); /* See (***) */ - } - } - - if(gper->getNumEntries() > 0) - gper->lua(vm); - - delete gper; - gper = NULL; - - // it's up to us to clean sorted data - // make sure first to free elements in case a string sorter has been used - if((retriever.sorter == column_name) - || (retriever.sorter == column_country) - || (retriever.sorter == column_os)) { - for(u_int i=0; igetPrefs()->get_ewma_alpha_percent(); - -#ifdef AS_RTT_DEBUG - u_int32_t old_rtt = round_trip_time; -#endif - if(round_trip_time) - Utils::update_ewma(rtt_msecs, &round_trip_time, ewma_alpha_percent); - else - round_trip_time = rtt_msecs; -#ifdef AS_RTT_DEBUG - printf("Updating rtt EWMA: [os: %u][sample msecs: %u][old rtt: %u][new rtt: %u][alpha percent: %u]\n", - os_type, rtt_msecs, old_rtt, round_trip_time, ewma_alpha_percent); -#endif -} - -/* *************************************** */ - void OperatingSystem::lua(lua_State* vm, DetailsLevel details_level, bool asListElement) { lua_newtable(vm); @@ -94,7 +71,6 @@ void OperatingSystem::lua(lua_State* vm, DetailsLevel details_level, bool asList lua_push_uint64_table_entry(vm, "duration", get_duration()); lua_push_uint64_table_entry(vm, "num_hosts", getNumHosts()); - lua_push_uint64_table_entry(vm, "round_trip_time", round_trip_time); if(details_level >= details_higher) { if(ndpiStats) ndpiStats->lua(iface, vm); diff --git a/src/OperatingSystemHash.cpp b/src/OperatingSystemHash.cpp index 9245633091..a5343371da 100644 --- a/src/OperatingSystemHash.cpp +++ b/src/OperatingSystemHash.cpp @@ -60,29 +60,3 @@ OperatingSystem* OperatingSystemHash::get(OSType os_type, bool is_inline_call) { return(head); } } - -/* ************************************ */ - -#ifdef AS_DEBUG - -static bool print_oses(GenericHashEntry *_as, void *user_data) { - OperatingSystem *as = (OperatingSystem*)_as; - - ntop->getTrace()->traceEvent(TRACE_NORMAL, "Operating System [os: %u] [num_uses: %u]", - as->get_os(), - os->getNumHosts()); - - return(false); /* false = keep on walking */ -} - -/* ************************************ */ - -void OperatingSystemHash::printHash() { - disablePurge(); - - walk(print_oses, NULL); - - enablePurge(); -} - -#endif