Coverage Report

Created: 2026-02-14 06:52

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 +
47
0
           arp_stats.sent.replies;
48
0
  }
49
0
  inline u_int64_t getNumRcvdArp() {
50
0
    return (u_int64_t)arp_stats.rcvd.requests +
51
0
           arp_stats.rcvd.replies;
52
0
  }
53
881
  inline void incSentArpRequests() { arp_stats.sent.requests++; }
54
798
  inline void incSentArpReplies() { arp_stats.sent.replies++; }
55
881
  inline void incRcvdArpRequests() { arp_stats.rcvd.requests++; }
56
798
  inline void incRcvdArpReplies() { arp_stats.rcvd.replies++; }
57
58
141k
  inline void incSentStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) {
59
141k
    sent.incStats(t, num_pkts, num_bytes);
60
141k
  }
61
141k
  inline void incRcvdStats(time_t t, u_int64_t num_pkts, u_int64_t num_bytes) {
62
141k
    rcvd.incStats(t, num_pkts, num_bytes);
63
141k
  }
64
  inline void incnDPIStats(time_t when, ndpi_protocol_category_t ndpi_category,
65
                           u_int64_t sent_packets, u_int64_t sent_bytes,
66
                           u_int64_t sent_goodput_bytes, u_int64_t rcvd_packets,
67
0
                           u_int64_t rcvd_bytes, u_int64_t rcvd_goodput_bytes) {
68
0
    if (ndpiStats || (ndpiStats = new nDPIStats())) {
69
      // ndpiStats->incStats(when, protocol.master_proto, sent_packets,
70
      // sent_bytes, rcvd_packets, rcvd_bytes); ndpiStats->incStats(when,
71
      // protocol.app_proto, sent_packets, sent_bytes, rcvd_packets,
72
      // rcvd_bytes);
73
0
      ndpiStats->incCategoryStats(when, ndpi_category, sent_bytes, rcvd_bytes);
74
0
    }
75
0
  }
76
77
20
  inline void incNumDHCPRequests() { dhcp_stats.num_req_sent++; }
78
23
  inline void incNumDHCPReplies() { dhcp_stats.num_rep_rcvd++; }
79
};
80
81
#endif