diff --git a/include/GenericHashEntry.h b/include/GenericHashEntry.h index b41e3bca81..7f3c05eade 100644 --- a/include/GenericHashEntry.h +++ b/include/GenericHashEntry.h @@ -36,6 +36,7 @@ class GenericHashEntry { GenericHashEntry *hash_next; /**< Pointer of next hash entry.*/ protected: + u_int16_t num_uses; bool will_be_purged; /**< Mark this host as candidate for purging.*/ time_t first_seen; /**< Time of first seen.*/ time_t last_seen; /**< Time of last seen.*/ @@ -97,6 +98,8 @@ class GenericHashEntry { inline bool is_ready_to_be_purged() { return(will_be_purged); }; virtual u_int32_t key() { return(0); }; virtual char* get_string_key(char *buf, u_int buf_len) { buf[0] = '\0'; return(buf); }; + void incUses() { num_uses++; } + void decUses() { num_uses--; } }; #endif /* _GENERIC_HASH_ENTRY_H_ */ diff --git a/include/Host.h b/include/Host.h index 4cd8adc885..8b04ef9c4a 100644 --- a/include/Host.h +++ b/include/Host.h @@ -24,31 +24,26 @@ #include "ntop_includes.h" -#define INTER_FLOW_ACTIVITY_SLOTS 5 -#define INTER_FLOW_ACTIVITY_MAX_INTERVAL 5 -#define INTER_FLOW_ACTIVITY_MAX_CONTINUITY_INTERVAL 20 - -typedef enum { - ifa_facebook_stats = 0, - ifa_twitter_stats, - - IFA_STATS_PROTOS_N -} ifa_stats_protos; +typedef struct { + const Flow *flow; + time_t first; + time_t last; + u_int16_t pkts; +} InterFlowActivityStats; class Host : public GenericHost { private: - u_int8_t mac_address[6]; u_int32_t asn; char *symbolic_name, *country, *city, *asname, os[16], trafficCategory[12], *topSitesKey; bool blacklisted_host, drop_all_host_traffic, dump_host_traffic; u_int32_t host_quota_mb; - u_int16_t num_uses; int16_t local_network_id, deviceIfIdx; u_int32_t deviceIP; int ingress_shaper_id, egress_shaper_id; float latitude, longitude; - IpAddress *ip; + IpAddress ip; Mutex *m; + Mac *mac; time_t nextResolveAttempt, nextSitesUpdate; #ifdef NTOPNG_PRO CountMinSketch *sent_to_sketch, *rcvd_from_sketch; @@ -61,13 +56,8 @@ class Host : public GenericHost { TrafficStats other_ip_sent, other_ip_rcvd; TrafficStats ingress_drops, egress_drops; - UserActivityStats user_activities; - struct { - const Flow * flow; - time_t first; - time_t last; - u_int16_t pkts; - } ifa_stats[IFA_STATS_PROTOS_N][INTER_FLOW_ACTIVITY_SLOTS]; + UserActivityStats *user_activities; + InterFlowActivityStats *ifa_stats; PacketStats sent_stats, recv_stats; u_int32_t total_num_flows_as_client, total_num_flows_as_server; u_int32_t num_active_flows_as_client, num_active_flows_as_server; @@ -86,7 +76,7 @@ class Host : public GenericHost { u_int32_t pktRetr, pktOOO, pktLost; } tcpPacketStats; /* Sent packets */ - void initialize(u_int8_t mac[6], u_int16_t _vlan_id, bool init_all); + void initialize(u_int8_t _mac[6], u_int16_t _vlan_id, bool init_all); void refreshHTTPBL(); void computeHostSerial(); json_object* getJSONObject(); @@ -98,8 +88,7 @@ class Host : public GenericHost { public: Host(NetworkInterface *_iface); Host(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId); - Host(NetworkInterface *_iface, u_int8_t mac[6], u_int16_t _vlanId); - Host(NetworkInterface *_iface, u_int8_t mac[6], u_int16_t _vlanId, IpAddress *_ip); + Host(NetworkInterface *_iface, u_int8_t _mac[6], u_int16_t _vlanId, IpAddress *_ip); ~Host(); void updateLocal(); @@ -113,17 +102,17 @@ class Host : public GenericHost { inline int16_t get_local_network_id() { return(local_network_id); }; inline PacketStats* get_sent_stats() { return(&sent_stats); }; inline PacketStats* get_recv_stats() { return(&recv_stats); }; - inline HTTPstats* getHTTPstats() { return(http); }; + inline HTTPstats* getHTTPstats() { return(http); }; inline HTTPstats* getHTTP() { return(http); }; - inline void set_ipv4(u_int32_t _ipv4) { ip->set_ipv4(_ipv4); }; - inline void set_ipv6(struct ndpi_in6_addr *_ipv6) { ip->set_ipv6(_ipv6); }; - u_int32_t key(); + inline void set_ipv4(u_int32_t _ipv4) { ip.set(_ipv4); }; + inline void set_ipv6(struct ndpi_in6_addr *_ipv6) { ip.set(_ipv6); }; + inline u_int32_t key() { return(ip.key()); }; char* getJSON(); inline void setOS(char *_os) { if(os[0] == '\0') snprintf(os, sizeof(os), "%s", _os); } - inline IpAddress* get_ip() { return(ip); } + inline IpAddress* get_ip() { return(&ip); } void set_mac(char *m); inline bool is_blacklisted() { return(blacklisted_host); } - inline u_int8_t* get_mac() { return(mac_address); } + inline u_int8_t* get_mac() { return(mac ? mac->get_mac() : NULL); } inline char* get_os() { return(os); } inline char* get_name() { return(symbolic_name); } inline char* get_country() { return(country); } @@ -133,15 +122,12 @@ class Host : public GenericHost { inline int get_egress_shaper_id() { return(egress_shaper_id); } inline u_int32_t get_asn() { return(asn); } inline char* get_asname() { return(asname); } - inline bool isPrivateHost() { return((ip && ip->isPrivateAddress()) ? true : false); } + inline bool isPrivateHost() { return(ip.isPrivateAddress()); } inline float get_latitude() { return(latitude); } inline float get_longitude() { return(longitude); } - bool isLocalInterfaceAddress(); - char* get_mac(char *buf, u_int buf_len, u_int8_t *mac); + bool isLocalInterfaceAddress(); char* get_name(char *buf, u_int buf_len, bool force_resolution_if_not_found); - char* get_string_key(char *buf, u_int buf_len); - void incUses() { num_uses++; } - void decUses() { num_uses--; } + inline char* get_string_key(char *buf, u_int buf_len) { return(ip.print(buf, buf_len)); }; bool idle(); void lua(lua_State* vm, patricia_tree_t * ptree, bool host_details, bool verbose, bool returnHost, bool asListElement, @@ -149,14 +135,15 @@ class Host : public GenericHost { void resolveHostName(); void setName(char *name); void set_host_label(char *label_name); - int compare(Host *h); - inline bool equal(IpAddress *_ip) { return(ip && _ip && ip->equal(_ip)); }; + inline int compare(Host *h) { return(ip.compare(&h->ip)); }; + inline bool equal(IpAddress *_ip) { return(_ip && ip.equal(_ip)); }; void incStats(u_int8_t l4_proto, u_int ndpi_proto, struct site_categories *category, u_int64_t sent_packets, u_int64_t sent_bytes, u_int64_t sent_goodput_bytes, u_int64_t rcvd_packets, u_int64_t rcvd_bytes, u_int64_t rcvd_goodput_bytes); void incHitter(Host *peer, u_int64_t sent_bytes, u_int64_t rcvd_bytes); void updateHostTrafficPolicy(char *key); + inline void incMacStats(bool sentBytes, u_int pkt_len) { if(mac) { if(sentBytes) mac->incSentStats(pkt_len); else mac->incRcvdStats(pkt_len); } }; char* serialize(); void serialize2redis(); bool deserialize(char *json_str, char *key); @@ -199,8 +186,9 @@ class Host : public GenericHost { void incrVisitedWebSite(char *hostname); const UserActivityCounter * getActivityBytes(UserActivityID id); void incActivityBytes(UserActivityID id, u_int64_t upbytes, u_int64_t downbytes, u_int64_t bgbytes); - void incIfaPackets(ifa_stats_protos proto, const Flow * flow, time_t when); - void getIfaStats(ifa_stats_protos proto, time_t when, int * count, u_int32_t * packets, time_t * max_diff); + void incIfaPackets(InterFlowActivityProtos proto, const Flow * flow, time_t when); + void getIfaStats(InterFlowActivityProtos proto, time_t when, int * count, u_int32_t * packets, time_t * max_diff); + inline UserActivityStats* get_user_activities() { return(user_activities); } }; #endif /* _HOST_H_ */ diff --git a/include/HostActivityRetriever.h b/include/HostActivityRetriever.h new file mode 100644 index 0000000000..d45164aba7 --- /dev/null +++ b/include/HostActivityRetriever.h @@ -0,0 +1,36 @@ +/* + * + * (C) 2013-16 - ntop.org + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _HOST_ACTIVITY_RETRIEVER_H_ +#define _HOST_ACTIVITY_RETRIEVER_H_ + +#include "ntop_includes.h" + +class HostActivityRetriever { +public: + IpAddress search; + bool found; + UserActivityCounter counters[UserActivitiesN]; + + HostActivityRetriever(const char * ip) { search.set((char *)ip), found = false; }; +}; + +#endif /* _HOST_ACTIVITY_RETRIEVER_H_ */ diff --git a/include/HostHash.h b/include/HostHash.h index d7bb6d6913..3635cb0949 100644 --- a/include/HostHash.h +++ b/include/HostHash.h @@ -32,7 +32,7 @@ class HostHash : public GenericHash { public: HostHash(NetworkInterface *iface, u_int _num_hashes, u_int _max_hash_size); - Host* get(u_int16_t vlanId, const u_int8_t mac[6]); + // Host* get(u_int16_t vlanId, const u_int8_t mac[6]); Host* get(u_int16_t vlanId, IpAddress *key); void incNumHTTPEntries(); diff --git a/include/IpAddress.h b/include/IpAddress.h index ac27280292..34b3602670 100644 --- a/include/IpAddress.h +++ b/include/IpAddress.h @@ -48,31 +48,27 @@ class IpAddress { public: IpAddress(); - IpAddress(char *string); - IpAddress(IpAddress *ip); - IpAddress(u_int32_t _ipv4); - IpAddress(struct ndpi_in6_addr *_ipv6); bool isEmpty(); inline void reset() { memset(&addr, 0, sizeof(addr)); } inline bool isIPv4() { return((addr.ipVersion == 4) ? true : false); } - inline bool isIPv6() { return((addr.ipVersion == 6) ? true : false); } - inline void set_ipv4(u_int32_t _ipv4) { addr.ipVersion = 4, addr.ipType.ipv4 = _ipv4; compute_key(); } - inline void set_ipv6(struct ndpi_in6_addr *_ipv6) { addr.ipVersion = 6, memcpy(&addr.ipType.ipv6, _ipv6, sizeof(struct ndpi_in6_addr)); compute_key(); } + inline bool isIPv6() { return((addr.ipVersion == 6) ? true : false); } inline u_int32_t get_ipv4() { return((addr.ipVersion == 4) ? addr.ipType.ipv4 : 0); } inline struct ndpi_in6_addr* get_ipv6() { return((addr.ipVersion == 6) ? &addr.ipType.ipv6 : NULL); } inline struct ipAddress* getIP() { return(&addr); }; inline bool equal(u_int32_t ipv4_addr) { if((addr.ipVersion == 4) && (addr.ipType.ipv4 == ipv4_addr)) return(true); else return(false); }; inline bool equal(struct ndpi_in6_addr *ip6_addr) { if((addr.ipVersion == 6) && (memcmp(&addr.ipType.ipv6, ip6_addr, sizeof(struct ndpi_in6_addr)) == 0)) return(true); else return(false); }; inline bool equal(IpAddress *_ip) { return(this->compare(_ip) == 0); }; - - void set_from_string(char *string); int compare(IpAddress *ip); - inline u_int32_t key() { return(ip_key); }; - void set(IpAddress *ip); - inline bool isPrivateAddress() { return(addr.privateIP); }; - inline bool isMulticastAddress() { return(addr.multicastIP); }; - inline bool isBroadcastAddress() { return(addr.broadcastIP); }; + inline u_int32_t key() { return(ip_key); }; + inline void set(u_int32_t _ipv4) { addr.ipVersion = 4, addr.ipType.ipv4 = _ipv4; compute_key(); } + inline void set(struct ndpi_in6_addr *_ipv6) { addr.ipVersion = 6, memcpy(&addr.ipType.ipv6, _ipv6, sizeof(struct ndpi_in6_addr)); + addr.privateIP = false; compute_key(); } + inline void set(IpAddress *ip) { memcpy(&addr, &ip->addr, sizeof(struct ipAddress)); ip_key = ip->ip_key; }; + void set(char *ip); + inline bool isPrivateAddress() { return(addr.privateIP); }; + inline bool isMulticastAddress() { return(addr.multicastIP); }; + inline bool isBroadcastAddress() { return(addr.broadcastIP); }; char* print(char *str, u_int str_len, u_int8_t bitmask = 0); bool isLocalHost(int16_t *network_id); bool isLocalInterfaceAddress(); diff --git a/include/Mac.h b/include/Mac.h new file mode 100644 index 0000000000..cb9e05bf19 --- /dev/null +++ b/include/Mac.h @@ -0,0 +1,50 @@ +/* + * + * (C) 2013-16 - ntop.org + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _MAC_H_ +#define _MAC_H_ + +#include "ntop_includes.h" + +class Mac : public GenericHashEntry { + private: + u_int8_t mac[6]; + u_int16_t vlan_id; + TrafficStats sent, rcvd; + + public: + Mac(NetworkInterface *_iface, u_int8_t _mac[6], u_int16_t _vlanId); + ~Mac(); + + inline u_int8_t* get_mac() { return(mac); } + inline u_int16_t get_vlan_id() { return(vlan_id); } + + inline void incSentStats(u_int pkt_len) { sent.incStats(pkt_len); } + inline void incRcvdStats(u_int pkt_len) { rcvd.incStats(pkt_len); } + + bool idle(); + bool isIdle(u_int max_idleness); + + inline u_int32_t key() { return(mac[0]+mac[1]+mac[2]+mac[3]+mac[4]+mac[5]); }; + inline char* get_string_key(char *buf, u_int buf_len) { return(Utils::formatMac(mac, buf, buf_len)); } +}; + +#endif /* _MAC_H_ */ diff --git a/include/MacHash.h b/include/MacHash.h new file mode 100644 index 0000000000..dbb22fa08d --- /dev/null +++ b/include/MacHash.h @@ -0,0 +1,37 @@ +/* + * + * (C) 2013-16 - ntop.org + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _MAC_HASH_H_ +#define _MAC_HASH_H_ + +#include "ntop_includes.h" + +class MacHash : public GenericHash { + private: + Mutex m; + + public: + MacHash(NetworkInterface *iface, u_int _num_hashes, u_int _max_hash_size); + + Mac* get(u_int16_t vlanId, const u_int8_t mac[6]); +}; + +#endif /* _MAC_HASH_H_ */ diff --git a/include/NetworkInterface.h b/include/NetworkInterface.h index a925197668..6bbde3655c 100644 --- a/include/NetworkInterface.h +++ b/include/NetworkInterface.h @@ -1,4 +1,4 @@ -/* + /* * * (C) 2013-16 - ntop.org * @@ -31,6 +31,8 @@ class Flow; class FlowHash; class Host; class HostHash; +class Mac; +class MacHash; class DB; class Paginator; @@ -86,8 +88,12 @@ class NetworkInterface { TcpPacketStats tcpPacketStats; u_int64_t zmq_initial_bytes, zmq_initial_pkts; + + /* Mac */ + MacHash *macs_hash; /**< Hash used to store MAC information. */ + /* Hosts */ - HostHash *hosts_hash; /**< Hash used to memorize the hosts information. */ + HostHash *hosts_hash; /**< Hash used to store hosts information. */ bool purge_idle_flows_hosts, sprobe_interface, inline_interface, dump_all_traffic, dump_to_tap, dump_to_disk, dump_unknown_traffic, dump_security_packets; DB *db; @@ -292,18 +298,18 @@ class NetworkInterface { void purgeIdle(time_t when); u_int purgeIdleFlows(); - u_int purgeIdleHosts(); + u_int purgeIdleHostsMacs(); u_int64_t getNumPackets(); u_int64_t getNumBytes(); u_int getNumPacketDrops(); u_int getNumFlows(); u_int getNumHosts(); + u_int getNumMacs(); u_int getNumHTTPHosts(); void runHousekeepingTasks(); - Host* findHostByMac(u_int8_t mac[6], u_int16_t vlanId, - bool createIfNotPresent); + Mac* getMac(u_int8_t _mac[6], u_int16_t vlanId, bool createIfNotPresent); Host* getHost(char *host_ip, u_int16_t vlan_id); bool getHostInfo(lua_State* vm, patricia_tree_t *allowed_hosts, char *host_ip, u_int16_t vlan_id); bool loadHostAlertPrefs(lua_State* vm, patricia_tree_t *allowed_hosts, char *host_ip, u_int16_t vlan_id); @@ -350,6 +356,7 @@ class NetworkInterface { char *host_ip, u_int16_t vlan_id); inline HostHash* get_hosts_hash() { return(hosts_hash); } + inline MacHash* get_macs_hash() { return(macs_hash); } inline bool is_bridge_interface() { return(bridge_interface); } inline const char* getLocalIPAddresses() { return(ip_addresses.c_str()); } void addInterfaceAddress(char *addr); diff --git a/include/Utils.h b/include/Utils.h index f24c53c43b..6d8df8f2db 100755 --- a/include/Utils.h +++ b/include/Utils.h @@ -72,7 +72,6 @@ class Utils { static ticks getticks(); static char* getURL(char *url, char *buf, u_int buf_len); static bool discardOldFilesExceeding(const char *path, const unsigned long max_size); - static char* macaddr_str (const char *mac, char *buf); static u_int64_t macaddr_int(const u_int8_t *mac); static void readMac(char *ifname, dump_mac_t mac_addr); static u_int32_t getMaxIfSpeed(const char *ifname); @@ -86,6 +85,7 @@ class Utils { static void xor_encdec(u_char *data, int data_len, u_char *key); static bool isPrintableChar(u_char c); static const char* flowstatus2str(FlowStatus s); + static char* formatMac(u_int8_t *mac, char *buf, u_int buf_len); }; #endif /* _UTILS_H_ */ diff --git a/include/ntop_defines.h b/include/ntop_defines.h index f0e62d6c73..71c8b6238b 100644 --- a/include/ntop_defines.h +++ b/include/ntop_defines.h @@ -553,4 +553,8 @@ #define _COMPILE_TIME_ASSERT2(X,L) _COMPILE_TIME_ASSERT3(X,L) #define COMPILE_TIME_ASSERT(X) _COMPILE_TIME_ASSERT2(X,__LINE__) +#define INTER_FLOW_ACTIVITY_SLOTS 5 +#define INTER_FLOW_ACTIVITY_MAX_INTERVAL 5 +#define INTER_FLOW_ACTIVITY_MAX_CONTINUITY_INTERVAL 20 + #endif /* _NTOP_DEFINES_H_ */ diff --git a/include/ntop_includes.h b/include/ntop_includes.h index 117b582c69..ef0753dc13 100644 --- a/include/ntop_includes.h +++ b/include/ntop_includes.h @@ -190,6 +190,7 @@ using namespace std; #include "MySQLDB.h" #include "TcpFlowStats.h" #include "InterfaceStatsHash.h" +#include "HostActivityRetriever.h" #include "NetworkInterface.h" #include "PcapInterface.h" #include "ViewInterface.h" @@ -220,10 +221,12 @@ using namespace std; #include "Flashstart.h" #include "GenericHost.h" #include "CategoryStats.h" +#include "Mac.h" #include "Host.h" #include "ActivityFilters.h" #include "Flow.h" #include "FlowHash.h" +#include "MacHash.h" #include "HostHash.h" #include "PeriodicActivities.h" #include "Lua.h" diff --git a/include/ntop_typedefs.h b/include/ntop_typedefs.h index 9f4dd6d54e..cda1d0ceb6 100644 --- a/include/ntop_typedefs.h +++ b/include/ntop_typedefs.h @@ -238,4 +238,10 @@ typedef enum { */ } UserActivityID; +typedef enum { + ifa_facebook_stats = 0, + ifa_twitter_stats, + IFA_STATS_PROTOS_N +} InterFlowActivityProtos; + #endif /* _NTOP_TYPEDEFS_H_ */ diff --git a/scripts/lua/admin/prefs.lua b/scripts/lua/admin/prefs.lua index 7161ab1ab0..011fa9965c 100644 --- a/scripts/lua/admin/prefs.lua +++ b/scripts/lua/admin/prefs.lua @@ -403,6 +403,19 @@ function printStatsRrds() "to keep application protocol statistics at the cost of using more disk space.", "On", "1", "success", "Off", "0", "danger", "toggle_local_ndpi", "ntopng.prefs.host_ndpi_rrd_creation", "0") + local toggle_local_activity = "toggle_local_activity" + local activityPrefsToSwitch = {"local_activity_prefs", + "host_activity_rrd_raw_hours", "id_input_host_activity_rrd_raw_hours", + "host_activity_rrd_1h_days", "id_input_host_activity_rrd_1h_days", + "host_activity_rrd_1d_days", "id_input_host_activity_rrd_1d_days"} + + if prefs.is_flow_activity_enabled then + toggleTableButtonPrefs("Activities Timeseries", + "Toggle the creation of activities timeseries for local hosts and networks. Turn it off to save storage space.", + "On", "1", "success", "Off", "0", "danger", toggle_local_activity, "ntopng.prefs.host_activity_rrd_creation", "0", + false, activityPrefsToSwitch) + end + local info = ntop.getInfo() toggleTableButtonPrefs("Flow Devices Timeseries", "Toggle the creation of bytes timeseries for each port of the sFlow/NetFlow devices. For each device port" .. diff --git a/scripts/lua/get_grouped_hosts_data.lua b/scripts/lua/get_grouped_hosts_data.lua index ceb95389f8..fce11bdd05 100644 --- a/scripts/lua/get_grouped_hosts_data.lua +++ b/scripts/lua/get_grouped_hosts_data.lua @@ -104,12 +104,8 @@ function print_single_group(value) end elseif (group_col == "local_network_id" or network_n ~= nil) then print("hosts_stats.lua?network="..tostring(value["id"]).."'>") - elseif (group_col == "antenna_mac") then - print("hosts_stats.lua?antenna_mac="..value["id"].."'>") elseif (group_col == "mac") then print("hosts_stats.lua?mac="..value["name"].."'>") - --PRINT - -- io.write("ID = "..value["id"]..'\n') else print("hosts_stats.lua'>") end @@ -132,7 +128,7 @@ function print_single_group(value) end print('", ') - elseif((group_col == "mac") or (group_col == "antenna_mac")) then + elseif(group_col == "mac") then print(get_symbolic_mac(value["name"])..'", ') elseif(group_col == "country" and value["id"] == "Uncategorized") then print(''..value["id"]..'", ') diff --git a/scripts/lua/get_hosts_data.lua b/scripts/lua/get_hosts_data.lua index 4ae360fa22..6b7ab4dc57 100644 --- a/scripts/lua/get_hosts_data.lua +++ b/scripts/lua/get_hosts_data.lua @@ -28,7 +28,6 @@ vlan = _GET["vlan"] network = _GET["network"] country = _GET["country"] os_ = _GET["os"] -antenna_mac = _GET["antenna_mac"] mac = _GET["mac"] -- table_id = _GET["table"] @@ -98,8 +97,6 @@ interface.select(ifname) to_skip = (currentPage-1) * perPage if(sortOrder == "desc") then sOrder = false else sOrder = true end --- if((mac ~= nil) or (antenna_mac ~= nil) or (mode == "local")) then - hosts_retrv_function = interface.getHostsInfo if mode == "local" then @@ -275,7 +272,6 @@ for _key, _value in pairsByKeys(vals, funct) do ((asn == nil) or (asn == tostring(hosts_stats[key]["asn"]))) and ((os_ == nil) or (os_ == tostring(hosts_stats[key]["os"]))) and ((country == nil) or (country == tostring(hosts_stats[key]["country"]))) and -((antenna_mac == nil) or (antenna_mac == tostring(hosts_stats[key]["antenna_mac"]))) and ((mac == nil) or (mac == tostring(hosts_stats[key]["mac"]))) and ((vlan == nil) or (vlan == tostring(hosts_stats[key]["vlan"]))) and ((network == nil) or (network == tostring(hosts_stats[key]["local_network_id"])))) then diff --git a/scripts/lua/host_details.lua b/scripts/lua/host_details.lua index fb9819c315..cfab21c4a5 100644 --- a/scripts/lua/host_details.lua +++ b/scripts/lua/host_details.lua @@ -36,6 +36,8 @@ is_packetdump_enabled = isLocalPacketdumpEnabled() host = nil family = nil +prefs = ntop.getPrefs() + local hostkey = hostinfo2hostkey(host_info, nil, true --[[ force show vlan --]]) if((host_name == nil) or (host_ip == nil)) then @@ -214,12 +216,14 @@ else end end -if(page == "activities") then - print("
  • Activities
  • \n") -else - if interface.isPcapDumpInterface() == false and host["ip"] ~= nil then +if(prefs.is_flow_activity_enabled) then + if(page == "activities") then + print("
  • Activities
  • \n") + else + if interface.isPcapDumpInterface() == false and host["ip"] ~= nil then print("
  • Activities
  • ") - end + end + end end if(page == "dns") then diff --git a/scripts/lua/hosts_stats.lua b/scripts/lua/hosts_stats.lua index a13a9943b7..9e7fba3697 100644 --- a/scripts/lua/hosts_stats.lua +++ b/scripts/lua/hosts_stats.lua @@ -17,7 +17,6 @@ asn = _GET["asn"] vlan = _GET["vlan"] network = _GET["network"] country = _GET["country"] -antenna_mac = _GET["antenna_mac"] mac = _GET["mac"] os_ = _GET["os"] community = _GET["community"] @@ -114,10 +113,6 @@ else network_url = "" end -if(antenna_mac ~= nil) then - print('&antenna_mac='..antenna_mac) -end - if(mac ~= nil) then print('&mac='..mac) end @@ -133,18 +128,10 @@ if(prefs.is_categorization_enabled) then print ('host_rows_option["categorizatio if(prefs.is_httpbl_enabled) then print ('host_rows_option["httpbl"] = true;\n') end if(show_vlan) then print ('host_rows_option["vlan"] = true;\n') end -if(antenna_mac ~= nil) then - am = "antenna_mac="..antenna_mac - am_str = " [Antenna "..antenna_mac.."]" -else - am = nil - am_str = "" -end - print [[ host_rows_option["ip"] = true; $("#table-hosts").datatable({ - title: "Hosts List]] print(am_str) print [[", + title: "Hosts List", url: url_update , ]] @@ -179,7 +166,6 @@ if(mode == "all") then elseif ( asninfo ~= "" ) then print('title: "All '..protocol..' '..network_name..' Hosts'..asninfo..'",\n') elseif ( mac ~= "" ) then print('title: "All local '..protocol..' '..network_name..' Hosts'..mac..'",\n') elseif ( os_ ~= "" ) then print('title: "All '..os_..' Hosts",\n') - elseif ( am_str ~= "" ) then print('title: "All '..os_..' Hosts'..am_str..'",\n') else print('title: "All '..protocol..' '..network_name..' Hosts'..asninfo..'",\n') end elseif(mode == "local") then @@ -187,7 +173,6 @@ elseif(mode == "local") then elseif ( asninfo ~= "" ) then print('title: "Local '..protocol..' '..network_name..' Hosts'..asninfo..'",\n') elseif ( mac ~= "" ) then print('title: "Local local '..protocol..' '..network_name..' Hosts'..mac..'",\n') elseif ( os_ ~= "" ) then print('title: "Local Hosts'..os_..' Hosts",\n') - elseif ( am_str ~= "" ) then print('title: "Local '..protocol..' '..network_name..' Hosts'..country..am_str..'",\n') else print('title: "Local '..protocol..' '..network_name..' Hosts'..country..'",\n') end elseif(mode == "remote") then @@ -195,7 +180,6 @@ elseif(mode == "remote") then elseif ( asninfo ~= "" ) then print('title: "Remote '..protocol..' '..network_name..' Hosts'..asninfo..'",\n') elseif ( mac ~= "" ) then print('title: "Remote local '..protocol..' '..network_name..' Hosts'..mac..'",\n') elseif ( os_ ~= "" ) then print('title: "Remote '..os_..' Hosts",\n') - elseif ( am_str ~= "" ) then print('title: "Remote '..protocol..' '..network_name..' Hosts'..country..am_str..'",\n') else print('title: "Remote '..protocol..' '..network_name..' Hosts'..country..'",\n') end else diff --git a/scripts/lua/inc/menu.lua b/scripts/lua/inc/menu.lua index cef88e68cc..bb7894ef08 100644 --- a/scripts/lua/inc/menu.lua +++ b/scripts/lua/inc/menu.lua @@ -151,10 +151,6 @@ print(ntop.getHttpPrefix()) print [[/lua/hosts_matrix.lua"> Local Flow Matrix ]] -if(_ifstats["has_mesh_networks_traffic"]) then - print [[
  • Mesh Antenna Stats
  • ]] -end - print(" ") -- Devices diff --git a/scripts/lua/mesh_antenna_stats.lua b/scripts/lua/mesh_antenna_stats.lua deleted file mode 100644 index ee4dff9695..0000000000 --- a/scripts/lua/mesh_antenna_stats.lua +++ /dev/null @@ -1,73 +0,0 @@ --- --- (C) 2013-16 - ntop.org --- - -dirs = ntop.getDirs() -package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path - -require "lua_utils" - -sendHTTPHeader('text/html; charset=iso-8859-1') - -if (group_col == nil) then - group_col = "network" -end - -ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") - -active_page = "hosts" -dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") - -print [[ -
    -
    -