/******************************************************************************
*
* Nagios check_icmp plugin
*
* License: GPL
* Copyright (c) 2005-2007 nagios-plugins team
*
* Original Author : Andreas Ericsson <ae@op5.se>
*
* Last Modified: $Date: 2007-09-15 12:55:12 +0100 (Sat, 15 Sep 2007) $
*
* Description:
*
* This file contains the check_icmp plugin
*
* Relevant RFC's: 792 (ICMP), 791 (IP)
*
* This program was modeled somewhat after the check_icmp program,
* which was in turn a hack of fping (www.fping.org) but has been
* completely rewritten since to generate higher precision rta values,
* and support several different modes as well as setting ttl to control.
* redundant routes. The only remainders of fping is currently a few
* function names.
*
* License Information:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: check_icmp.c 1779 2007-09-15 11:55:12Z hweiss $
*
*****************************************************************************/
/* progname may change */
/* char *progname = "check_icmp"; */
char *progname;
const char *revision = "$Revision: 1779 $";
const char *copyright = "2005-2007";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
/** nagios plugins basic includes */
#include "common.h"
#include "netutils.h"
#include "utils.h"
#include <sys/time.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <stddef.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
#include <signal.h>
/** sometimes undefined system macros (quite a few, actually) **/
#ifndef MAXTTL
# define MAXTTL 255
#endif
#ifndef INADDR_NONE
# define INADDR_NONE 0xffffffU
#endif
#ifndef SOL_IP
#define SOL_IP 0
#endif
/* we bundle these in one #ifndef, since they're all from BSD
* Put individual #ifndef's around those that bother you */
#ifndef ICMP_UNREACH_NET_UNKNOWN
# define ICMP_UNREACH_NET_UNKNOWN 6
# define ICMP_UNREACH_HOST_UNKNOWN 7
# define ICMP_UNREACH_ISOLATED 8
# define ICMP_UNREACH_NET_PROHIB 9
# define ICMP_UNREACH_HOST_PROHIB 10
# define ICMP_UNREACH_TOSNET 11
# define ICMP_UNREACH_TOSHOST 12
#endif
/* tru64 has the ones above, but not these */
=1= |