Coverage Report

Created: 2026-04-01 07:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ntopng/include/MacStats.h
Line
Count
Source
1
/*
2
 *
3
 * (C) 2013-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 _MAC_STATS_H_
23
#define _MAC_STATS_H_
24
25
class MacStats : public GenericTrafficElement {
26
 protected:
27
  NetworkInterface* iface;
28
  struct {
29
    u_int32_t num_req_sent, num_rep_rcvd;
30
  } dhcp_stats;
31
  struct {
32
    struct {
33
      u_int32_t requests, replies;
34
    } sent, rcvd;
35
  } arp_stats;
36
37
 public:
38
  MacStats(NetworkInterface* _iface);
39
40
  void lua(lua_State* vm, bool show_details);
41
0
  inline void getJSONObject(json_object* my_object) {
42
0
    GenericTrafficElement::getJSONObject(my_object, iface);
43
0
  }
44
45
0
  inline u_int64_t getNumSentArp() {
46
0
    return (u_int64_t)arp_stats.sent.requests + arp_stats.sent.replies;
47
0
  }
48
0
  inline u_int64_t getNumRcvdArp() {
49
0
    return (u_int64_t)arp_stats.rcvd.requests + arp_stats.rcvd.replies;
50
0
  }
51
1
  inline void incSentArpRequests() { arp_stats.sent.requests++; }
52
1
  inline void incSentArpReplies() { arp_stats.sent.replies++; }
53
1
  inline void incRcvdArpRequests() { arp_stats.rcvd.requests++; }
54
1
  inline void incRcvdArpReplies() { arp_stats.rcvd.replies++; }
55
56
59.8k
  inline void incSentStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) {
57
59.8k
    sent.incStats(t, num_pkts, num_bytes);
58
59.8k
  }
59
59.8k
  inline void incRcvdStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) {
60
59.8k
    rcvd.incStats(t, num_pkts, num_bytes);
61
59.8k
  }
62
  inline void incnDPIStats(time_t when, ndpi_protocol_category_t ndpi_category,
63
                           u_int64_t sent_packets, u_int64_t sent_bytes,
64
                           u_int64_t sent_goodput_bytes, u_int64_t rcvd_packets,
65
0
                           u_int64_t rcvd_bytes, u_int64_t rcvd_goodput_bytes) {
66
0
    if (ndpiStats || (ndpiStats = new nDPIStats())) {
67
      // ndpiStats->incStats(when, protocol.master_proto, sent_packets,
68
      // sent_bytes, rcvd_packets, rcvd_bytes); ndpiStats->incStats(when,
69
      // protocol.app_proto, sent_packets, sent_bytes, rcvd_packets,
70
      // rcvd_bytes);
71
0
      ndpiStats->incCategoryStats(when, ndpi_category, sent_bytes, rcvd_bytes);
72
0
    }
73
0
  }
74
75
52
  inline void incNumDHCPRequests() { dhcp_stats.num_req_sent++; }
76
39
  inline void incNumDHCPReplies() { dhcp_stats.num_rep_rcvd++; }
77
};
78
79
#endif