diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2023-09-17 23:15:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-17 23:15:59 +0200 |
| commit | d3e07d2b5734149c1314cb98b48dd1adebd62686 (patch) | |
| tree | a924b49927ae1925a7e0893d31e0c9c6abd3228e /plugins-root/check_icmp.c | |
| parent | 495c4c9adfa482303b31cdac7d28adda82d2d2ed (diff) | |
| parent | 2ddc75e69db5a3dd379c896d8420c9af20ec1cee (diff) | |
| download | monitoring-plugins-d3e07d2.tar.gz | |
Merge branch 'master' into dev/check_ssh-patches
Diffstat (limited to 'plugins-root/check_icmp.c')
| -rw-r--r-- | plugins-root/check_icmp.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index c3be2efd..1d47e9fc 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -274,7 +274,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code) | |||
| 274 | break; | 274 | break; |
| 275 | 275 | ||
| 276 | case ICMP_TIMXCEED: | 276 | case ICMP_TIMXCEED: |
| 277 | /* really 'out of reach', or non-existant host behind a router serving | 277 | /* really 'out of reach', or non-existent host behind a router serving |
| 278 | * two different subnets */ | 278 | * two different subnets */ |
| 279 | switch(icmp_code) { | 279 | switch(icmp_code) { |
| 280 | case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break; | 280 | case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break; |
| @@ -1432,15 +1432,20 @@ get_ip_address(const char *ifname) | |||
| 1432 | { | 1432 | { |
| 1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else | 1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else |
| 1434 | struct sockaddr_in ip; | 1434 | struct sockaddr_in ip; |
| 1435 | ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy | ||
| 1435 | #if defined(SIOCGIFADDR) | 1436 | #if defined(SIOCGIFADDR) |
| 1436 | struct ifreq ifr; | 1437 | struct ifreq ifr; |
| 1437 | 1438 | ||
| 1438 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); | 1439 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); |
| 1440 | |||
| 1439 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; | 1441 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; |
| 1442 | |||
| 1440 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) | 1443 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) |
| 1441 | crash("Cannot determine IP address of interface %s", ifname); | 1444 | crash("Cannot determine IP address of interface %s", ifname); |
| 1445 | |||
| 1442 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); | 1446 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); |
| 1443 | #else | 1447 | #else |
| 1448 | (void) ifname; | ||
| 1444 | errno = 0; | 1449 | errno = 0; |
| 1445 | crash("Cannot get interface IP address on this platform."); | 1450 | crash("Cannot get interface IP address on this platform."); |
| 1446 | #endif | 1451 | #endif |
