index 5781f758db2e2f5a3efbc6f2e0ab2c89b90b47a3..bdd348f20dc50c54a3e0872ba0d1e6cfdf21c6b2 100644 (file)
* Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
* Copyright (c) 2001-2007 Nagios Plugin Development Team
*
-* Last Modified: $Date$
-*
* Description:
*
* This file contains the check_dhcp plugin
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
-* $Id$
*
*****************************************************************************/
const char *progname = "check_dhcp";
-const char *revision = "$Revision$";
const char *copyright = "2001-2007";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#elif defined(__sun__) || defined(__solaris__) || defined(__hpux__)
-#define INSAP 22
-#define OUTSAP 24
+#define INSAP 22
+#define OUTSAP 24
#include <signal.h>
#include <ctype.h>
#define bcopy(source, destination, length) memcpy(destination, source, length)
-#define AREA_SZ 5000 /* buffer length in bytes */
+#define AREA_SZ 5000 /* buffer length in bytes */
static u_long ctl_area[AREA_SZ];
static u_long dat_area[AREA_SZ];
static struct strbuf ctl = {AREA_SZ, 0, (char *)ctl_area};
static struct strbuf dat = {AREA_SZ, 0, (char *)dat_area};
-#define GOT_CTRL 1
-#define GOT_DATA 2
-#define GOT_BOTH 3
-#define GOT_INTR 4
-#define GOT_ERR 128
+#define GOT_CTRL 1
+#define GOT_DATA 2
+#define GOT_BOTH 3
+#define GOT_INTR 4
+#define GOT_ERR 128
#define u_int8_t uint8_t
#define u_int16_t uint16_t
requested_server *requested_server_list=NULL;
int valid_responses=0; /* number of valid DHCPOFFERs we received */
-int requested_servers=0;
+int requested_servers=0;
int requested_responses=0;
int request_specific_address=FALSE;
unit = atoi(p) ;
*p = '\0' ;
strncat(dev, interface_name, 6) ;
- }
+ }
else{
printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name);
exit(STATE_UNKNOWN);
/* send the DHCPDISCOVER packet out */
send_dhcp_packet(&discover_packet,sizeof(discover_packet),sock,&sockaddr_broadcast);
- if(verbose)
+ if(verbose)
printf("\n\n");
return OK;
if((current_time-start_time)>=dhcpoffer_timeout)
break;
- if(verbose)
+ if(verbose)
printf("\n\n");
bzero(&source,sizeof(source));
continue;
}
else{
- if(verbose)
+ if(verbose)
printf(_("Result=OK\n"));
responses++;
printf("\n");
if(result==ERROR){
- if(verbose)
+ if(verbose)
printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
continue;
@@ -660,7 +656,7 @@ int send_dhcp_packet(void *buffer, int buffer_size, int sock, struct sockaddr_in
result=sendto(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)dest,sizeof(*dest));
- if(verbose)
+ if(verbose)
printf(_("send_dhcp_packet result: %d\n"),result);
if(result<0)
/* get option length */
option_length=offer_packet->options[x++];
- if(verbose)
+ if(verbose)
printf("Option: %d (0x%02X)\n",option_type,option_length);
/* get option data */
if(verbose){
printf(_("DHCP Server Match: Offerer=%s"),inet_ntoa(temp_offer->server_address));
printf(_(" Requested=%s"),inet_ntoa(temp_server->server_address));
- if(temp_server->answered)
+ if(temp_server->answered)
printf(_(" (duplicate)"));
printf(_("\n"));
}
int option_index = 0;
static struct option long_options[] =
- {
+ {
{"serverip", required_argument,0,'s'},
{"requestedip", required_argument,0,'r'},
{"timeout", required_argument,0,'t'},
break;
case 'V': /* version */
- print_revision(progname,revision);
+ print_revision(progname, NP_VERSION);
exit(STATE_OK);
case 'h': /* help */
/***********************************************************************
* interface:
- * function mac_addr_dlpi - get the mac address of the interface with
+ * function mac_addr_dlpi - get the mac address of the interface with
* type dev (eg lnc, hme) and unit (0, 1 ..)
*
* parameter: addr: an array of six bytes, has to be allocated by the caller
/* print usage help */
void print_help(void){
- print_revision(progname,revision);
+ print_revision(progname, NP_VERSION);
printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n");
printf (COPYRIGHT, copyright, email);