diff options
Diffstat (limited to 'plugins-root/check_dhcp.c')
-rw-r--r-- | plugins-root/check_dhcp.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index a41a86e..9b62b3e 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -274,7 +274,7 @@ int main(int argc, char **argv){ | |||
274 | 274 | ||
275 | /* this plugin almost certainly needs root permissions. */ | 275 | /* this plugin almost certainly needs root permissions. */ |
276 | np_warn_if_not_root(); | 276 | np_warn_if_not_root(); |
277 | 277 | ||
278 | /* create socket for DHCP communications */ | 278 | /* create socket for DHCP communications */ |
279 | dhcp_socket=create_dhcp_socket(); | 279 | dhcp_socket=create_dhcp_socket(); |
280 | 280 | ||
@@ -316,7 +316,7 @@ int get_hardware_address(int sock,char *interface_name){ | |||
316 | 316 | ||
317 | strncpy((char *)&ifr.ifr_name,interface_name,sizeof(ifr.ifr_name)-1); | 317 | strncpy((char *)&ifr.ifr_name,interface_name,sizeof(ifr.ifr_name)-1); |
318 | ifr.ifr_name[sizeof(ifr.ifr_name)-1]='\0'; | 318 | ifr.ifr_name[sizeof(ifr.ifr_name)-1]='\0'; |
319 | 319 | ||
320 | /* try and grab hardware address of requested interface */ | 320 | /* try and grab hardware address of requested interface */ |
321 | if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){ | 321 | if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){ |
322 | printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name); | 322 | printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name); |
@@ -506,7 +506,7 @@ int send_dhcp_discover(int sock){ | |||
506 | opts += sizeof(requested_address); | 506 | opts += sizeof(requested_address); |
507 | } | 507 | } |
508 | discover_packet.options[opts++]=DHCP_OPTION_END; | 508 | discover_packet.options[opts++]=DHCP_OPTION_END; |
509 | 509 | ||
510 | /* unicast fields */ | 510 | /* unicast fields */ |
511 | if(unicast) | 511 | if(unicast) |
512 | discover_packet.giaddr.s_addr = my_ip.s_addr; | 512 | discover_packet.giaddr.s_addr = my_ip.s_addr; |
@@ -571,7 +571,7 @@ int get_dhcp_offer(int sock){ | |||
571 | 571 | ||
572 | result=OK; | 572 | result=OK; |
573 | result=receive_dhcp_packet(&offer_packet,sizeof(offer_packet),sock,dhcpoffer_timeout,&source); | 573 | result=receive_dhcp_packet(&offer_packet,sizeof(offer_packet),sock,dhcpoffer_timeout,&source); |
574 | 574 | ||
575 | if(result!=OK){ | 575 | if(result!=OK){ |
576 | if(verbose) | 576 | if(verbose) |
577 | printf(_("Result=ERROR\n")); | 577 | printf(_("Result=ERROR\n")); |
@@ -952,7 +952,7 @@ int free_requested_server_list(void){ | |||
952 | next_server=this_server->next; | 952 | next_server=this_server->next; |
953 | free(this_server); | 953 | free(this_server); |
954 | } | 954 | } |
955 | 955 | ||
956 | return OK; | 956 | return OK; |
957 | } | 957 | } |
958 | 958 | ||
@@ -977,7 +977,7 @@ int get_results(void){ | |||
977 | /* get max lease time we were offered */ | 977 | /* get max lease time we were offered */ |
978 | if(temp_offer->lease_time>max_lease_time || temp_offer->lease_time==DHCP_INFINITE_TIME) | 978 | if(temp_offer->lease_time>max_lease_time || temp_offer->lease_time==DHCP_INFINITE_TIME) |
979 | max_lease_time=temp_offer->lease_time; | 979 | max_lease_time=temp_offer->lease_time; |
980 | 980 | ||
981 | /* see if we got the address we requested */ | 981 | /* see if we got the address we requested */ |
982 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) | 982 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) |
983 | received_requested_address=TRUE; | 983 | received_requested_address=TRUE; |
@@ -1009,7 +1009,7 @@ int get_results(void){ | |||
1009 | /* get max lease time we were offered */ | 1009 | /* get max lease time we were offered */ |
1010 | if(temp_offer->lease_time>max_lease_time || temp_offer->lease_time==DHCP_INFINITE_TIME) | 1010 | if(temp_offer->lease_time>max_lease_time || temp_offer->lease_time==DHCP_INFINITE_TIME) |
1011 | max_lease_time=temp_offer->lease_time; | 1011 | max_lease_time=temp_offer->lease_time; |
1012 | 1012 | ||
1013 | /* see if we got the address we requested */ | 1013 | /* see if we got the address we requested */ |
1014 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) | 1014 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) |
1015 | received_requested_address=TRUE; | 1015 | received_requested_address=TRUE; |
@@ -1387,7 +1387,7 @@ void print_help(void){ | |||
1387 | 1387 | ||
1388 | printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n"); | 1388 | printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n"); |
1389 | printf (COPYRIGHT, copyright, email); | 1389 | printf (COPYRIGHT, copyright, email); |
1390 | 1390 | ||
1391 | printf("%s\n", _("This plugin tests the availability of DHCP servers on a network.")); | 1391 | printf("%s\n", _("This plugin tests the availability of DHCP servers on a network.")); |
1392 | 1392 | ||
1393 | printf ("\n\n"); | 1393 | printf ("\n\n"); |
@@ -1411,17 +1411,18 @@ void print_help(void){ | |||
1411 | printf (" %s\n", "-u, --unicast"); | 1411 | printf (" %s\n", "-u, --unicast"); |
1412 | printf (" %s\n", _("Unicast testing: mimic a DHCP relay, requires -s")); | 1412 | printf (" %s\n", _("Unicast testing: mimic a DHCP relay, requires -s")); |
1413 | 1413 | ||
1414 | printf (_(UT_SUPPORT)); | ||
1414 | return; | 1415 | return; |
1415 | } | 1416 | } |
1416 | 1417 | ||
1417 | 1418 | ||
1418 | void | 1419 | void |
1419 | print_usage(void){ | 1420 | print_usage(void){ |
1420 | 1421 | ||
1421 | printf (_("Usage:")); | 1422 | printf (_("Usage:")); |
1422 | printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname); | 1423 | printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname); |
1423 | printf (" [-i interface] [-m mac]\n"); | 1424 | printf (" [-i interface] [-m mac]\n"); |
1424 | 1425 | ||
1425 | return; | 1426 | return; |
1426 | } | 1427 | } |
1427 | 1428 | ||