diff options
-rw-r--r-- | plugins-root/check_icmp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 7f3c4b5..317cd53 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
@@ -1430,20 +1430,21 @@ set_source_ip(char *arg) | |||
1430 | static in_addr_t | 1430 | static in_addr_t |
1431 | get_ip_address(const char *ifname) | 1431 | get_ip_address(const char *ifname) |
1432 | { | 1432 | { |
1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else | ||
1434 | struct sockaddr_in ip; | ||
1433 | #if defined(SIOCGIFADDR) | 1435 | #if defined(SIOCGIFADDR) |
1434 | struct ifreq ifr; | 1436 | struct ifreq ifr; |
1435 | struct sockaddr_in ip; | ||
1436 | 1437 | ||
1437 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); | 1438 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); |
1438 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; | 1439 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; |
1439 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) | 1440 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) |
1440 | crash("Cannot determine IP address of interface %s", ifname); | 1441 | crash("Cannot determine IP address of interface %s", ifname); |
1441 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); | 1442 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); |
1442 | return ip.sin_addr.s_addr; | ||
1443 | #else | 1443 | #else |
1444 | errno = 0; | 1444 | errno = 0; |
1445 | crash("Cannot get interface IP address on this platform."); | 1445 | crash("Cannot get interface IP address on this platform."); |
1446 | #endif | 1446 | #endif |
1447 | return ip.sin_addr.s_addr; | ||
1447 | } | 1448 | } |
1448 | 1449 | ||
1449 | /* | 1450 | /* |