summaryrefslogtreecommitdiffstats
path: root/plugins-root/check_icmp.d/check_icmp_helpers.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-06-20 11:29:07 +0200
committerGitHub <noreply@github.com>2025-06-20 11:29:07 +0200
commitb8580c18e354b9070adbf464df186442d55dc120 (patch)
treec5d126ae124b6c48d34384472304803a01f0a7af /plugins-root/check_icmp.d/check_icmp_helpers.h
parent916d3a52a0f01f05bbf42008fa5dddcee6ad7522 (diff)
parentd2735eecd4c44ba4a2504304963e861a427e393e (diff)
downloadmonitoring-plugins-master.tar.gz
Merge pull request #2125 from RincewindsHat/refactor/check_icmpHEADmaster
Refactor check_icmp: - Far less global variables - Proper IPv6/legacy IP dual stack functionality (allowed mixed v4/v6 hosts) - Improved readability/understandability - General cleanup
Diffstat (limited to 'plugins-root/check_icmp.d/check_icmp_helpers.h')
-rw-r--r--plugins-root/check_icmp.d/check_icmp_helpers.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins-root/check_icmp.d/check_icmp_helpers.h b/plugins-root/check_icmp.d/check_icmp_helpers.h
new file mode 100644
index 00000000..dc6ea40b
--- /dev/null
+++ b/plugins-root/check_icmp.d/check_icmp_helpers.h
@@ -0,0 +1,68 @@
1#pragma once
2
3#include "../../lib/states.h"
4#include <netinet/in_systm.h>
5#include <netinet/in.h>
6#include <netinet/ip.h>
7#include <netinet/ip6.h>
8#include <netinet/ip_icmp.h>
9#include <netinet/icmp6.h>
10#include <arpa/inet.h>
11
12typedef struct ping_target {
13 unsigned short id; /* id in **table, and icmp pkts */
14 char *msg; /* icmp error message, if any */
15
16 struct sockaddr_storage address; /* the address of this host */
17 struct sockaddr_storage error_addr; /* stores address of error replies */
18 time_t time_waited; /* total time waited, in usecs */
19 unsigned int icmp_sent, icmp_recv, icmp_lost; /* counters */
20 unsigned char icmp_type, icmp_code; /* type and code from errors */
21 unsigned short flags; /* control/status flags */
22
23 double rtmax; /* max rtt */
24 double rtmin; /* min rtt */
25
26 double jitter; /* measured jitter */
27 double jitter_max; /* jitter rtt maximum */
28 double jitter_min; /* jitter rtt minimum */
29
30 time_t last_tdiff;
31 unsigned int last_icmp_seq; /* Last ICMP_SEQ to check out of order pkts */
32
33 bool found_out_of_order_packets;
34
35 struct ping_target *next;
36} ping_target;
37
38ping_target ping_target_init();
39
40typedef struct {
41 char *name;
42 ping_target *target_list;
43 unsigned int number_of_targets;
44} check_icmp_target_container;
45
46check_icmp_target_container check_icmp_target_container_init();
47
48typedef struct {
49 unsigned int icmp_sent;
50 unsigned int icmp_recv;
51 unsigned int icmp_lost;
52 unsigned short targets_down;
53} check_icmp_state;
54
55check_icmp_state check_icmp_state_init();
56
57typedef struct {
58 int errorcode;
59 ping_target host;
60} ping_target_create_wrapper;
61
62typedef struct {
63 int socket4;
64 int socket6;
65} check_icmp_socket_set;
66
67ping_target_create_wrapper ping_target_create(struct sockaddr_storage address);
68unsigned int ping_target_list_append(ping_target *list, ping_target *elem);