diff --git a/include/AlertsQueue.h b/include/AlertsQueue.h index eeb336c9f6..5660eabf49 100644 --- a/include/AlertsQueue.h +++ b/include/AlertsQueue.h @@ -36,9 +36,10 @@ class AlertsQueue { AlertsQueue(NetworkInterface *iface); void pushOutsideDhcpRangeAlert(u_int8_t* cli_mac, Mac *sender_mac, - u_int32_t ip, u_int32_t router_ip, int vlan_id); + u_int32_t ip, u_int32_t router_ip, VLANid vlan_id); void pushMacIpAssociationChangedAlert(u_int32_t ip, u_int8_t *old_mac, u_int8_t *new_mac, Mac *new_host_mac); - void pushBroadcastDomainTooLargeAlert(const u_int8_t *src_mac, const u_int8_t *dst_mac, u_int32_t spa, u_int32_t tpa, int vlan_id); + void pushBroadcastDomainTooLargeAlert(const u_int8_t *src_mac, const u_int8_t *dst_mac, + u_int32_t spa, u_int32_t tpa, VLANid vlan_id); void pushLoginTrace(const char*user, bool authorized); void pushNfqFlushedAlert(int queue_len, int queue_len_pct, int queue_dropped); }; diff --git a/include/Flow.h b/include/Flow.h index e8c75c9045..26bcba1e79 100644 --- a/include/Flow.h +++ b/include/Flow.h @@ -41,7 +41,8 @@ class Flow : public GenericHashEntry { IpAddress *cli_ip_addr, *srv_ip_addr; ICMPinfo *icmp_info; u_int8_t cli2srv_tos, srv2cli_tos; /* RFC 2474, 3168 */ - u_int16_t cli_port, srv_port, vlanId; + u_int16_t cli_port, srv_port; + VLANid vlanId; u_int32_t vrfId; u_int32_t srcAS, dstAS, prevAdjacentAS, nextAdjacentAS; u_int8_t protocol, src2dst_tcp_flags, dst2src_tcp_flags; @@ -279,7 +280,7 @@ class Flow : public GenericHashEntry { public: Flow(NetworkInterface *_iface, - u_int16_t _vlanId, u_int8_t _protocol, + VLANid _vlanId, u_int8_t _protocol, Mac *_cli_mac, IpAddress *_cli_ip, u_int16_t _cli_port, Mac *_srv_mac, IpAddress *_srv_ip, u_int16_t _srv_port, const ICMPinfo * const icmp_info, @@ -471,7 +472,7 @@ class Flow : public GenericHashEntry { inline const struct ndpi_in6_addr* get_srv_ipv6() const { return(srv_host->get_ip()->get_ipv6()); }; inline u_int16_t get_cli_port() const { return(ntohs(cli_port)); }; inline u_int16_t get_srv_port() const { return(ntohs(srv_port)); }; - inline u_int16_t get_vlan_id() const { return(vlanId); }; + inline VLANid get_vlan_id() const { return(vlanId); }; inline u_int8_t get_protocol() const { return(protocol); }; inline u_int64_t get_bytes() const { return(stats.get_cli2srv_bytes() + stats.get_srv2cli_bytes() ); }; inline u_int64_t get_bytes_cli2srv() const { return(stats.get_cli2srv_bytes()); }; @@ -564,7 +565,7 @@ class Flow : public GenericHashEntry { u_int32_t key(); static u_int32_t key(Host *cli, u_int16_t cli_port, Host *srv, u_int16_t srv_port, - u_int16_t vlan_id, + VLANid vlan_id, u_int16_t protocol); void lua(lua_State* vm, AddressTree * ptree, DetailsLevel details_level, bool asListElement); void lua_get_min_info(lua_State* vm); @@ -600,7 +601,7 @@ class Flow : public GenericHashEntry { bool equal(const IpAddress *_cli_ip, const IpAddress *_srv_ip, u_int16_t _cli_port, u_int16_t _srv_port, - u_int16_t _vlanId, u_int8_t _protocol, + VLANid _vlanId, u_int8_t _protocol, const ICMPinfo * const icmp_info, bool *src2srv_direction) const; void sumStats(nDPIStats *ndpi_stats, FlowStats *stats); diff --git a/include/FlowHash.h b/include/FlowHash.h index 2e3f0fc826..4e469f9289 100644 --- a/include/FlowHash.h +++ b/include/FlowHash.h @@ -30,7 +30,7 @@ class FlowHash : public GenericHash { Flow* find(IpAddress *src_ip, IpAddress *dst_ip, u_int16_t src_port, u_int16_t dst_port, - u_int16_t vlanId, u_int8_t protocol, + VLANid vlanId, u_int8_t protocol, const ICMPinfo * const icmp_info, bool *src2dst_direction, bool is_inline_call); diff --git a/include/Host.h b/include/Host.h index 6f46e12954..d62a0fa285 100644 --- a/include/Host.h +++ b/include/Host.h @@ -38,7 +38,8 @@ class Host : public GenericHashEntry, public HostAlertableEntity, public Score, } fingerprints; bool stats_reset_requested, name_reset_requested, data_delete_requested; - u_int16_t vlan_id, host_pool_id, host_services_bitmap; + u_int16_t host_pool_id, host_services_bitmap; + VLANid vlan_id; u_int8_t num_remote_access; HostStats *stats, *stats_shadow; time_t last_stats_reset; @@ -98,7 +99,7 @@ class Host : public GenericHashEntry, public HostAlertableEntity, public Score, Bitmap128 disabled_flow_alerts; time_t disabled_alerts_tstamp; - void initialize(Mac *_mac, u_int16_t _vlan_id); + void initialize(Mac *_mac, VLANid _vlan_id); void inlineSetOS(OSType _os); bool statsResetRequested(); void checkStatsReset(); @@ -115,8 +116,8 @@ class Host : public GenericHashEntry, public HostAlertableEntity, public Score, char* get_mac_based_tskey(Mac *mac, char *buf, size_t bufsize); public: - Host(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId); - Host(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, IpAddress *_ip); + Host(NetworkInterface *_iface, char *ipAddress, VLANid _vlanId); + Host(NetworkInterface *_iface, Mac *_mac, VLANid _vlanId, IpAddress *_ip); virtual ~Host(); @@ -182,7 +183,7 @@ class Host : public GenericHashEntry, public HostAlertableEntity, public Score, u_int16_t decScoreValue(u_int16_t score_decr, ScoreCategory score_category, bool as_client); inline u_int16_t get_host_pool() const { return(host_pool_id); }; - inline u_int16_t get_vlan_id() const { return(vlan_id); }; + inline VLANid get_vlan_id() const { return(vlan_id); }; char* get_name(char *buf, u_int buf_len, bool force_resolution_if_not_found); inline void incSentTcp(u_int32_t ooo_pkts, u_int32_t retr_pkts, u_int32_t lost_pkts, u_int32_t keep_alive_pkts) { @@ -384,7 +385,7 @@ class Host : public GenericHashEntry, public HostAlertableEntity, public Score, inline u_int32_t getTotalNumUnreachableIncomingFlows() const { return stats->getTotalUnreachableNumFlowsAsServer(); }; inline u_int32_t getTotalNumHostUnreachableOutgoingFlows() const { return stats->getTotalHostUnreachableNumFlowsAsClient(); }; inline u_int32_t getTotalNumHostUnreachableIncomingFlows() const { return stats->getTotalHostUnreachableNumFlowsAsServer(); }; - void splitHostVLAN(const char *at_sign_str, char *buf, int bufsize, u_int16_t *vlan_id); + void splitHostVLAN(const char *at_sign_str, char *buf, int bufsize, VLANid *vlan_id); char* get_country(char *buf, u_int buf_len); char* get_city(char *buf, u_int buf_len); void get_geocoordinates(float *latitude, float *longitude); diff --git a/include/HostHash.h b/include/HostHash.h index c845a0d1dc..e55d489127 100644 --- a/include/HostHash.h +++ b/include/HostHash.h @@ -33,7 +33,7 @@ class HostHash : public GenericHash { HostHash(NetworkInterface *iface, u_int _num_hashes, u_int _max_hash_size); /* Search for an host by IP and VLAN */ - Host* get(u_int16_t vlanId, IpAddress *key, bool is_inline_call); + Host* get(VLANid vlanId, IpAddress *key, bool is_inline_call); void incNumHTTPEntries(); void decNumHTTPEntries(); diff --git a/include/HostPools.h b/include/HostPools.h index 837f78b9e2..a353c4294b 100644 --- a/include/HostPools.h +++ b/include/HostPools.h @@ -77,7 +77,8 @@ class HostPools { u_int16_t getPool(Mac *m); u_int16_t getPoolByName(const char * const pool_name); - bool findIpPool(IpAddress *ip, u_int16_t vlan_id, u_int16_t *found_pool, ndpi_patricia_node_t **found_node); + bool findIpPool(IpAddress *ip, VLANid vlan_id, + u_int16_t *found_pool, ndpi_patricia_node_t **found_node); bool findMacPool(const u_int8_t * const mac, u_int16_t *found_pool); bool findMacPool(Mac *mac, u_int16_t *found_pool); void lua(lua_State *vm); diff --git a/include/ICMPinfo.h b/include/ICMPinfo.h index 8105783422..d64975cc22 100644 --- a/include/ICMPinfo.h +++ b/include/ICMPinfo.h @@ -50,7 +50,7 @@ class ICMPinfo { void print() const; u_int32_t key() const; bool equal(const ICMPinfo * const icmp_info) const; - void lua(lua_State* vm, AddressTree * ptree, NetworkInterface *iface, u_int16_t vlan_id) const; + void lua(lua_State* vm, AddressTree * ptree, NetworkInterface *iface, VLANid vlan_id) const; bool isPortUnreachable() const; bool isHostUnreachable(u_int8_t proto) const; }; diff --git a/include/LocalHost.h b/include/LocalHost.h index 64038a975d..188d5df8e6 100644 --- a/include/LocalHost.h +++ b/include/LocalHost.h @@ -27,11 +27,11 @@ class DoHDoTStats { private: IpAddress ip; - u_int16_t vlan_id; + VLANid vlan_id; u_int32_t num_uses; public: - DoHDoTStats(IpAddress i, u_int16_t id) { ip = i, vlan_id = id, num_uses = 0; } + DoHDoTStats(IpAddress i, VLANid id) { ip = i, vlan_id = id, num_uses = 0; } inline void incUses() { num_uses++; } @@ -68,8 +68,8 @@ class LocalHost : public Host, public SerializableElement { void luaDoHDot(lua_State *vm); public: - LocalHost(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, IpAddress *_ip); - LocalHost(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId); + LocalHost(NetworkInterface *_iface, Mac *_mac, VLANid _vlanId, IpAddress *_ip); + LocalHost(NetworkInterface *_iface, char *ipAddress, VLANid _vlanId); virtual ~LocalHost(); virtual void set_hash_entry_state_idle(); diff --git a/include/LuaEngine.h b/include/LuaEngine.h index 9aeab210d6..af9f32c93d 100644 --- a/include/LuaEngine.h +++ b/include/LuaEngine.h @@ -181,6 +181,7 @@ extern void lua_push_bool_table_entry(lua_State *L, const char *key, bool value) int ntop_lua_check(lua_State* vm, const char* func, int pos, int expected_type); -void get_host_vlan_info(char* lua_ip, char** host_ip, u_int16_t* vlan_id, char *buf, u_int buf_len); +void get_host_vlan_info(char* lua_ip, char** host_ip, + VLANid* vlan_id, char *buf, u_int buf_len); #endif /* _LUA_H_ */ diff --git a/include/NetworkInterface.h b/include/NetworkInterface.h index d8c5fcb64a..7000d4940b 100644 --- a/include/NetworkInterface.h +++ b/include/NetworkInterface.h @@ -280,7 +280,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { void deleteDataStructures(); NetworkInterface* getDynInterface(u_int64_t criteria, bool parser_interface); - Flow* getFlow(Mac *srcMac, Mac *dstMac, u_int16_t vlan_id, + Flow* getFlow(Mac *srcMac, Mac *dstMac, VLANid vlan_id, u_int32_t deviceIP, u_int32_t inIndex, u_int32_t outIndex, const ICMPinfo * const icmp_info, IpAddress *src_ip, IpAddress *dst_ip, @@ -298,7 +298,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { bool host_details, LocationPolicy location, char *countryFilter, char *mac_filter, - u_int16_t vlan_id, OSType osFilter, + VLANid vlan_id, OSType osFilter, u_int32_t asnFilter, int16_t networkFilter, u_int16_t pool_filter, bool filtered_hosts, bool blacklisted_hosts, bool hide_top_hidden, @@ -344,7 +344,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { bool checkPeriodicStatsUpdateTime(const struct timeval *tv); void topItemsCommit(const struct timeval *when); void checkMacIPAssociation(bool triggerEvent, u_char *_mac, u_int32_t ipv4, Mac *host_mac); - void checkDhcpIPRange(Mac *sender_mac, struct dhcp_packet *dhcp_reply, u_int16_t vlan_id); + void checkDhcpIPRange(Mac *sender_mac, struct dhcp_packet *dhcp_reply, VLANid vlan_id); void pollQueuedeCompanionEvents(); bool getInterfaceBooleanPref(const char *pref_key, bool default_pref_value) const; virtual void incEthStats(bool ingressPacket, u_int16_t proto, u_int32_t num_pkts, @@ -385,7 +385,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { virtual u_int32_t getFlowsHashSize(); void updateSitesStats(); - void updateBroadcastDomains(u_int16_t vlan_id, + void updateBroadcastDomains(VLANid vlan_id, const u_int8_t *src_mac, const u_int8_t *dst_mac, u_int32_t src, u_int32_t dst); @@ -406,7 +406,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { void luaTrafficMap(lua_State *vm); void enableTrafficMap(bool enable); inline bool isTrafficMapEnabled() { return(check_traffic_stats != NULL); }; - inline bool updateCheckTrafficMap(IpAddress *ip, Mac *mac, u_int16_t vlan_id, TrafficStatsMonitor updated_stats) { return(check_traffic_stats) ? check_traffic_stats->updateElement(ip, mac, vlan_id, updated_stats) : false; }; + inline bool updateCheckTrafficMap(IpAddress *ip, Mac *mac, VLANid vlan_id, TrafficStatsMonitor updated_stats) { return(check_traffic_stats) ? check_traffic_stats->updateElement(ip, mac, vlan_id, updated_stats) : false; }; #endif inline bool are_ip_reassignment_alerts_enabled() { return(enable_ip_reassignment_alerts); }; inline AddressTree* getInterfaceNetworks() { return(&interface_networks); }; @@ -480,7 +480,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { struct ndpi_detection_module_struct* get_ndpi_struct() const; inline bool is_purge_idle_interface() { return(purge_idle_flows_hosts); }; int dumpFlow(time_t when, Flow *f); - bool getHostMinInfo(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, u_int16_t vlan_id, bool only_ndpi_stats); + bool getHostMinInfo(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, VLANid vlan_id, bool only_ndpi_stats); /* Enqueue alert to a queue for processing and later delivery to recipients */ bool enqueueFlowAlert(FlowAlert *alert); @@ -494,7 +494,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { #ifdef NTOPNG_PRO void flushFlowDump(); #endif - void checkPointHostTalker(lua_State* vm, char *host_ip, u_int16_t vlan_id); + void checkPointHostTalker(lua_State* vm, char *host_ip, VLANid vlan_id); int dumpLocalHosts2redis(bool disable_purge); inline void incRetransmittedPkts(u_int32_t num) { tcpPacketStats.incRetr(num); }; inline void incOOOPkts(u_int32_t num) { tcpPacketStats.incOOO(num); }; @@ -574,14 +574,14 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { void updateLbdIdentifier(); void updateDiscardProbingTraffic(); void updateFlowsOnlyInterface(); - bool restoreHost(char *host_ip, u_int16_t vlan_id); + bool restoreHost(char *host_ip, VLANid vlan_id); void checkHostsToRestore(); u_int printAvailableInterfaces(bool printHelp, int idx, char *ifname, u_int ifname_len); - void findFlowHosts(u_int16_t vlan_id, + void findFlowHosts(VLANid vlan_id, Mac *src_mac, IpAddress *_src_ip, Host **src, Mac *dst_mac, IpAddress *_dst_ip, Host **dst); virtual Flow* findFlowByKeyAndHashId(u_int32_t key, u_int hash_id, AddressTree *allowed_hosts); - virtual Flow* findFlowByTuple(u_int16_t vlan_id, + virtual Flow* findFlowByTuple(VLANid vlan_id, IpAddress *src_ip, IpAddress *dst_ip, u_int16_t src_port, u_int16_t dst_port, u_int8_t l4_proto, @@ -599,7 +599,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { const struct bpf_timeval *when, const u_int64_t time, struct ndpi_ethhdr *eth, - u_int16_t vlan_id, + VLANid vlan_id, struct ndpi_iphdr *iph, struct ndpi_ipv6hdr *ip6, u_int16_t ip_offset, @@ -618,7 +618,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { virtual void lua(lua_State* vm); #ifdef NTOPNG_PRO - void luaTrafficMapHostStats(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, u_int16_t vlan_id); + void luaTrafficMapHostStats(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, VLANid vlan_id); #endif void luaScore(lua_State* vm); void luaAlertedFlows(lua_State* vm); @@ -626,9 +626,9 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { void luaNdpiStats(lua_State* vm); void luaPeriodicityFilteringMenu(lua_State* vm); void luaServiceFilteringMenu(lua_State* vm); - void luaPeriodicityStats(lua_State* vm, IpAddress *ip_address, u_int16_t vlan_id, u_int16_t host_pool_id, + void luaPeriodicityStats(lua_State* vm, IpAddress *ip_address, VLANid vlan_id, u_int16_t host_pool_id, bool unicast, u_int32_t first_seen, u_int16_t filter_ndpi_proto); - void luaServiceMap(lua_State* vm, IpAddress *ip_address, u_int16_t vlan_id, u_int16_t host_pool_id, + void luaServiceMap(lua_State* vm, IpAddress *ip_address, VLANid vlan_id, u_int16_t host_pool_id, bool unicast, u_int32_t first_seen, u_int16_t filter_ndpi_proto); void luaSubInterface(lua_State *vm); void luaServiceMapStatus(lua_State *vm); @@ -654,7 +654,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { AddressTree *allowed_hosts, bool host_details, LocationPolicy location, char *countryFilter, char *mac_filter, - u_int16_t vlan_id, OSType osFilter, + VLANid vlan_id, OSType osFilter, u_int32_t asnFilter, int16_t networkFilter, u_int16_t pool_filter, bool filtered_hosts, bool blacklisted_hosts, bool hide_top_hidden, @@ -749,13 +749,13 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { virtual void runHousekeepingTasks(); void runShutdownTasks(); - VLAN* getVLAN(u_int16_t vlanId, bool create_if_not_present, bool is_inline_call); + VLAN* getVLAN(VLANid vlanId, bool create_if_not_present, bool is_inline_call); AutonomousSystem *getAS(IpAddress *ipa, bool create_if_not_present, bool is_inline_call); OperatingSystem *getOS(OSType os, bool create_if_not_present, bool is_inline_call); Country* getCountry(const char *country_name, bool create_if_not_present, bool is_inline_call); virtual Mac* getMac(u_int8_t _mac[6], bool create_if_not_present, bool is_inline_call); - virtual Host* getHost(char *host_ip, u_int16_t vlan_id, bool is_inline_call); - bool getHostInfo(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, u_int16_t vlan_id); + virtual Host* getHost(char *host_ip, VLANid vlan_id, bool is_inline_call); + bool getHostInfo(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, VLANid vlan_id); void findPidFlows(lua_State *vm, u_int32_t pid); void findProcNameFlows(lua_State *vm, char *proc_name); void addAllAvailableInterfaces(); @@ -884,7 +884,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { bool getASInfo(lua_State* vm, u_int32_t asn); bool getOSInfo(lua_State* vm, OSType os_type); bool getCountryInfo(lua_State* vm, const char *country); - bool getVLANInfo(lua_State* vm, u_int16_t vlan_id); + bool getVLANInfo(lua_State* vm, VLANid vlan_id); inline void incNumHosts(bool local) { if(local) numLocalHosts++; numHosts++; }; inline void decNumHosts(bool local) { if(local) numLocalHosts--; numHosts--; }; inline void incNumL2Devices() { numL2Devices++; } @@ -937,7 +937,7 @@ class NetworkInterface : public NetworkInterfaceAlertableEntity { inline void decPoolNumL2Devices(u_int16_t id, bool is_inline_call) { if (host_pools) host_pools->decNumL2Devices(id, is_inline_call); }; - Host* findHostByIP(AddressTree *allowed_hosts, char *host_ip, u_int16_t vlan_id); + Host* findHostByIP(AddressTree *allowed_hosts, char *host_ip, VLANid vlan_id); #ifdef HAVE_NINDEX NIndexFlowDB* getNindex(); #endif diff --git a/include/Paginator.h b/include/Paginator.h index 85e2494ab2..541721f7fa 100644 --- a/include/Paginator.h +++ b/include/Paginator.h @@ -36,7 +36,7 @@ class Paginator { int l7proto_filter, l7category_filter; u_int16_t port_filter; int16_t local_network_filter; - u_int16_t vlan_id_filter; + VLANid vlan_id_filter; u_int8_t ip_version /* Either 4 or 6 */; u_int8_t l4_protocol; int8_t unicast_traffic, unidirectional_traffic, alerted_flows, filtered_flows; @@ -111,7 +111,7 @@ class Paginator { if(local_network_filter) { (*f) = local_network_filter; return true; } return false; } - inline bool vlanIdFilter(u_int16_t *f) const { + inline bool vlanIdFilter(VLANid *f) const { if(vlan_id_filter) { (*f) = vlan_id_filter; return true; } return false; } diff --git a/include/ParsedFlowCore.h b/include/ParsedFlowCore.h index b789d77bbc..9bf54cecdf 100644 --- a/include/ParsedFlowCore.h +++ b/include/ParsedFlowCore.h @@ -38,7 +38,8 @@ class ParsedFlowCore { u_int16_t src_port, dst_port; u_int32_t inIndex, outIndex; ndpi_proto l7_proto; - u_int16_t vlan_id, pkt_sampling_rate; + VLANid vlan_id; + u_int16_t pkt_sampling_rate; u_int32_t in_pkts, in_bytes, out_pkts, out_bytes, vrfId; u_int32_t in_fragments, out_fragments; u_int32_t src_as, dst_as, prev_adjacent_as, next_adjacent_as; diff --git a/include/RemoteHost.h b/include/RemoteHost.h index d8b012ef8e..e29f347d12 100644 --- a/include/RemoteHost.h +++ b/include/RemoteHost.h @@ -29,8 +29,8 @@ class RemoteHost : public Host { void initialize(); public: - RemoteHost(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, IpAddress *_ip); - RemoteHost(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId); + RemoteHost(NetworkInterface *_iface, Mac *_mac, VLANid _vlanId, IpAddress *_ip); + RemoteHost(NetworkInterface *_iface, char *ipAddress, VLANid _vlanId); virtual ~RemoteHost(); void set_hash_entry_state_idle(); diff --git a/include/VLAN.h b/include/VLAN.h index acdd6c9daa..eb66ef8e3c 100644 --- a/include/VLAN.h +++ b/include/VLAN.h @@ -26,7 +26,7 @@ class VLAN : public GenericHashEntry, public GenericTrafficElement, public SerializableElement, public Score { private: - u_int16_t vlan_id; + VLANid vlan_id; inline void incSentStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) { if(first_seen == 0) first_seen = t; @@ -39,16 +39,16 @@ class VLAN : public GenericHashEntry, public GenericTrafficElement, public Seria } public: - VLAN(NetworkInterface *_iface, u_int16_t _vlan_id); + VLAN(NetworkInterface *_iface, VLANid _vlan_id); ~VLAN(); void set_hash_entry_state_idle(); inline u_int16_t getNumHosts() { return getUses(); } inline u_int32_t key() { return(vlan_id); } - inline u_int16_t get_vlan_id() { return(vlan_id); } + inline VLANid get_vlan_id() { return(vlan_id); } - bool equal(u_int16_t _vlan_id); + bool equal(VLANid _vlan_id); inline void incStats(time_t when, u_int16_t proto_id, u_int64_t sent_packets, u_int64_t sent_bytes, diff --git a/include/VLANAddressTree.h b/include/VLANAddressTree.h index c64880bfab..c062c58754 100644 --- a/include/VLANAddressTree.h +++ b/include/VLANAddressTree.h @@ -24,6 +24,21 @@ class AddressTree; +/* +typedef struct { + // u_int32_t vlan_id:12, observation_domain_id:20; +} VLANid; +*/ + +/* + vlan_id: lower 12 bits + observation_domain_id: upper 20 bits + */ +typedef u_int32_t VLANid; + +inline u_int16_t filterVLANid(VLANid id) { return((u_int16_t)(id & 0xFFF)); } +inline u_int32_t filterObservationDomainId(VLANid id) { return((id >> 12) & 0xFFFFF); } + class VLANAddressTree { protected: AddressTree **tree; @@ -32,13 +47,13 @@ class VLANAddressTree { VLANAddressTree(); ~VLANAddressTree(); - bool addAddress(u_int16_t vlan_id, char *_net, const int16_t user_data = -1); - bool addAddresses(u_int16_t vlan_id, char *net, const int16_t user_data = -1); + bool addAddress(VLANid vlan_id, char *_net, const int16_t user_data = -1); + bool addAddresses(VLANid vlan_id, char *net, const int16_t user_data = -1); - int16_t findAddress(u_int16_t vlan_id, int family, void *addr, u_int8_t *network_mask_bits = NULL); - int16_t findMac(u_int16_t vlan_id, const u_int8_t addr[]); + int16_t findAddress(VLANid vlan_id, int family, void *addr, u_int8_t *network_mask_bits = NULL); + int16_t findMac(VLANid vlan_id, const u_int8_t addr[]); - inline AddressTree *getAddressTree(u_int16_t vlan_id) { return tree[vlan_id]; }; + inline AddressTree *getAddressTree(VLANid vlan_id) { return tree[vlan_id]; }; }; #endif diff --git a/include/VLANHash.h b/include/VLANHash.h index b5f446787a..4c53db6624 100644 --- a/include/VLANHash.h +++ b/include/VLANHash.h @@ -31,7 +31,7 @@ class VLANHash : public GenericHash { public: VLANHash(NetworkInterface *iface, u_int _num_hashes, u_int _max_hash_size); - VLAN* get(u_int16_t vlan_id, bool is_inline_call); + VLAN* get(VLANid vlan_id, bool is_inline_call); #ifdef VLAN_DEBUG void printHash(); diff --git a/include/ViewInterface.h b/include/ViewInterface.h index e24d35e46e..1faf0af0c2 100644 --- a/include/ViewInterface.h +++ b/include/ViewInterface.h @@ -84,7 +84,7 @@ class ViewInterface : public NetworkInterface { virtual u_int32_t getFlowsHashSize(); virtual Flow* findFlowByKeyAndHashId(u_int32_t key, u_int hash_id, AddressTree *allowed_hosts); - virtual Flow* findFlowByTuple(u_int16_t vlan_id, + virtual Flow* findFlowByTuple(VLANid vlan_id, IpAddress *src_ip, IpAddress *dst_ip, u_int16_t src_port, u_int16_t dst_port, u_int8_t l4_proto, diff --git a/src/AlertsQueue.cpp b/src/AlertsQueue.cpp index 148d6d6e92..1f13b87ca7 100644 --- a/src/AlertsQueue.cpp +++ b/src/AlertsQueue.cpp @@ -53,7 +53,7 @@ void AlertsQueue::pushAlertJson(ndpi_serializer *alert, const char *atype, const /* **************************************************** */ void AlertsQueue::pushOutsideDhcpRangeAlert(u_int8_t *cli_mac, Mac *sender_mac, - u_int32_t ip, u_int32_t router_ip, int vlan_id) { + u_int32_t ip, u_int32_t router_ip, VLANid vlan_id) { ndpi_serializer *tlv; char name[64]; @@ -128,7 +128,7 @@ void AlertsQueue::pushMacIpAssociationChangedAlert(u_int32_t ip, u_int8_t *old_m /* **************************************************** */ void AlertsQueue::pushBroadcastDomainTooLargeAlert(const u_int8_t *src_mac, const u_int8_t *dst_mac, - u_int32_t spa, u_int32_t tpa, int vlan_id) { + u_int32_t spa, u_int32_t tpa, VLANid vlan_id) { ndpi_serializer *tlv; if(ntop->getPrefs()->are_alerts_disabled()) diff --git a/src/Flow.cpp b/src/Flow.cpp index 70eac63a66..fe5820872b 100644 --- a/src/Flow.cpp +++ b/src/Flow.cpp @@ -33,7 +33,7 @@ const ndpi_protocol Flow::ndpiUnknownProtocol = { NDPI_PROTOCOL_UNKNOWN, /* *************************************** */ Flow::Flow(NetworkInterface *_iface, - u_int16_t _vlanId, u_int8_t _protocol, + VLANid _vlanId, u_int8_t _protocol, Mac *_cli_mac, IpAddress *_cli_ip, u_int16_t _cli_port, Mac *_srv_mac, IpAddress *_srv_ip, u_int16_t _srv_port, const ICMPinfo * const _icmp_info, @@ -1874,7 +1874,7 @@ void Flow::update_pools_stats(NetworkInterface *iface, bool Flow::equal(const IpAddress *_cli_ip, const IpAddress *_srv_ip, u_int16_t _cli_port, u_int16_t _srv_port, - u_int16_t _vlanId, u_int8_t _protocol, + VLANid _vlanId, u_int8_t _protocol, const ICMPinfo * const _icmp_info, bool *src2srv_direction) const { const IpAddress *cli_ip = get_cli_ip_addr(), *srv_ip = get_srv_ip_addr(); @@ -2021,7 +2021,9 @@ void Flow::lua(lua_State* vm, AddressTree * ptree, lua_get_info(vm, false /* Server */); if(vrfId) lua_push_uint64_table_entry(vm, "vrfId", vrfId); - lua_push_uint64_table_entry(vm, "vlan", get_vlan_id()); + + lua_push_uint32_table_entry(vm, "vlan", filterVLANid(get_vlan_id())); + lua_push_uint32_table_entry(vm, "observation_domain_id", filterObservationDomainId(get_vlan_id())); if(srcAS) lua_push_int32_table_entry(vm, "src_as", srcAS); @@ -2327,7 +2329,7 @@ u_int32_t Flow::key() { u_int32_t Flow::key(Host *_cli, u_int16_t _cli_port, Host *_srv, u_int16_t _srv_port, - u_int16_t _vlan_id, + VLANid _vlan_id, u_int16_t _protocol) { u_int32_t k = _cli_port + _srv_port + _vlan_id + _protocol; @@ -2798,7 +2800,9 @@ void Flow::alert2JSON(FlowAlert *alert, ndpi_serializer *s) { // flows don't have any pool for now ndpi_serialize_string_int32(s, "pool_id", NO_HOST_POOL_ID); - ndpi_serialize_string_int32(s, "vlan_id", get_vlan_id()); + ndpi_serialize_string_int32(s, "vlan_id", filterVLANid(get_vlan_id())); + ndpi_serialize_string_int32(s, "observation_domain_id", filterObservationDomainId(get_vlan_id())); + ndpi_serialize_string_int32(s, "proto", get_protocol()); if(hasRisks()) diff --git a/src/FlowHash.cpp b/src/FlowHash.cpp index e5294e1afc..f9e7fb299a 100644 --- a/src/FlowHash.cpp +++ b/src/FlowHash.cpp @@ -34,7 +34,7 @@ static u_int16_t max_num_loops = 0; Flow* FlowHash::find(IpAddress *src_ip, IpAddress *dst_ip, u_int16_t src_port, u_int16_t dst_port, - u_int16_t vlanId, u_int8_t protocol, + VLANid vlanId, u_int8_t protocol, const ICMPinfo * const icmp_info, bool *src2dst_direction, bool is_inline_call) { diff --git a/src/Host.cpp b/src/Host.cpp index ba878d9ab8..2665e9e020 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -23,7 +23,7 @@ /* *************************************** */ -Host::Host(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId) : GenericHashEntry(_iface), +Host::Host(NetworkInterface *_iface, char *ipAddress, VLANid _vlanId) : GenericHashEntry(_iface), HostAlertableEntity(_iface, alert_entity_host), Score(_iface), HostCallbacksStatus() { ip.set(ipAddress); initialize(NULL, _vlanId); @@ -32,7 +32,7 @@ Host::Host(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId) : Gener /* *************************************** */ Host::Host(NetworkInterface *_iface, Mac *_mac, - u_int16_t _vlanId, IpAddress *_ip) : GenericHashEntry(_iface), HostAlertableEntity(_iface, alert_entity_host), Score(_iface), HostCallbacksStatus() { + VLANid _vlanId, IpAddress *_ip) : GenericHashEntry(_iface), HostAlertableEntity(_iface, alert_entity_host), Score(_iface), HostCallbacksStatus() { ip.set(_ip); #ifdef BROADCAST_DEBUG @@ -169,7 +169,7 @@ void Host::housekeep(time_t t) { /* *************************************** */ -void Host::initialize(Mac *_mac, u_int16_t _vlanId) { +void Host::initialize(Mac *_mac, VLANid _vlanId) { char buf[64]; stats = NULL; /* it will be instantiated by specialized classes */ @@ -391,7 +391,8 @@ void Host::lua_get_ip(lua_State *vm) const { char ip_buf[64]; lua_push_str_table_entry(vm, "ip", ip.print(ip_buf, sizeof(ip_buf))); - lua_push_uint64_table_entry(vm, "vlan", get_vlan_id()); + lua_push_uint32_table_entry(vm, "vlan", filterVLANid(get_vlan_id())); + lua_push_uint32_table_entry(vm, "observation_domain_id", filterObservationDomainId(get_vlan_id())); } /* ***************************************************** */ @@ -665,7 +666,9 @@ void Host::lua(lua_State* vm, AddressTree *ptree, lua_newtable(vm); lua_push_str_table_entry(vm, "ip", (ipaddr = printMask(ip_buf, sizeof(ip_buf)))); - lua_push_uint64_table_entry(vm, "vlan", vlan_id); + lua_push_uint32_table_entry(vm, "vlan", filterVLANid(get_vlan_id())); + lua_push_uint32_table_entry(vm, "observation_domain_id", filterObservationDomainId(get_vlan_id())); + lua_push_bool_table_entry(vm, "hiddenFromTop", isHiddenFromTop()); lua_push_uint64_table_entry(vm, "ipkey", ip.key()); @@ -1228,7 +1231,7 @@ void Host::luaUsedQuotas(lua_State* vm) { /* *************************************** */ /* Splits a string in the format hostip@vlanid: *buf=hostip, *vlan_id=vlanid */ -void Host::splitHostVLAN(const char *at_sign_str, char*buf, int bufsize, u_int16_t *vlan_id) { +void Host::splitHostVLAN(const char *at_sign_str, char*buf, int bufsize, VLANid *vlan_id) { int size; const char *vlan_ptr = strchr(at_sign_str, '@'); diff --git a/src/HostHash.cpp b/src/HostHash.cpp index 687f2c5607..659b8a7262 100644 --- a/src/HostHash.cpp +++ b/src/HostHash.cpp @@ -30,7 +30,7 @@ HostHash::HostHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_ /* ************************************ */ -Host* HostHash::get(u_int16_t vlanId, IpAddress *key, bool is_inline_call) { +Host* HostHash::get(VLANid vlanId, IpAddress *key, bool is_inline_call) { u_int32_t hash = (key->key() % num_hashes); if(table[hash] == NULL) { diff --git a/src/HostPools.cpp b/src/HostPools.cpp index 538719a0de..cd83079628 100644 --- a/src/HostPools.cpp +++ b/src/HostPools.cpp @@ -356,7 +356,8 @@ void HostPools::reloadPools() { char kname[CONST_MAX_LEN_REDIS_KEY]; char **pools, **pool_members, *at, *member; int num_pools, num_members, actual_num_members; - u_int16_t _pool_id, vlan_id; + u_int16_t _pool_id; + VLANid vlan_id; VLANAddressTree *new_tree; HostPoolStats **new_stats; Redis *redis = ntop->getRedis(); @@ -535,7 +536,8 @@ bool HostPools::findMacPool(Mac *mac, u_int16_t *found_pool) { /* *************************************** */ -bool HostPools::findIpPool(IpAddress *ip, u_int16_t vlan_id, u_int16_t *found_pool, ndpi_patricia_node_t **found_node) { +bool HostPools::findIpPool(IpAddress *ip, VLANid vlan_id, + u_int16_t *found_pool, ndpi_patricia_node_t **found_node) { VLANAddressTree *cur_tree; /* must use this as tree can be swapped */ #ifdef HOST_POOLS_DEBUG char buf[128]; diff --git a/src/ICMPinfo.cpp b/src/ICMPinfo.cpp index 09a42dfd8c..f9005db798 100644 --- a/src/ICMPinfo.cpp +++ b/src/ICMPinfo.cpp @@ -165,7 +165,8 @@ bool ICMPinfo::equal(const ICMPinfo * const _icmp_info) const { /* *************************************** */ -void ICMPinfo::lua(lua_State* vm, AddressTree * ptree, NetworkInterface *iface, u_int16_t vlan_id) const { +void ICMPinfo::lua(lua_State* vm, AddressTree * ptree, + NetworkInterface *iface, VLANid vlan_id) const { char buf[64]; if(vm && unreach) { diff --git a/src/LocalHost.cpp b/src/LocalHost.cpp index d208ef01e5..5e1c37bfa6 100644 --- a/src/LocalHost.cpp +++ b/src/LocalHost.cpp @@ -23,7 +23,7 @@ /* *************************************** */ -LocalHost::LocalHost(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, +LocalHost::LocalHost(NetworkInterface *_iface, Mac *_mac, VLANid _vlanId, IpAddress *_ip) : Host(_iface, _mac, _vlanId, _ip) { #ifdef LOCALHOST_DEBUG char buf[48]; @@ -37,7 +37,7 @@ LocalHost::LocalHost(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, /* *************************************** */ LocalHost::LocalHost(NetworkInterface *_iface, char *ipAddress, - u_int16_t _vlanId) : Host(_iface, ipAddress, _vlanId) { + VLANid _vlanId) : Host(_iface, ipAddress, _vlanId) { initialize(); } diff --git a/src/LuaEngineInterface.cpp b/src/LuaEngineInterface.cpp index 12e2554d79..6b95c3f70d 100644 --- a/src/LuaEngineInterface.cpp +++ b/src/LuaEngineInterface.cpp @@ -507,7 +507,7 @@ static int ntop_interface_live_capture(lua_State* vm) { Host *h; char host_ip[64]; char *key; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; get_host_vlan_info((char*)lua_tostring(vm, 1), &key, &vlan_id, host_ip, sizeof(host_ip)); @@ -643,7 +643,7 @@ static int ntop_interface_reset_host_stats(lua_State* vm, bool delete_data) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char buf[64], *host_ip; Host *host; - u_int16_t vlan_id; + VLANid vlan_id; bool reset_blacklisted = false; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -1122,7 +1122,7 @@ static int ntop_get_host_used_quotas_stats(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); Host *h; char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[128]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -1567,7 +1567,7 @@ static int ntop_get_interface_mac_hosts(lua_State* vm) { static int ntop_set_host_operating_system(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip = NULL, buf[64]; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; OSType os = os_unknown; Host *host; @@ -1903,7 +1903,7 @@ static int ntop_get_interface_os_info(lua_State* vm) { static int ntop_get_interface_vlan_info(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); - u_int16_t vlan_id; + VLANid vlan_id; if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER) != CONST_LUA_OK) return(CONST_LUA_ERROR); vlan_id = (u_int16_t)lua_tonumber(vm, 1); @@ -1995,7 +1995,7 @@ static int ntop_get_interface_flows_info(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char buf[64]; char *host_ip = NULL; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; Host *host = NULL; Paginator *p = NULL; u_int32_t begin_slot = 0; @@ -2140,7 +2140,7 @@ static int ntop_get_interface_network_stats(lua_State* vm) { static int ntop_get_interface_host_info(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -2162,7 +2162,7 @@ static int ntop_get_interface_host_info(lua_State* vm) { static int ntop_get_interface_host_country(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; Host* h = NULL; @@ -2405,7 +2405,7 @@ static int ntop_getsflowdeviceinfo(lua_State* vm) { static int ntop_restore_interface_host(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; AddressTree *ptree = get_allowed_nets(vm); @@ -2430,8 +2430,11 @@ static int ntop_restore_interface_host(lua_State* vm) { static int ntop_get_interface_flow_key(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); Host *cli, *srv; - char *cli_name = NULL; u_int16_t cli_vlan = 0; u_int16_t cli_port = 0; - char *srv_name = NULL; u_int16_t srv_vlan = 0; u_int16_t srv_port = 0; + char *cli_name = NULL; + u_int16_t cli_port = 0; + char *srv_name = NULL; + u_int16_t srv_port = 0; + VLANid cli_vlan = 0, srv_vlan = 0; u_int16_t protocol; char cli_buf[256], srv_buf[256]; @@ -2513,7 +2516,7 @@ static int ntop_get_interface_find_flow_by_key_and_hash_id(lua_State* vm) { static int ntop_get_interface_find_flow_by_tuple(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); IpAddress src_ip_addr, dst_ip_addr; - u_int16_t vlan_id, src_port, dst_port; + VLANid vlan_id, src_port, dst_port; u_int8_t l4_proto; char *src_ip, *dst_ip; Flow *f; @@ -2817,7 +2820,7 @@ static int ntop_update_flows_only_interface(lua_State* vm) { static int ntop_update_host_traffic_policy(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -2972,7 +2975,7 @@ static int ntop_reload_host_prefs(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char buf[64], *host_ip; Host *host; - u_int16_t vlan_id; + VLANid vlan_id; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); if(!ntop_interface) return(CONST_LUA_ERROR); @@ -3486,7 +3489,7 @@ static int ntop_get_active_flows_stats(lua_State* vm) { nDPIStats ndpi_stats; FlowStats stats; char *host_ip = NULL; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; bool only_traffic_stats = false; Host *host = NULL; @@ -3606,7 +3609,7 @@ static int ntop_checkpoint_host_talker(lua_State* vm) { int ifid; NetworkInterface *iface = NULL; char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -3657,7 +3660,7 @@ static int ntop_reset_pools_quotas(lua_State *vm) { static int ntop_find_member_pool(lua_State *vm) { char *address; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; bool is_mac; ndpi_patricia_node_t *target_node = NULL; u_int16_t pool_id; @@ -3871,7 +3874,7 @@ static int ntop_interface_release_engaged_alerts(lua_State* vm) { static int ntop_interface_inc_total_host_alerts(lua_State* vm) { NetworkInterface *iface = getCurrentInterface(vm); - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; #ifdef UNUSED AlertType alert_type; #endif @@ -3904,7 +3907,7 @@ static int ntop_get_interface_periodicity_map(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); IpAddress *ip = NULL; char * l7_proto = NULL; - u_int16_t vlan_id = 0, host_pool_id = 0, filter_ndpi_proto = 0; + VLANid vlan_id = 0, host_pool_id = 0, filter_ndpi_proto = 0; u_int32_t first_seen = 0; bool unicast = false; @@ -3957,7 +3960,7 @@ static int ntop_get_interface_service_map(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); IpAddress *ip = NULL; char *l7_proto = NULL; - u_int16_t vlan_id = 0, host_pool_id = 0, filter_ndpi_proto = 0; + VLANid vlan_id = 0, host_pool_id = 0, filter_ndpi_proto = 0; u_int32_t first_seen = 0; bool unicast = false; @@ -4148,7 +4151,7 @@ static int ntop_get_address_info(lua_State* vm) { static int ntop_interface_get_traffic_map_host_stats(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -4173,7 +4176,7 @@ static int ntop_interface_get_traffic_map_host_stats(lua_State* vm) { static int ntop_get_ndpi_host_stats(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -4199,7 +4202,7 @@ static int ntop_get_ndpi_host_stats(lua_State* vm) { static int ntop_get_interface_get_host_min_info(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); diff --git a/src/LuaEngineNtop.cpp b/src/LuaEngineNtop.cpp index b1a9978a12..0eb655ab33 100644 --- a/src/LuaEngineNtop.cpp +++ b/src/LuaEngineNtop.cpp @@ -57,8 +57,8 @@ int ntop_lua_check(lua_State* vm, const char* func, int pos, int expected_type) /* ****************************************** */ void get_host_vlan_info(char* lua_ip, char** host_ip, - u_int16_t* vlan_id, - char *buf, u_int buf_len) { + VLANid* vlan_id, + char *buf, u_int buf_len) { char *where, *vlan = NULL; snprintf(buf, buf_len, "%s", lua_ip); @@ -3177,7 +3177,7 @@ static int ntop_is_allowed_interface(lua_State* vm) { static int ntop_is_allowed_network(lua_State* vm) { bool rv = false; - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char *host, buf[64]; AddressTree *allowed_nets = get_allowed_nets(vm); @@ -3215,7 +3215,7 @@ static int ntop_is_local_interface_address(lua_State* vm) { static int ntop_get_resolved_address(lua_State* vm) { char *key, *tmp,rsp[256],value[64]; Redis *redis = ntop->getRedis(); - u_int16_t vlan_id = 0; + VLANid vlan_id = 0; char buf[64]; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); @@ -4415,7 +4415,7 @@ static void ntop_reset_host_name(lua_State* vm, char *address) { NetworkInterface *iface; char buf[64], *host_ip; Host *host; - u_int16_t vlan_id; + VLANid vlan_id; get_host_vlan_info(address, &host_ip, &vlan_id, buf, sizeof(buf)); diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index 2ba4be509e..9b964dec65 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -880,7 +880,7 @@ bool NetworkInterface::walker(u_int32_t *begin_slot, /* **************************************************** */ Flow* NetworkInterface::getFlow(Mac *srcMac, Mac *dstMac, - u_int16_t vlan_id, u_int32_t deviceIP, + VLANid vlan_id, u_int32_t deviceIP, u_int32_t inIndex, u_int32_t outIndex, const ICMPinfo * const icmp_info, IpAddress *src_ip, IpAddress *dst_ip, @@ -1142,7 +1142,7 @@ bool NetworkInterface::processPacket(u_int32_t bridge_iface_idx, const struct bpf_timeval *when, const u_int64_t packet_time, struct ndpi_ethhdr *eth, - u_int16_t vlan_id, + VLANid vlan_id, struct ndpi_iphdr *iph, struct ndpi_ipv6hdr *ip6, u_int16_t ip_offset, @@ -2957,7 +2957,7 @@ void NetworkInterface::cleanup() { /* **************************************************** */ -void NetworkInterface::findFlowHosts(u_int16_t vlanId, +void NetworkInterface::findFlowHosts(VLANid vlanId, Mac *src_mac, IpAddress *_src_ip, Host **src, Mac *dst_mac, IpAddress *_dst_ip, Host **dst) { int16_t local_network_id; @@ -3434,7 +3434,7 @@ void NetworkInterface::resetPoolsStats(u_int16_t pool_filter) { struct host_find_info { char *host_to_find; - u_int16_t vlan_id; + VLANid vlan_id; Host *h; }; @@ -3455,7 +3455,7 @@ struct os_find_info { /* **************************************************** */ struct vlan_find_info { - u_int16_t vlan_id; + VLANid vlan_id; VLAN *vl; }; @@ -3470,7 +3470,7 @@ struct country_find_info { struct mac_find_info { u_int8_t mac[6]; - u_int16_t vlan_id; + VLANid vlan_id; Mac *m; DeviceType dtype; lua_State *vm; @@ -3580,7 +3580,7 @@ static bool find_vlan_by_vlan_id(GenericHashEntry *he, void *user_data, bool *ma /* Enqueues an host restore request on the interface. The checkHostsToRestore * function, in the datapath, will take care of restoring the host. */ -bool NetworkInterface::restoreHost(char *host_ip, u_int16_t vlan_id) { +bool NetworkInterface::restoreHost(char *host_ip, VLANid vlan_id) { char buf[64]; bool rv; @@ -3593,7 +3593,7 @@ bool NetworkInterface::restoreHost(char *host_ip, u_int16_t vlan_id) { /* **************************************************** */ -Host* NetworkInterface::getHost(char *host_ip, u_int16_t vlan_id, bool isInlineCall) { +Host* NetworkInterface::getHost(char *host_ip, VLANid vlan_id, bool isInlineCall) { struct in_addr a4; struct in6_addr a6; Host *h = NULL; @@ -3675,7 +3675,7 @@ void NetworkInterface::updateFlowProfiles() { bool NetworkInterface::getHostInfo(lua_State* vm, AddressTree *allowed_hosts, - char *host_ip, u_int16_t vlan_id) { + char *host_ip, VLANid vlan_id) { Host *h; bool ret; @@ -3693,7 +3693,7 @@ bool NetworkInterface::getHostInfo(lua_State* vm, /* **************************************************** */ #ifdef NTOPNG_PRO -void NetworkInterface::luaTrafficMapHostStats(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, u_int16_t vlan_id) { +void NetworkInterface::luaTrafficMapHostStats(lua_State* vm, AddressTree *allowed_hosts, char *host_ip, VLANid vlan_id) { Host *h; if(!check_traffic_stats) @@ -3712,7 +3712,7 @@ void NetworkInterface::luaTrafficMapHostStats(lua_State* vm, AddressTree *allowe bool NetworkInterface::getHostMinInfo(lua_State* vm, AddressTree *allowed_hosts, - char *host_ip, u_int16_t vlan_id, + char *host_ip, VLANid vlan_id, bool only_ndpi_stats) { Host *h; bool ret; @@ -3748,7 +3748,7 @@ void NetworkInterface::checkReloadHostsBroadcastDomain() { /* **************************************************** */ -void NetworkInterface::checkPointHostTalker(lua_State* vm, char *host_ip, u_int16_t vlan_id) { +void NetworkInterface::checkPointHostTalker(lua_State* vm, char *host_ip, VLANid vlan_id) { Host *h; if(host_ip && (h = getHost(host_ip, vlan_id, false /* Not an inline call */))) @@ -3760,7 +3760,7 @@ void NetworkInterface::checkPointHostTalker(lua_State* vm, char *host_ip, u_int1 /* **************************************************** */ Host* NetworkInterface::findHostByIP(AddressTree *allowed_hosts, - char *host_ip, u_int16_t vlan_id) { + char *host_ip, VLANid vlan_id) { if(host_ip != NULL) { Host *h = getHost(host_ip, vlan_id, false /* Not an inline call */); @@ -3808,7 +3808,7 @@ struct flowHostRetriever { bool dhcpOnly; /* Not used in flow_search_walker */ bool hideTopHidden; /* Not used in flow_search_walker */ const AddressTree * cidr_filter; /* Not used in flow_search_walker */ - u_int16_t vlan_id; + VLANid vlan_id; OSType osFilter; u_int32_t asnFilter; u_int32_t uidFilter; @@ -3838,7 +3838,8 @@ static bool flow_matches(Flow *f, struct flowHostRetriever *retriever) { int ndpi_proto, ndpi_cat; u_int16_t port; int16_t local_network_id; - u_int16_t vlan_id = 0, cli_pool, srv_pool, pool_filter; + VLANid vlan_id = 0; + u_int16_t cli_pool, srv_pool, pool_filter; AlertLevelGroup flow_status_severity_filter = alert_level_group_none; ndpi_patricia_node_t *srv_target_node = NULL, *cli_target_node = NULL; IpAddress *cli_ip = (IpAddress *) f->get_srv_ip_addr(); @@ -4931,7 +4932,7 @@ int NetworkInterface::sortHosts(u_int32_t *begin_slot, bool host_details, LocationPolicy location, char *countryFilter, char *mac_filter, - u_int16_t vlan_id, OSType osFilter, + VLANid vlan_id, OSType osFilter, u_int32_t asnFilter, int16_t networkFilter, u_int16_t pool_filter, bool filtered_hosts, bool blacklisted_hosts, bool hide_top_hidden, @@ -5222,7 +5223,7 @@ int NetworkInterface::getActiveHostsList(lua_State* vm, AddressTree *allowed_hosts, bool host_details, LocationPolicy location, char *countryFilter, char *mac_filter, - u_int16_t vlan_id, OSType osFilter, + VLANid vlan_id, OSType osFilter, u_int32_t asnFilter, int16_t networkFilter, u_int16_t pool_filter, bool filtered_hosts, bool blacklisted_hosts, bool hide_top_hidden, @@ -6064,7 +6065,7 @@ Mac* NetworkInterface::getMac(u_int8_t _mac[6], bool create_if_not_present, bool /* **************************************************** */ -VLAN* NetworkInterface::getVLAN(u_int16_t vlanId, bool create_if_not_present, bool isInlineCall) { +VLAN* NetworkInterface::getVLAN(VLANid vlanId, bool create_if_not_present, bool isInlineCall) { VLAN *ret = NULL; if(!vlans_hash) return(NULL); @@ -6233,7 +6234,7 @@ Flow* NetworkInterface::findFlowByKeyAndHashId(u_int32_t key, u_int hash_id, Add /* **************************************************** */ -Flow* NetworkInterface::findFlowByTuple(u_int16_t vlan_id, +Flow* NetworkInterface::findFlowByTuple(VLANid vlan_id, IpAddress *src_ip, IpAddress *dst_ip, u_int16_t src_port, u_int16_t dst_port, u_int8_t l4_proto, @@ -6828,7 +6829,7 @@ void NetworkInterface::reloadHideFromTop(bool refreshHosts) { int num_nets = ntop->getRedis()->smembers(kname, &networks); char *at; - u_int16_t vlan_id; + VLANid vlan_id; for(int i=0; iempty()) @@ -8660,7 +8661,7 @@ void NetworkInterface::luaServiceFilteringMenu(lua_State* vm) { /* *************************************** */ void NetworkInterface::luaPeriodicityStats(lua_State* vm, IpAddress *ip_address, - u_int16_t vlan_id, u_int16_t host_pool_id, bool unicast, + VLANid vlan_id, u_int16_t host_pool_id, bool unicast, u_int32_t first_seen, u_int16_t filter_ndpi_proto) { #if defined(NTOPNG_PRO) && !defined(HAVE_NEDGE) if(pMap) { @@ -8675,7 +8676,7 @@ void NetworkInterface::luaPeriodicityStats(lua_State* vm, IpAddress *ip_address, /* *************************************** */ void NetworkInterface::luaServiceMap(lua_State* vm, IpAddress *ip_address, - u_int16_t vlan_id, u_int16_t host_pool_id, bool unicast, + VLANid vlan_id, u_int16_t host_pool_id, bool unicast, u_int32_t first_seen, u_int16_t filter_ndpi_proto) { #if defined(NTOPNG_PRO) && !defined(HAVE_NEDGE) if(sMap) { diff --git a/src/RemoteHost.cpp b/src/RemoteHost.cpp index 0efa79fb18..8e0de1987c 100644 --- a/src/RemoteHost.cpp +++ b/src/RemoteHost.cpp @@ -23,7 +23,7 @@ /* *************************************** */ -RemoteHost::RemoteHost(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, IpAddress *_ip) : Host(_iface, _mac, _vlanId, _ip) { +RemoteHost::RemoteHost(NetworkInterface *_iface, Mac *_mac, VLANid _vlanId, IpAddress *_ip) : Host(_iface, _mac, _vlanId, _ip) { #ifdef REMOTEHOST_DEBUG char buf[48]; ntop->getTrace()->traceEvent(TRACE_NORMAL, "Instantiating REMOTE host %s", _ip ? _ip->print(buf, sizeof(buf)) : ""); @@ -33,7 +33,7 @@ RemoteHost::RemoteHost(NetworkInterface *_iface, Mac *_mac, u_int16_t _vlanId, I /* *************************************** */ -RemoteHost::RemoteHost(NetworkInterface *_iface, char *ipAddress, u_int16_t _vlanId) : Host(_iface, ipAddress, _vlanId) { +RemoteHost::RemoteHost(NetworkInterface *_iface, char *ipAddress, VLANid _vlanId) : Host(_iface, ipAddress, _vlanId) { initialize(); } diff --git a/src/VLAN.cpp b/src/VLAN.cpp index 05a3ef31e1..3e7633794e 100644 --- a/src/VLAN.cpp +++ b/src/VLAN.cpp @@ -23,7 +23,7 @@ /* *************************************** */ -VLAN::VLAN(NetworkInterface *_iface, u_int16_t _vlan_id) : GenericHashEntry(_iface), GenericTrafficElement(), Score(_iface) { +VLAN::VLAN(NetworkInterface *_iface, VLANid _vlan_id) : GenericHashEntry(_iface), GenericTrafficElement(), Score(_iface) { vlan_id = _vlan_id; #ifdef VLAN_DEBUG @@ -80,6 +80,6 @@ void VLAN::lua(lua_State* vm, DetailsLevel details_level, bool asListElement) { /* *************************************** */ -bool VLAN::equal(u_int16_t _vlan_id) { +bool VLAN::equal(VLANid _vlan_id) { return(vlan_id == _vlan_id); } diff --git a/src/VLANAddressTree.cpp b/src/VLANAddressTree.cpp index 6bd0bb3d31..573f8c3ff9 100644 --- a/src/VLANAddressTree.cpp +++ b/src/VLANAddressTree.cpp @@ -40,7 +40,7 @@ VLANAddressTree::~VLANAddressTree() { /* **************************************** */ -bool VLANAddressTree::addAddress(u_int16_t vlan_id, char *_net, const int16_t user_data) { +bool VLANAddressTree::addAddress(VLANid vlan_id, char *_net, const int16_t user_data) { if(tree[vlan_id] || (tree[vlan_id] = new (std::nothrow) AddressTree())) return tree[vlan_id]->addAddress(_net, user_data); @@ -49,7 +49,7 @@ bool VLANAddressTree::addAddress(u_int16_t vlan_id, char *_net, const int16_t us /* **************************************** */ -bool VLANAddressTree::addAddresses(u_int16_t vlan_id, char *net, const int16_t user_data) { +bool VLANAddressTree::addAddresses(VLANid vlan_id, char *net, const int16_t user_data) { if(tree[vlan_id] || (tree[vlan_id] = new (std::nothrow) AddressTree())) return tree[vlan_id]->addAddresses(net, user_data); @@ -58,14 +58,14 @@ bool VLANAddressTree::addAddresses(u_int16_t vlan_id, char *net, const int16_t u /* **************************************** */ -int16_t VLANAddressTree::findAddress(u_int16_t vlan_id, int family, void *addr, u_int8_t *network_mask_bits) { +int16_t VLANAddressTree::findAddress(VLANid vlan_id, int family, void *addr, u_int8_t *network_mask_bits) { if(! tree[vlan_id]) return -1; return tree[vlan_id]->findAddress(family, addr, network_mask_bits); } /* **************************************** */ -int16_t VLANAddressTree::findMac(u_int16_t vlan_id, const u_int8_t addr[]) { +int16_t VLANAddressTree::findMac(VLANid vlan_id, const u_int8_t addr[]) { if(! tree[vlan_id]) return -1; return tree[vlan_id]->findMac(addr); } diff --git a/src/VLANHash.cpp b/src/VLANHash.cpp index 2c4c015606..70bc7b8531 100644 --- a/src/VLANHash.cpp +++ b/src/VLANHash.cpp @@ -30,7 +30,7 @@ VLANHash::VLANHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_ /* ************************************ */ -VLAN* VLANHash::get(u_int16_t _vlan_id, bool is_inline_call) { +VLAN* VLANHash::get(VLANid _vlan_id, bool is_inline_call) { u_int32_t hash = _vlan_id; hash %= num_hashes; diff --git a/src/ViewInterface.cpp b/src/ViewInterface.cpp index a3be1bd3de..7ac839200f 100644 --- a/src/ViewInterface.cpp +++ b/src/ViewInterface.cpp @@ -415,7 +415,7 @@ void ViewInterface::sumStats(TcpFlowStats *_tcpFlowStats, EthStats *_ethStats, /* **************************************************** */ -Flow* ViewInterface::findFlowByTuple(u_int16_t vlan_id, +Flow* ViewInterface::findFlowByTuple(VLANid vlan_id, IpAddress *src_ip, IpAddress *dst_ip, u_int16_t src_port, u_int16_t dst_port, u_int8_t l4_proto,