Coverage Report

Created: 2024-02-25 06:37

/src/ntopng/include/VLAN.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *
3
 * (C) 2013-24 - 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_H_
23
#define _VLAN_H_
24
25
#include "ntop_includes.h"
26
27
class VLAN : public GenericHashEntry,
28
             public GenericTrafficElement,
29
             public Score {
30
 private:
31
  u_int16_t vlan_id;
32
  UsedPorts usedPorts;
33
34
29.8k
  inline void incSentStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) {
35
29.8k
    if (first_seen == 0) first_seen = t;
36
29.8k
    last_seen = iface->getTimeLastPktRcvd();
37
29.8k
    sent.incStats(t, num_pkts, num_bytes);
38
29.8k
  }
39
40
29.8k
  inline void incRcvdStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) {
41
29.8k
    rcvd.incStats(t, num_pkts, num_bytes);
42
29.8k
  }
43
44
 public:
45
  VLAN(NetworkInterface* _iface, u_int16_t _vlan_id);
46
  ~VLAN();
47
48
  void set_hash_entry_state_idle();
49
50
0
  inline u_int16_t getNumHosts() { return getUses(); }
51
3.30k
  inline u_int32_t key() { return (vlan_id); }
52
0
  inline u_int16_t get_vlan_id() { return (vlan_id); }
53
54
  bool equal(u_int16_t _vlan_id);
55
56
  inline void incStats(time_t when, u_int16_t proto_id, u_int64_t sent_packets,
57
                       u_int64_t sent_bytes, u_int64_t rcvd_packets,
58
29.8k
                       u_int64_t rcvd_bytes) {
59
29.8k
    if (ndpiStats || (ndpiStats = new nDPIStats()))
60
29.8k
      ndpiStats->incStats(when, proto_id, sent_packets, sent_bytes,
61
29.8k
                          rcvd_packets, rcvd_bytes);
62
29.8k
    incSentStats(when, sent_packets, sent_bytes);
63
29.8k
    incRcvdStats(when, rcvd_packets, rcvd_bytes);
64
29.8k
  }
65
66
  void lua(lua_State* vm, DetailsLevel details_level, bool asListElement);
67
0
  inline char* getSerializationKey(char* buf, uint bufsize) {
68
0
    snprintf(buf, bufsize, VLAN_SERIALIZED_KEY, iface->get_id(), vlan_id);
69
0
    return (buf);
70
0
  }
71
0
  inline void setServerPort(bool isTCP, u_int16_t port, ndpi_protocol* proto) {
72
0
    usedPorts.setServerPort(isTCP, port, proto);
73
0
  };
74
0
  void luaUsedPorts(lua_State* vm) { usedPorts.lua(vm, iface); };
75
};
76
77
#endif /* _VLAN_H_ */