Debian Codegraph @

madrisan-nagios-plugins-linux/nagios-plugins-linux/include/netinfo.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 /* netinfo.h -- a library foe getting network interfaces statistics
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef _NETINFO_H
18 #define _NETINFO_H
19
20 #include <stdint.h>
21 #include <sys/types.h>
22
23 #include "netinfo-private.h"
24 #include "system.h"
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 enum
32 {
33 /* list of address families */
34 IF_AF_PACKET = (1 << 0),
35 IF_AF_INET = (1 << 1),
36 IF_AF_INET6 = (1 << 2),
37 /* command-line options */
38 CHECK_LINK = (1 << 0),
39 NO_LOOPBACK = (1 << 1),
40 NO_WIRELESS = (1 << 2),
41 NO_BYTES = (1 << 3),
42 NO_COLLISIONS = (1 << 4),
43 NO_DROPS = (1 << 4),
44 NO_ERRORS = (1 << 5),
45 NO_MULTICAST = (1 << 6),
46 NO_PACKETS = (1 << 7),
47 RX_ONLY = (1 << 8),
48 TX_ONLY = (1 << 9)
49 };
50
51 enum duplex
52 {
53 DUP_HALF = DUPLEX_HALF,
54 DUP_FULL = DUPLEX_FULL,
55 _DUP_MAX,
56 _DUP_UNKNOWN = DUPLEX_UNKNOWN
57 };
58
59 struct iflist *netinfo (unsigned int options, const char *ifname_regex,
60 unsigned int seconds, unsigned int *ninterfaces);
61 struct iflist *iflist_get_next (struct iflist *ifentry);
62 #define iflist_foreach(list_entry, list) \
63 for (list_entry = list; list_entry != NULL; \
64 list_entry = iflist_get_next(list_entry))
65
66 /* Accessing the values from struct iflist */
67 const char *iflist_get_ifname (struct iflist *ifentry);
68 uint8_t iflist_get_duplex (struct iflist *ifentry);
69 uint32_t iflist_get_speed (struct iflist *ifentry);
70 unsigned int iflist_get_tx_packets (struct iflist *ifentry);
71 unsigned int iflist_get_rx_packets (struct iflist *ifentry);
72 unsigned int iflist_get_tx_bytes (struct iflist *ifentry);
73 unsigned int iflist_get_rx_bytes (struct iflist *ifentry);
74 unsigned int iflist_get_tx_errors (struct iflist *ifentry);
75 unsigned int iflist_get_rx_errors (struct iflist *ifentry);
76 unsigned int iflist_get_tx_dropped (struct iflist *ifentry);
77 unsigned int iflist_get_rx_dropped (struct iflist *ifentry);
78 unsigned int iflist_get_collisions (struct iflist *ifentry);
79 unsigned int iflist_get_flags (struct iflist *ifentry);
80 unsigned int iflist_get_multicast (struct iflist *ifentry);
81
82 void print_ifname_debug (struct iflist *iflhead, unsigned int options);
83 void freeiflist (struct iflist *iflhead);
84
85 /* helper functions for parsing and priting interface flags */
86 bool if_flags_LOOPBACK (unsigned int flags);
87 bool if_flags_RUNNING (unsigned int flags);
88 bool if_flags_UP (unsigned int flags);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* _NETINFO_H */