diff options
Diffstat (limited to 'plugins-root/check_dhcp.c')
-rw-r--r-- | plugins-root/check_dhcp.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index d8afb17..ad67323 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -323,7 +323,8 @@ int get_hardware_address(int sock,char *interface_name){ | |||
323 | #elif defined(__bsd__) | 323 | #elif defined(__bsd__) |
324 | /* King 2004 see ACKNOWLEDGEMENTS */ | 324 | /* King 2004 see ACKNOWLEDGEMENTS */ |
325 | 325 | ||
326 | int mib[6], len; | 326 | size_t len; |
327 | int mib[6]; | ||
327 | char *buf; | 328 | char *buf; |
328 | unsigned char *ptr; | 329 | unsigned char *ptr; |
329 | struct if_msghdr *ifm; | 330 | struct if_msghdr *ifm; |
@@ -463,10 +464,9 @@ int send_dhcp_discover(int sock){ | |||
463 | discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; | 464 | discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; |
464 | 465 | ||
465 | /* | 466 | /* |
466 | * transaction ID is supposed to be random. We won't use the address so | 467 | * transaction ID is supposed to be random. |
467 | * we don't care about high entropy here. time(2) is good enough. | ||
468 | */ | 468 | */ |
469 | srand(time(NULL)); | 469 | srand(time(NULL)^getpid()); |
470 | packet_xid=random(); | 470 | packet_xid=random(); |
471 | discover_packet.xid=htonl(packet_xid); | 471 | discover_packet.xid=htonl(packet_xid); |
472 | 472 | ||
@@ -692,17 +692,11 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st | |||
692 | } | 692 | } |
693 | 693 | ||
694 | else{ | 694 | else{ |
695 | |||
696 | /* why do we need to peek first? i don't know, its a hack. without it, the source address of the first packet received was | ||
697 | not being interpreted correctly. sigh... */ | ||
698 | bzero(&source_address,sizeof(source_address)); | 695 | bzero(&source_address,sizeof(source_address)); |
699 | address_size=sizeof(source_address); | 696 | address_size=sizeof(source_address); |
700 | recv_result=recvfrom(sock,(char *)buffer,buffer_size,MSG_PEEK,(struct sockaddr *)&source_address,&address_size); | ||
701 | if(verbose) | ||
702 | printf("recv_result_1: %d\n",recv_result); | ||
703 | recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size); | 697 | recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size); |
704 | if(verbose) | 698 | if(verbose) |
705 | printf("recv_result_2: %d\n",recv_result); | 699 | printf("recv_result: %d\n",recv_result); |
706 | 700 | ||
707 | if(recv_result==-1){ | 701 | if(recv_result==-1){ |
708 | if(verbose){ | 702 | if(verbose){ |