Coverage Report

Created: 2026-05-24 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ntopng/include/HostDetails.h
Line
Count
Source
1
/*
2
 *
3
 * (C) 2019-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 _HOST_DETAILS_H_
23
#define _HOST_DETAILS_H_
24
25
#include "ntop_includes.h"
26
27
class HostDetails {
28
 private:
29
  char* ip;
30
  char* mac_address;
31
  char* mac_manufacturer;
32
  char* ip_hex;
33
  char* name;
34
  u_int16_t vlan_id;
35
  u_int64_t total_traffic;
36
  u_int8_t score;
37
  u_int32_t active_flows_as_server;
38
  u_int64_t host_key;
39
  u_int16_t port;
40
41
 public:
42
  HostDetails(char* _ip, char* _mac_address, char* _mac_manufacturer,
43
              u_int64_t _total_traffic, char* _ip_hex, u_int16_t _vlan_id,
44
              u_int8_t _score, u_int32_t _active_flows_count, char* _name,
45
0
              u_int64_t _host_key) {
46
0
    ip = _ip ? strdup(_ip) : NULL;
47
0
    mac_address = _mac_address ? strdup(_mac_address) : NULL;
48
0
    mac_manufacturer = _mac_manufacturer ? strdup(_mac_manufacturer) : NULL;
49
0
    total_traffic = _total_traffic;
50
0
    ip_hex = _ip_hex ? strdup(_ip_hex) : NULL;
51
0
    vlan_id = _vlan_id;
52
0
    score = _score;
53
0
    active_flows_as_server = _active_flows_count;
54
0
    name = _name ? strdup(_name) : NULL;
55
0
    host_key = _host_key;
56
0
  };
57
58
0
  ~HostDetails() {
59
0
    if (ip_hex) free(ip_hex);
60
0
    if (ip) free(ip);
61
0
    if (mac_address) free(mac_address);
62
0
    if (name) free(name);
63
0
    if (mac_manufacturer) free(mac_manufacturer);
64
0
  };
65
66
  /* Getters */
67
0
  inline char* get_ip() { return (ip ? ip : (char*)""); };
68
0
  inline char* get_ip_hex() { return (ip_hex ? ip_hex : (char*)""); };
69
0
  inline char* get_mac_address() {
70
0
    return (mac_address ? mac_address : (char*)"");
71
0
  };
72
0
  inline char* get_mac_manufacturer() {
73
0
    return (mac_manufacturer ? mac_manufacturer : (char*)"");
74
0
  };
75
0
  inline char* get_name() { return (name ? name : (char*)""); };
76
77
0
  inline u_int64_t get_total_traffic() { return (total_traffic); };
78
0
  inline u_int8_t get_score() { return (score); };
79
0
  inline u_int32_t get_active_flows_as_server() {
80
0
    return (active_flows_as_server);
81
0
  };
82
0
  inline u_int16_t get_vlan_id() { return (vlan_id); };
83
0
  inline u_int64_t get_host_key() { return (host_key); };
84
0
  inline u_int16_t get_port() { return (port); };
85
86
  /* Setters */
87
0
  inline void set_port(u_int16_t _port) { port = _port; };
88
89
  /* Inc stats */
90
0
  inline void inc_stats(u_int64_t f_traffic) {
91
0
    total_traffic += f_traffic;
92
0
    active_flows_as_server++;
93
0
  }
94
};
95
96
#endif /* _HOST_DETAILS_H_ */