summaryrefslogtreecommitdiffstats
path: root/plugins-root
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-root')
-rw-r--r--plugins-root/check_icmp.c8
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);
149static time_t get_timevaldiff(struct timeval earlier, struct timeval later); 149static time_t get_timevaldiff(struct timeval earlier, struct timeval later);
150static time_t get_timevaldiff_to_now(struct timeval earlier); 150static time_t get_timevaldiff_to_now(struct timeval earlier);
151 151
152static in_addr_t get_ip_address(const char *ifname); 152static in_addr_t get_ip_address(const char *ifname, const int icmp_sock);
153static void set_source_ip(char *arg, int icmp_sock, sa_family_t addr_family); 153static 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. */
1783static in_addr_t get_ip_address(const char *ifname) { 1783static 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;