From 0453d6d1e206c1f4c156bf73c473608a8c0da4f5 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 1 Apr 2025 00:44:26 +0200 Subject: Refactor check_dhcp --- plugins-root/check_dhcp.d/config.h | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 plugins-root/check_dhcp.d/config.h (limited to 'plugins-root/check_dhcp.d/config.h') diff --git a/plugins-root/check_dhcp.d/config.h b/plugins-root/check_dhcp.d/config.h new file mode 100644 index 00000000..f189068b --- /dev/null +++ b/plugins-root/check_dhcp.d/config.h @@ -0,0 +1,50 @@ +#pragma once + +#include "../../config.h" +#include "../lib/states.h" +#include +#include +#include "net/if.h" +#include "output.h" + +typedef struct requested_server_struct { + struct in_addr server_address; + bool answered; + struct requested_server_struct *next; +} requested_server; + +typedef struct check_dhcp_config { + bool unicast_mode; /* unicast mode: mimic a DHCP relay */ + bool exclusive_mode; /* exclusive mode aka "rogue DHCP server detection" */ + int num_of_requested_servers; + struct in_addr dhcp_ip; /* server to query (if in unicast mode) */ + struct in_addr requested_address; + bool request_specific_address; + + int dhcpoffer_timeout; + unsigned char *user_specified_mac; + char network_interface_name[IFNAMSIZ]; + requested_server *requested_server_list; + + mp_output_format output_format; + bool output_format_is_set; +} check_dhcp_config; + +check_dhcp_config check_dhcp_config_init(void) { + check_dhcp_config tmp = { + .unicast_mode = false, + .exclusive_mode = false, + .num_of_requested_servers = 0, + .dhcp_ip = {0}, + .requested_address = {0}, + .request_specific_address = false, + + .dhcpoffer_timeout = 2, + .user_specified_mac = NULL, + .network_interface_name = "eth0", + .requested_server_list = NULL, + + .output_format_is_set = false, + }; + return tmp; +} -- cgit v1.2.3-74-g34f1