[nagiosplug] check_dhcp: Don't misinterpret the "siaddr" field
"Nagios Plugin Development" <[email protected]> Wed, 13 Jun 2012 22:50:22 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug Branch: master Commit: 4d5276273287ef59881b541ba96279e91974a4b2 Author: Holger Weiss <[email protected]> Date: Thu Jun 14 00:39:55 2012 +0200 URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=4d52762 check_dhcp: Don't misinterpret the "siaddr" field RFC 2131 (2.) says: "DHCP clarifies the interpretation of the 'siaddr' field as the address of the server to use in the next step of the client's bootstrap process." So, we shouldn't interpret this field as the DHCP server's own address. (#3503921 - Jason Ellison) --- THANKS.in | 1 + plugins-root/check_dhcp.c | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/THANKS.in b/THANKS.in index 32a8868..943acdb 100644 --- a/THANKS.in +++ b/THANKS.in @@ -273,3 +273,4 @@ Jason Lunn Alex Griffin Marc Remy Matej Vela +Jason Ellison diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index ac89274..b02ee49 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c @@ -141,7 +141,7 @@ typedef struct dhcp_packet_struct{ u_int16_t flags; /* flags */ struct in_addr ciaddr; /* IP address of this machine (if we already have one) */ struct in_addr yiaddr; /* IP address of this machine (offered by the DHCP server) */ - struct in_addr siaddr; /* IP address of DHCP server */ + struct in_addr siaddr; /* IP address of next server */ struct in_addr giaddr; /* IP address of DHCP relay */ unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH]; /* hardware address of this machine */ char sname [MAX_DHCP_SNAME_LENGTH]; /* name of DHCP server */ @@ -587,11 +587,6 @@ int get_dhcp_offer(int sock){ /* Save a copy of "source" into "via" even if it's via itself */ memcpy(&via,&source,sizeof(source)) ; - /* If siaddr is non-zero, set "source" to siaddr */ - if(offer_packet.siaddr.s_addr != 0L){ - source.sin_addr.s_addr = offer_packet.siaddr.s_addr ; - } - if(verbose){ printf(_("DHCPOFFER from IP address %s"),inet_ntoa(source.sin_addr)); printf(_(" via %s\n"),inet_ntoa(via.sin_addr)); @@ -904,9 +899,9 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){ * the next bootstrap service (e.g., delivery of an operating system * executable image). A DHCP server always returns its own address in * the 'server identifier' option." 'serv_ident' is the 'server - * identifier' option, 'source' is the 'siaddr' field or (if 'siaddr' - * wasn't available) the IP address we received the DHCPOFFER from. If - * 'serv_ident' isn't available for some reason, we use 'source'. + * identifier' option, 'source' is the IP address we received the + * DHCPOFFER from. If 'serv_ident' isn't available for some reason, we + * use 'source'. */ new_offer->server_address=serv_ident.s_addr?serv_ident:source; new_offer->offered_address=offer_packet->yiaddr; ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/