/src/ntopng/include/VLANAddressTree.h
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * (C) 2017-26 - ntop.org |
4 | | * |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #ifndef _VLAN_ADDRESS_TREE_H_ |
23 | | #define _VLAN_ADDRESS_TREE_H_ |
24 | | |
25 | | class AddressTree; |
26 | | |
27 | | class VLANAddressTree { |
28 | | protected: |
29 | | AddressTree** tree; |
30 | | ndpi_void_fn_t free_func; |
31 | | u_int32_t num_addresses; |
32 | | RwLock updateLock; |
33 | | bool lock_enabled; |
34 | | |
35 | | public: |
36 | | VLANAddressTree(ndpi_void_fn_t data_free_func = NULL, bool use_locking = true); |
37 | | ~VLANAddressTree(); |
38 | | |
39 | 0 | inline bool isEmpty() { return (num_addresses == 0); } |
40 | | bool addAddress(u_int16_t vlan_id, const char* net, int64_t user_data = -1); |
41 | | bool addAddresses(u_int16_t vlan_id, char* net, const int16_t user_data = -1); |
42 | | |
43 | | int64_t findAddress(u_int16_t vlan_id, int family, void* addr, |
44 | | u_int8_t* network_mask_bits = NULL); |
45 | | int64_t findMac(u_int16_t vlan_id, const u_int8_t addr[]); |
46 | | |
47 | | void* findAndGetData(u_int16_t vlan_id, IpAddress* ipa); |
48 | | bool addVLANAddressAndData(u_int16_t vlan_id, const char* _what, |
49 | | void* user_data); |
50 | | |
51 | 0 | inline AddressTree* getAddressTree(u_int16_t vlan_id) { |
52 | 0 | return tree[vlan_id]; |
53 | 0 | }; |
54 | | }; |
55 | | |
56 | | #endif |