summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Eble <psychotrahe@users.sourceforge.net>2007-05-13 12:28:30 +0000
committerMatthias Eble <psychotrahe@users.sourceforge.net>2007-05-13 12:28:30 +0000
commit09f87e314b898eb3d67ba41c75fa2603b47bfd7e (patch)
tree48a2fa89e9276dbf695b39fb9590b71f5abecf81
parent1ef19943e19fe30a5fbd7607e53c75c98db9974c (diff)
downloadmonitoring-plugins-09f87e314b898eb3d67ba41c75fa2603b47bfd7e.tar.gz
check_dhcp now adds mandatory end option (Thanks to Enrico Scholz - #1675306)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1712 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--THANKS.in1
-rw-r--r--plugins-root/check_dhcp.c17
2 files changed, 12 insertions, 6 deletions
diff --git a/THANKS.in b/THANKS.in
index baed6965..b35c4381 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -219,3 +219,4 @@ Denis Knauf
219Matthias Flacke 219Matthias Flacke
220Emil Michles 220Emil Michles
221Ask Bjoern Hansen 221Ask Bjoern Hansen
222Enrico Scholz
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 72405fea..8559d634 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -185,6 +185,7 @@ typedef struct requested_server_struct{
185#define DHCP_OPTION_SERVER_IDENTIFIER 54 185#define DHCP_OPTION_SERVER_IDENTIFIER 54
186#define DHCP_OPTION_RENEWAL_TIME 58 186#define DHCP_OPTION_RENEWAL_TIME 58
187#define DHCP_OPTION_REBINDING_TIME 59 187#define DHCP_OPTION_REBINDING_TIME 59
188#define DHCP_OPTION_END 255
188 189
189#define DHCP_INFINITE_TIME 0xFFFFFFFF 190#define DHCP_INFINITE_TIME 0xFFFFFFFF
190 191
@@ -401,6 +402,7 @@ int get_hardware_address(int sock,char *interface_name){
401int send_dhcp_discover(int sock){ 402int send_dhcp_discover(int sock){
402 dhcp_packet discover_packet; 403 dhcp_packet discover_packet;
403 struct sockaddr_in sockaddr_broadcast; 404 struct sockaddr_in sockaddr_broadcast;
405 unsigned short opts;
404 406
405 407
406 /* clear the packet data structure */ 408 /* clear the packet data structure */
@@ -442,17 +444,20 @@ int send_dhcp_discover(int sock){
442 discover_packet.options[2]='\x53'; 444 discover_packet.options[2]='\x53';
443 discover_packet.options[3]='\x63'; 445 discover_packet.options[3]='\x63';
444 446
447 opts = 4;
445 /* DHCP message type is embedded in options field */ 448 /* DHCP message type is embedded in options field */
446 discover_packet.options[4]=DHCP_OPTION_MESSAGE_TYPE; /* DHCP message type option identifier */ 449 discover_packet.options[opts++]=DHCP_OPTION_MESSAGE_TYPE; /* DHCP message type option identifier */
447 discover_packet.options[5]='\x01'; /* DHCP message option length in bytes */ 450 discover_packet.options[opts++]='\x01'; /* DHCP message option length in bytes */
448 discover_packet.options[6]=DHCPDISCOVER; 451 discover_packet.options[opts++]=DHCPDISCOVER;
449 452
450 /* the IP address we're requesting */ 453 /* the IP address we're requesting */
451 if(request_specific_address==TRUE){ 454 if(request_specific_address==TRUE){
452 discover_packet.options[7]=DHCP_OPTION_REQUESTED_ADDRESS; 455 discover_packet.options[opts++]=DHCP_OPTION_REQUESTED_ADDRESS;
453 discover_packet.options[8]='\x04'; 456 discover_packet.options[opts++]='\x04';
454 memcpy(&discover_packet.options[9],&requested_address,sizeof(requested_address)); 457 memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address));
458 opts += sizeof(requested_address);
455 } 459 }
460 discover_packet.options[opts++]=DHCP_OPTION_END;
456 461
457 /* send the DHCPDISCOVER packet to broadcast address */ 462 /* send the DHCPDISCOVER packet to broadcast address */
458 sockaddr_broadcast.sin_family=AF_INET; 463 sockaddr_broadcast.sin_family=AF_INET;