diff options
| author | Alvar Penning <post@0x21.biz> | 2025-12-10 21:12:17 +0100 |
|---|---|---|
| committer | Alvar Penning <post@0x21.biz> | 2025-12-11 21:05:49 +0100 |
| commit | b27bf07ebf518a719482c5c40372549f5a9a127a (patch) | |
| tree | a2b8e9ddccc08a6b022ff2827b6c79885ea56836 /plugins-root | |
| parent | cbddc7dbb4c218df453d3c14abe0ce21c17b6cce (diff) | |
| download | monitoring-plugins-b27bf07ebf518a719482c5c40372549f5a9a127a.tar.gz | |
plugins-root/check_icmp: Fix build for SIOCGIFADDR
The refactoring in eafee9c3f91879afa82749fa1d8cd2b0b53a5d5c missed the
part within "#if defined(SIOCGIFADDR)" in get_ip_address.
Diffstat (limited to 'plugins-root')
| -rw-r--r-- | plugins-root/check_icmp.c | 8 |
1 files 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); | |||
| 149 | static time_t get_timevaldiff(struct timeval earlier, struct timeval later); | 149 | static time_t get_timevaldiff(struct timeval earlier, struct timeval later); |
| 150 | static time_t get_timevaldiff_to_now(struct timeval earlier); | 150 | static time_t get_timevaldiff_to_now(struct timeval earlier); |
| 151 | 151 | ||
| 152 | static in_addr_t get_ip_address(const char *ifname); | 152 | static in_addr_t get_ip_address(const char *ifname, const int icmp_sock); |
| 153 | static void set_source_ip(char *arg, int icmp_sock, sa_family_t addr_family); | 153 | static void set_source_ip(char *arg, int icmp_sock, sa_family_t addr_family); |
| 154 | 154 | ||
| 155 | /* Receiving data */ | 155 | /* Receiving data */ |
| @@ -1772,7 +1772,7 @@ static void set_source_ip(char *arg, const int icmp_sock, sa_family_t addr_famil | |||
| 1772 | memset(&src, 0, sizeof(src)); | 1772 | memset(&src, 0, sizeof(src)); |
| 1773 | src.sin_family = addr_family; | 1773 | src.sin_family = addr_family; |
| 1774 | if ((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE) { | 1774 | if ((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE) { |
| 1775 | src.sin_addr.s_addr = get_ip_address(arg); | 1775 | src.sin_addr.s_addr = get_ip_address(arg, icmp_sock); |
| 1776 | } | 1776 | } |
| 1777 | if (bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1) { | 1777 | if (bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1) { |
| 1778 | crash("Cannot bind to IP address %s", arg); | 1778 | 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 | |||
| 1780 | } | 1780 | } |
| 1781 | 1781 | ||
| 1782 | /* TODO: Move this to netutils.c and also change check_dhcp to use that. */ | 1782 | /* TODO: Move this to netutils.c and also change check_dhcp to use that. */ |
| 1783 | static in_addr_t get_ip_address(const char *ifname) { | 1783 | static in_addr_t get_ip_address(const char *ifname, const int icmp_sock) { |
| 1784 | // TODO: Rewrite this so the function return an error and we exit somewhere else | 1784 | // TODO: Rewrite this so the function return an error and we exit somewhere else |
| 1785 | struct sockaddr_in ip_address; | 1785 | struct sockaddr_in ip_address; |
| 1786 | ip_address.sin_addr.s_addr = 0; // Fake initialization to make compiler happy | 1786 | 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) { | |||
| 1795 | crash("Cannot determine IP address of interface %s", ifname); | 1795 | crash("Cannot determine IP address of interface %s", ifname); |
| 1796 | } | 1796 | } |
| 1797 | 1797 | ||
| 1798 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); | 1798 | memcpy(&ip_address, &ifr.ifr_addr, sizeof(ip_address)); |
| 1799 | #else | 1799 | #else |
| 1800 | (void)ifname; | 1800 | (void)ifname; |
| 1801 | errno = 0; | 1801 | errno = 0; |
