[monitoring-plugins] New variable is actually a boolean

Lorenz Kästle git at monitoring-plugins.org
Sun Oct 1 15:00:12 CEST 2023


 Module: monitoring-plugins
 Branch: check_dhcp_rogue_detection
 Commit: 316a3683d1e01675d59d2ee78bedc69e68347b95
 Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
   Date: Sun Oct  1 14:46:13 2023 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=316a368

New variable is actually a boolean

---

 plugins-root/check_dhcp.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 9aeff2b..bc010e1 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -156,7 +156,7 @@ typedef struct dhcp_offer_struct{
 	u_int32_t lease_time;            /* lease time in seconds */
 	u_int32_t renewal_time;          /* renewal time in seconds */
 	u_int32_t rebinding_time;        /* rebinding time in seconds */
-	u_int8_t desired;                 /* is this offer desired (necessary in exclusive mode) */
+	bool desired;                 /* is this offer desired (necessary in exclusive mode) */
 	struct dhcp_offer_struct *next;
         }dhcp_offer;
 
@@ -199,8 +199,8 @@ typedef struct requested_server_struct{
 #define ETHERNET_HARDWARE_ADDRESS            1     /* used in htype field of dhcp packet */
 #define ETHERNET_HARDWARE_ADDRESS_LENGTH     6     /* length of Ethernet hardware addresses */
 
-u_int8_t unicast = 0;        /* unicast mode: mimic a DHCP relay */
-u_int8_t exclusive = 0;      /* exclusive mode aka "rogue DHCP server detection" */
+bool unicast = 0;        /* unicast mode: mimic a DHCP relay */
+bool exclusive = 0;      /* exclusive mode aka "rogue DHCP server detection" */
 struct in_addr my_ip;        /* our address (required for relay) */
 struct in_addr dhcp_ip;      /* server to query (if in unicast mode) */
 unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]="";
@@ -902,7 +902,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
 	new_offer->lease_time=dhcp_lease_time;
 	new_offer->renewal_time=dhcp_renewal_time;
 	new_offer->rebinding_time=dhcp_rebinding_time;
-	new_offer->desired=FALSE; /* exclusive mode: we'll check that in get_results */
+	new_offer->desired=false; /* exclusive mode: we'll check that in get_results */
 
 
 	if(verbose){
@@ -983,7 +983,7 @@ int get_results(void){
 					if(temp_server->answered == FALSE){
 						requested_responses++;
 						temp_server->answered=TRUE;
-						temp_offer->desired=TRUE;
+						temp_offer->desired=true;
 					}
 		        	}
                 	}
@@ -991,7 +991,7 @@ int get_results(void){
 
 		/* exclusive mode: check for undesired offers */
 		for(temp_offer=dhcp_offer_list;temp_offer!=NULL;temp_offer=temp_offer->next) {
-			if (temp_offer->desired == FALSE) {
+			if (!temp_offer->desired) {
 				undesired_offer=temp_offer; /* Checks only for the first undesired offer */
 				break; /* no further checks needed */
 			}
@@ -1148,10 +1148,10 @@ int call_getopt(int argc, char **argv){
 			break;
 
 		case 'u': /* unicast testing */
-			unicast=1;
+			unicast=true;
 			break;
 		case 'x': /* exclusive testing aka "rogue DHCP server detection" */
-			exclusive=1;
+			exclusive=true;
 			break;
 
 		case 'V': /* version */



More information about the Commits mailing list