Module: monitoring-plugins
Branch: master
Commit: b27bf07ebf518a719482c5c40372549f5a9a127a
Author: Alvar Penning <[email protected]>
Date: Wed Dec 10 21:12:17 2025 +0100
URL:
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b27bf07e
plugins-root/check_icmp: Fix build for SIOCGIFADDR
The refactoring in eafee9c3f91879afa82749fa1d8cd2b0b53a5d5c missed the
part within "#if defined(SIOCGIFADDR)" in get_ip_address.
---
plugins-root/check_icmp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index a5909c44..35cae3ed 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -149,7 +149,7 @@ static get_timevar_wrapper get_timevar(const char *str);
static time_t get_timevaldiff(struct timeval earlier, struct timeval later);
static time_t get_timevaldiff_to_now(struct timeval earlier);
-static in_addr_t get_ip_address(const char *ifname);
+static in_addr_t get_ip_address(const char *ifname, const int icmp_sock);
static void set_source_ip(char *arg, int icmp_sock, sa_family_t addr_family);
/* Receiving data */
@@ -1772,7 +1772,7 @@ static void set_source_ip(char *arg, const int icmp_sock,
sa_family_t addr_famil
memset(&src, 0, sizeof(src));
src.sin_family = addr_family;
if ((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE) {
- src.sin_addr.s_addr = get_ip_address(arg);
+ src.sin_addr.s_addr = get_ip_address(arg, icmp_sock);
}
if (bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1) {
crash("Cannot bind to IP address %s", arg);
@@ -1780,7 +1780,7 @@ static void set_source_ip(char *arg, const int icmp_sock,
sa_family_t addr_famil
}
/* TODO: Move this to netutils.c and also change check_dhcp to use that. */
-static in_addr_t get_ip_address(const char *ifname) {
+static in_addr_t get_ip_address(const char *ifname, const int icmp_sock) {
// TODO: Rewrite this so the function return an error and we exit
somewhere else
struct sockaddr_in ip_address;
ip_address.sin_addr.s_addr = 0; // Fake initialization to make compiler
happy
@@ -1795,7 +1795,7 @@ static in_addr_t get_ip_address(const char *ifname) {
crash("Cannot determine IP address of interface %s", ifname);
}
- memcpy(&ip, &ifr.ifr_addr, sizeof(ip));
+ memcpy(&ip_address, &ifr.ifr_addr, sizeof(ip_address));
#else
(void)ifname;
errno = 0;