Imported Upstream version 1.4.13+git200906171200

This commit is contained in:
Jan Wagner 2013-11-26 23:56:50 +01:00
parent 4ab9f0d24c
commit d0b8ab8112
362 changed files with 34110 additions and 10773 deletions

View file

@ -6,8 +6,6 @@
* Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
* Copyright (c) 2001-2007 Nagios Plugin Development Team
*
* Last Modified: $Date: 2008-05-07 11:02:42 +0100 (Wed, 07 May 2008) $
*
* Description:
*
* This file contains the check_dhcp plugin
@ -32,12 +30,10 @@
* 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: check_dhcp.c 1991 2008-05-07 10:02:42Z dermoth $
*
*****************************************************************************/
const char *progname = "check_dhcp";
const char *revision = "$Revision: 1991 $";
const char *copyright = "2001-2007";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
@ -79,8 +75,8 @@ 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>
@ -90,17 +86,17 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
#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
@ -195,7 +191,6 @@ typedef struct requested_server_struct{
#define DHCP_INFINITE_TIME 0xFFFFFFFF
#define DHCP_BROADCAST_FLAG 32768
#define DHCP_UNICAST_FLAG 0
#define DHCP_SERVER_PORT 67
#define DHCP_CLIENT_PORT 68
@ -223,7 +218,7 @@ dhcp_offer *dhcp_offer_list=NULL;
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;
@ -383,7 +378,7 @@ int get_hardware_address(int sock,char *interface_name){
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);
@ -536,7 +531,7 @@ int send_dhcp_discover(int sock){
/* 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;
@ -565,7 +560,7 @@ int get_dhcp_offer(int sock){
if((current_time-start_time)>=dhcpoffer_timeout)
break;
if(verbose)
if(verbose)
printf("\n\n");
bzero(&source,sizeof(source));
@ -582,7 +577,7 @@ int get_dhcp_offer(int sock){
continue;
}
else{
if(verbose)
if(verbose)
printf(_("Result=OK\n"));
responses++;
@ -627,7 +622,7 @@ int get_dhcp_offer(int sock){
printf("\n");
if(result==ERROR){
if(verbose)
if(verbose)
printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
continue;
@ -661,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)
@ -767,7 +762,7 @@ int create_dhcp_socket(void){
}
/* set the broadcast option - we need this to listen to DHCP broadcast messages */
if(setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
if(!unicast && setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
printf(_("Error: Could not set broadcast option on DHCP socket!\n"));
exit(STATE_UNKNOWN);
}
@ -854,7 +849,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
/* 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 */
@ -990,7 +985,7 @@ int get_results(void){
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"));
}
@ -1091,7 +1086,7 @@ int call_getopt(int argc, char **argv){
int option_index = 0;
static struct option long_options[] =
{
{
{"serverip", required_argument,0,'s'},
{"requestedip", required_argument,0,'r'},
{"timeout", required_argument,0,'t'},
@ -1169,7 +1164,7 @@ int call_getopt(int argc, char **argv){
break;
case 'V': /* version */
print_revision(progname,revision);
print_revision(progname, NP_VERSION);
exit(STATE_OK);
case 'h': /* help */
@ -1307,7 +1302,7 @@ static int dl_bind(int fd, int sap, u_char *addr){
/***********************************************************************
* 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
@ -1386,7 +1381,7 @@ void print_hardware_address(const unsigned char *address){
/* 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);