diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-01 13:59:00 +0200 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-01 13:59:00 +0200 |
commit | 1aaa2385031da8de6c9d74cecf589482a56b9e35 (patch) | |
tree | ab06bd2dffc6064f2ac05e3eaa927e8fc189920f | |
parent | 07510639189539817cee805caa5b6471427b7964 (diff) | |
download | monitoring-plugins-1aaa238.tar.gz |
Use real booleans
-rw-r--r-- | plugins-root/check_dhcp.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index 99df3d23..0c18d5fc 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -115,9 +115,6 @@ long mac_addr_dlpi( const char *, int, u_char *); | |||
115 | #define OK 0 | 115 | #define OK 0 |
116 | #define ERROR -1 | 116 | #define ERROR -1 |
117 | 117 | ||
118 | #define FALSE 0 | ||
119 | #define TRUE 1 | ||
120 | |||
121 | 118 | ||
122 | /**** DHCP definitions ****/ | 119 | /**** DHCP definitions ****/ |
123 | 120 | ||
@@ -158,7 +155,7 @@ typedef struct dhcp_offer_struct{ | |||
158 | 155 | ||
159 | typedef struct requested_server_struct{ | 156 | typedef struct requested_server_struct{ |
160 | struct in_addr server_address; | 157 | struct in_addr server_address; |
161 | int answered; | 158 | bool answered; |
162 | struct requested_server_struct *next; | 159 | struct requested_server_struct *next; |
163 | }requested_server; | 160 | }requested_server; |
164 | 161 | ||
@@ -217,8 +214,8 @@ int valid_responses=0; /* number of valid DHCPOFFERs we received */ | |||
217 | int requested_servers=0; | 214 | int requested_servers=0; |
218 | int requested_responses=0; | 215 | int requested_responses=0; |
219 | 216 | ||
220 | int request_specific_address=FALSE; | 217 | bool request_specific_address=false; |
221 | int received_requested_address=FALSE; | 218 | bool received_requested_address=false; |
222 | int verbose=0; | 219 | int verbose=0; |
223 | struct in_addr requested_address; | 220 | struct in_addr requested_address; |
224 | 221 | ||
@@ -491,7 +488,7 @@ int send_dhcp_discover(int sock){ | |||
491 | discover_packet.options[opts++]=DHCPDISCOVER; | 488 | discover_packet.options[opts++]=DHCPDISCOVER; |
492 | 489 | ||
493 | /* the IP address we're requesting */ | 490 | /* the IP address we're requesting */ |
494 | if(request_specific_address==TRUE){ | 491 | if(request_specific_address){ |
495 | discover_packet.options[opts++]=DHCP_OPTION_REQUESTED_ADDRESS; | 492 | discover_packet.options[opts++]=DHCP_OPTION_REQUESTED_ADDRESS; |
496 | discover_packet.options[opts++]='\x04'; | 493 | discover_packet.options[opts++]='\x04'; |
497 | memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address)); | 494 | memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address)); |
@@ -792,7 +789,7 @@ int add_requested_server(struct in_addr server_address){ | |||
792 | return ERROR; | 789 | return ERROR; |
793 | 790 | ||
794 | new_server->server_address=server_address; | 791 | new_server->server_address=server_address; |
795 | new_server->answered=FALSE; | 792 | new_server->answered=false; |
796 | 793 | ||
797 | new_server->next=requested_server_list; | 794 | new_server->next=requested_server_list; |
798 | requested_server_list=new_server; | 795 | requested_server_list=new_server; |
@@ -946,7 +943,7 @@ int get_results(void){ | |||
946 | int result; | 943 | int result; |
947 | uint32_t max_lease_time=0; | 944 | uint32_t max_lease_time=0; |
948 | 945 | ||
949 | received_requested_address=FALSE; | 946 | received_requested_address=false; |
950 | 947 | ||
951 | /* checks responses from requested servers */ | 948 | /* checks responses from requested servers */ |
952 | requested_responses=0; | 949 | requested_responses=0; |
@@ -962,7 +959,7 @@ int get_results(void){ | |||
962 | 959 | ||
963 | /* see if we got the address we requested */ | 960 | /* see if we got the address we requested */ |
964 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) | 961 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) |
965 | received_requested_address=TRUE; | 962 | received_requested_address=true; |
966 | 963 | ||
967 | /* see if the servers we wanted a response from talked to us or not */ | 964 | /* see if the servers we wanted a response from talked to us or not */ |
968 | if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){ | 965 | if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){ |
@@ -973,9 +970,9 @@ int get_results(void){ | |||
973 | printf(_(" (duplicate)")); | 970 | printf(_(" (duplicate)")); |
974 | printf(_("\n")); | 971 | printf(_("\n")); |
975 | } | 972 | } |
976 | if(temp_server->answered == FALSE){ | 973 | if(!temp_server->answered){ |
977 | requested_responses++; | 974 | requested_responses++; |
978 | temp_server->answered=TRUE; | 975 | temp_server->answered=true; |
979 | } | 976 | } |
980 | } | 977 | } |
981 | } | 978 | } |
@@ -994,7 +991,7 @@ int get_results(void){ | |||
994 | 991 | ||
995 | /* see if we got the address we requested */ | 992 | /* see if we got the address we requested */ |
996 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) | 993 | if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) |
997 | received_requested_address=TRUE; | 994 | received_requested_address=true; |
998 | } | 995 | } |
999 | } | 996 | } |
1000 | 997 | ||
@@ -1005,7 +1002,7 @@ int get_results(void){ | |||
1005 | result=STATE_CRITICAL; | 1002 | result=STATE_CRITICAL; |
1006 | else if(requested_responses<requested_servers) | 1003 | else if(requested_responses<requested_servers) |
1007 | result=STATE_WARNING; | 1004 | result=STATE_WARNING; |
1008 | else if(request_specific_address==TRUE && received_requested_address==FALSE) | 1005 | else if(request_specific_address && !received_requested_address) |
1009 | result=STATE_WARNING; | 1006 | result=STATE_WARNING; |
1010 | 1007 | ||
1011 | if(result==0) /* garrett honeycutt 2005 */ | 1008 | if(result==0) /* garrett honeycutt 2005 */ |
@@ -1028,8 +1025,8 @@ int get_results(void){ | |||
1028 | if(requested_servers>0) | 1025 | if(requested_servers>0) |
1029 | printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers); | 1026 | printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers); |
1030 | 1027 | ||
1031 | if(request_specific_address==TRUE) | 1028 | if(request_specific_address) |
1032 | printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address==TRUE)?"":_("not ")); | 1029 | printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address)?"":_("not ")); |
1033 | 1030 | ||
1034 | printf(_(", max lease time = ")); | 1031 | printf(_(", max lease time = ")); |
1035 | if(max_lease_time==DHCP_INFINITE_TIME) | 1032 | if(max_lease_time==DHCP_INFINITE_TIME) |
@@ -1090,7 +1087,7 @@ int call_getopt(int argc, char **argv){ | |||
1090 | 1087 | ||
1091 | case 'r': /* address we are requested from DHCP servers */ | 1088 | case 'r': /* address we are requested from DHCP servers */ |
1092 | resolve_host(optarg,&requested_address); | 1089 | resolve_host(optarg,&requested_address); |
1093 | request_specific_address=TRUE; | 1090 | request_specific_address=true; |
1094 | break; | 1091 | break; |
1095 | 1092 | ||
1096 | case 't': /* timeout */ | 1093 | case 't': /* timeout */ |