summaryrefslogtreecommitdiffstats
path: root/plugins-root/check_dhcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-root/check_dhcp.c')
-rw-r--r--plugins-root/check_dhcp.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 2a1875c4..b02ee49c 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -141,7 +141,7 @@ typedef struct dhcp_packet_struct{
141 u_int16_t flags; /* flags */ 141 u_int16_t flags; /* flags */
142 struct in_addr ciaddr; /* IP address of this machine (if we already have one) */ 142 struct in_addr ciaddr; /* IP address of this machine (if we already have one) */
143 struct in_addr yiaddr; /* IP address of this machine (offered by the DHCP server) */ 143 struct in_addr yiaddr; /* IP address of this machine (offered by the DHCP server) */
144 struct in_addr siaddr; /* IP address of DHCP server */ 144 struct in_addr siaddr; /* IP address of next server */
145 struct in_addr giaddr; /* IP address of DHCP relay */ 145 struct in_addr giaddr; /* IP address of DHCP relay */
146 unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH]; /* hardware address of this machine */ 146 unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH]; /* hardware address of this machine */
147 char sname [MAX_DHCP_SNAME_LENGTH]; /* name of DHCP server */ 147 char sname [MAX_DHCP_SNAME_LENGTH]; /* name of DHCP server */
@@ -587,11 +587,6 @@ int get_dhcp_offer(int sock){
587 /* Save a copy of "source" into "via" even if it's via itself */ 587 /* Save a copy of "source" into "via" even if it's via itself */
588 memcpy(&via,&source,sizeof(source)) ; 588 memcpy(&via,&source,sizeof(source)) ;
589 589
590 /* If siaddr is non-zero, set "source" to siaddr */
591 if(offer_packet.siaddr.s_addr != 0L){
592 source.sin_addr.s_addr = offer_packet.siaddr.s_addr ;
593 }
594
595 if(verbose){ 590 if(verbose){
596 printf(_("DHCPOFFER from IP address %s"),inet_ntoa(source.sin_addr)); 591 printf(_("DHCPOFFER from IP address %s"),inet_ntoa(source.sin_addr));
597 printf(_(" via %s\n"),inet_ntoa(via.sin_addr)); 592 printf(_(" via %s\n"),inet_ntoa(via.sin_addr));
@@ -839,8 +834,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
839 /* process all DHCP options present in the packet */ 834 /* process all DHCP options present in the packet */
840 for(x=4;x<MAX_DHCP_OPTIONS_LENGTH;){ 835 for(x=4;x<MAX_DHCP_OPTIONS_LENGTH;){
841 836
842 /* end of options (0 is really just a pad, but bail out anyway) */ 837 if((int)offer_packet->options[x]==-1)
843 if((int)offer_packet->options[x]==-1 || (int)offer_packet->options[x]==0)
844 break; 838 break;
845 839
846 /* get option type */ 840 /* get option type */
@@ -872,7 +866,9 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
872 } 866 }
873 867
874 /* skip option data we're ignoring */ 868 /* skip option data we're ignoring */
875 if(option_type!=DHCP_OPTION_REBINDING_TIME) 869 if(option_type==0) /* "pad" option, see RFC 2132 (3.1) */
870 x+=1;
871 else
876 x+=option_length; 872 x+=option_length;
877 } 873 }
878 874
@@ -903,9 +899,9 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
903 * the next bootstrap service (e.g., delivery of an operating system 899 * the next bootstrap service (e.g., delivery of an operating system
904 * executable image). A DHCP server always returns its own address in 900 * executable image). A DHCP server always returns its own address in
905 * the 'server identifier' option." 'serv_ident' is the 'server 901 * the 'server identifier' option." 'serv_ident' is the 'server
906 * identifier' option, 'source' is the 'siaddr' field or (if 'siaddr' 902 * identifier' option, 'source' is the IP address we received the
907 * wasn't available) the IP address we received the DHCPOFFER from. If 903 * DHCPOFFER from. If 'serv_ident' isn't available for some reason, we
908 * 'serv_ident' isn't available for some reason, we use 'source'. 904 * use 'source'.
909 */ 905 */
910 new_offer->server_address=serv_ident.s_addr?serv_ident:source; 906 new_offer->server_address=serv_ident.s_addr?serv_ident:source;
911 new_offer->offered_address=offer_packet->yiaddr; 907 new_offer->offered_address=offer_packet->yiaddr;