1996-03-07 21:08:11 +00:00
|
|
|
/* linux.h
|
|
|
|
|
1996-05-20 00:39:25 +00:00
|
|
|
System dependencies for Linux.
|
1996-03-07 21:08:11 +00:00
|
|
|
|
1996-05-20 00:39:25 +00:00
|
|
|
Based on a configuration originally supplied by Jonathan Stone. */
|
1996-03-07 21:08:11 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-19 19:16:28 +00:00
|
|
|
* Copyright (c) 2004,2005,2007 by Internet Systems Consortium, Inc. ("ISC")
|
2005-03-17 20:15:29 +00:00
|
|
|
* Copyright (c) 1996-2003 by Internet Software Consortium
|
1996-03-07 21:08:11 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
1996-03-07 21:08:11 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
|
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
1996-03-07 21:08:11 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* Internet Systems Consortium, Inc.
|
|
|
|
* 950 Charter Street
|
|
|
|
* Redwood City, CA 94063
|
|
|
|
* <info@isc.org>
|
|
|
|
* http://www.isc.org/
|
2000-03-17 04:00:32 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* This software has been written for Internet Systems Consortium
|
2000-03-17 04:00:32 +00:00
|
|
|
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
|
2005-03-17 20:15:29 +00:00
|
|
|
* To learn more about Internet Systems Consortium, see
|
2000-03-17 04:00:32 +00:00
|
|
|
* ``http://www.isc.org/''. To learn more about Vixie Enterprises,
|
|
|
|
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
|
|
|
|
* ``http://www.nominum.com''.
|
1996-03-07 21:08:11 +00:00
|
|
|
*/
|
|
|
|
|
1996-05-20 00:39:25 +00:00
|
|
|
#include <features.h>
|
1996-05-23 02:37:28 +00:00
|
|
|
#ifndef __BIT_TYPES_DEFINED__
|
|
|
|
#define __BIT_TYPES_DEFINED__
|
1996-05-20 00:39:25 +00:00
|
|
|
#undef __USE_BSD
|
|
|
|
typedef char int8_t;
|
|
|
|
typedef short int16_t;
|
|
|
|
typedef long int32_t;
|
|
|
|
|
|
|
|
typedef unsigned char u_int8_t;
|
|
|
|
typedef unsigned short u_int16_t;
|
|
|
|
typedef unsigned long u_int32_t;
|
1996-05-23 02:37:28 +00:00
|
|
|
#endif /* __BIT_TYPES_DEFINED__ */
|
1996-05-20 00:39:25 +00:00
|
|
|
|
1999-02-14 19:04:05 +00:00
|
|
|
typedef u_int8_t u8;
|
|
|
|
typedef u_int16_t u16;
|
|
|
|
typedef u_int32_t u32;
|
|
|
|
|
1996-05-17 00:29:29 +00:00
|
|
|
#include <syslog.h>
|
1996-03-07 21:08:11 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
extern int h_errno;
|
|
|
|
|
|
|
|
#include <net/if.h>
|
1997-01-02 12:00:19 +00:00
|
|
|
#include <net/route.h>
|
1998-03-16 06:16:30 +00:00
|
|
|
|
1999-02-14 19:04:05 +00:00
|
|
|
#if LINUX_MAJOR == 1
|
1998-03-16 06:16:30 +00:00
|
|
|
# include <linux/if_arp.h>
|
|
|
|
# include <linux/time.h> /* also necessary */
|
|
|
|
#else
|
|
|
|
# include <net/if_arp.h>
|
|
|
|
#endif
|
1996-09-11 06:36:41 +00:00
|
|
|
|
1996-03-07 21:08:11 +00:00
|
|
|
#include <sys/time.h> /* gettimeofday()*/
|
|
|
|
|
1999-02-25 23:30:43 +00:00
|
|
|
/* Databases go in /var/state/dhcp. It would also be valid to put them
|
|
|
|
in /var/state/misc - indeed, given that there's only one lease file, it
|
|
|
|
would probably be better. However, I have some ideas for optimizing
|
|
|
|
the lease database that may result in a _lot_ of smaller files being
|
2007-01-29 10:25:55 +00:00
|
|
|
created, so in that context it makes more sense to have a separate
|
1999-02-25 23:30:43 +00:00
|
|
|
directory. */
|
|
|
|
|
|
|
|
#ifndef _PATH_DHCPD_DB
|
|
|
|
#define _PATH_DHCPD_DB "/var/state/dhcp/dhcpd.leases"
|
1997-02-18 14:34:14 +00:00
|
|
|
#endif
|
2007-10-27 19:15:37 +00:00
|
|
|
#ifndef _PATH_DHCPD6_DB
|
|
|
|
#define _PATH_DHCPD6_DB "/var/state/dhcp/dhcpd6.leases"
|
|
|
|
#endif
|
1999-02-25 23:30:43 +00:00
|
|
|
|
1997-02-18 14:34:14 +00:00
|
|
|
#ifndef _PATH_DHCLIENT_DB
|
1999-02-25 23:30:43 +00:00
|
|
|
#define _PATH_DHCLIENT_DB "/var/state/dhcp/dhclient.leases"
|
1997-02-18 14:34:14 +00:00
|
|
|
#endif
|
2007-05-08 23:05:22 +00:00
|
|
|
#ifndef _PATH_DHCLIENT6_DB
|
|
|
|
#define _PATH_DHCLIENT6_DB "/var/state/dhcp/dhclient6.leases"
|
|
|
|
#endif
|
1996-03-07 21:08:11 +00:00
|
|
|
|
|
|
|
/* Varargs stuff... */
|
|
|
|
#include <stdarg.h>
|
|
|
|
#define VA_DOTDOTDOT ...
|
|
|
|
#define VA_start(list, last) va_start (list, last)
|
|
|
|
#define va_dcl
|
1996-05-20 00:39:25 +00:00
|
|
|
|
1996-03-07 21:08:11 +00:00
|
|
|
#define VOIDPTR void *
|
|
|
|
|
2006-02-24 23:16:32 +00:00
|
|
|
#if defined(__alpha__) || defined(__amd64__) || defined(__ia64__) || \
|
|
|
|
defined(__sparc64__)
|
|
|
|
# define PTRSIZE_64BIT
|
|
|
|
#endif
|
|
|
|
|
1996-03-07 21:08:11 +00:00
|
|
|
#define EOL '\n'
|
|
|
|
|
|
|
|
/* Time stuff... */
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#define TIME time_t
|
|
|
|
#define GET_TIME(x) time ((x))
|
|
|
|
|
1999-02-25 23:30:43 +00:00
|
|
|
#if (LINUX_MAJOR >= 2)
|
2006-02-24 23:16:32 +00:00
|
|
|
# if ((LINUX_MAJOR > 2) || (LINUX_MINOR >= 1))
|
1999-02-25 23:30:43 +00:00
|
|
|
# if defined (USE_DEFAULT_NETWORK)
|
|
|
|
# define USE_LPF
|
|
|
|
# endif
|
2001-05-01 23:12:34 +00:00
|
|
|
# if !defined (__sparc__) /* XXX hopefully this will be fixed someday */
|
2001-05-17 19:04:09 +00:00
|
|
|
# define SIOCGIFCONF_ZERO_PROBE
|
2001-05-01 23:12:34 +00:00
|
|
|
# endif
|
1999-02-14 19:04:05 +00:00
|
|
|
# define LINUX_SLASHPROC_DISCOVERY
|
|
|
|
# define PROCDEV_DEVICE "/proc/net/dev"
|
1999-02-25 23:30:43 +00:00
|
|
|
# define HAVE_ARPHRD_TUNNEL
|
1999-05-27 17:43:28 +00:00
|
|
|
# define HAVE_TR_SUPPORT
|
1999-02-25 23:30:43 +00:00
|
|
|
# endif
|
|
|
|
# define HAVE_ARPHRD_METRICOM
|
|
|
|
# define HAVE_ARPHRD_IEEE802
|
|
|
|
# define HAVE_ARPHRD_LOOPBACK
|
|
|
|
# define HAVE_SO_BINDTODEVICE
|
|
|
|
# define HAVE_SIOCGIFHWADDR
|
2000-01-05 18:10:07 +00:00
|
|
|
# define HAVE_SETFD
|
1999-02-25 23:30:43 +00:00
|
|
|
#endif
|
|
|
|
|
2000-04-07 05:08:13 +00:00
|
|
|
#if defined (SIOCGIFHWADDR) && !defined (HAVE_SIOCGIFHWADDR)
|
|
|
|
# define HAVE_SIOCGIFHWADDR
|
|
|
|
#endif
|
|
|
|
|
1999-02-25 23:30:43 +00:00
|
|
|
#if !defined (USE_LPF)
|
|
|
|
# if defined (USE_DEFAULT_NETWORK)
|
1996-05-13 00:10:37 +00:00
|
|
|
# define USE_SOCKETS
|
2000-06-20 20:27:37 +00:00
|
|
|
# define SOCKET_CAN_RECEIVE_UNICAST_UNCONFIGURED
|
1999-02-14 19:04:05 +00:00
|
|
|
# endif
|
1999-02-25 23:30:43 +00:00
|
|
|
# define IGNORE_HOSTUNREACH
|
1996-05-13 00:10:37 +00:00
|
|
|
#endif
|
1996-08-27 09:56:21 +00:00
|
|
|
|
|
|
|
#define ALIAS_NAMES_PERMUTED
|
1997-03-29 00:08:40 +00:00
|
|
|
#define SKIP_DUMMY_INTERFACES
|
2000-02-02 05:38:07 +00:00
|
|
|
|
|
|
|
#ifdef NEED_PRAND_CONF
|
|
|
|
#ifndef HAVE_DEV_RANDOM
|
|
|
|
# define HAVE_DEV_RANDOM 1
|
|
|
|
#endif /* HAVE_DEV_RANDOM */
|
|
|
|
|
|
|
|
const char *cmds[] = {
|
|
|
|
"/bin/ps -axlw 2>&1",
|
|
|
|
"/sbin/arp -an 2>&1",
|
|
|
|
"/bin/netstat -an 2>&1",
|
|
|
|
"/bin/df 2>&1",
|
|
|
|
"/usr/bin/dig com. soa +ti=1 +retry=0 2>&1",
|
|
|
|
"/usr/bin/uptime 2>&1",
|
|
|
|
"/bin/netstat -s 2>&1",
|
|
|
|
"/usr/bin/dig . soa +ti=1 +retry=0 2>&1",
|
|
|
|
"/usr/bin/vmstat 2>&1",
|
|
|
|
"/usr/bin/w 2>&1",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *dirs[] = {
|
|
|
|
"/tmp",
|
|
|
|
"/usr/tmp",
|
|
|
|
".",
|
|
|
|
"/",
|
|
|
|
"/var/spool",
|
|
|
|
"/dev",
|
|
|
|
"/var/spool/mail",
|
|
|
|
"/home",
|
|
|
|
"/usr/home",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *files[] = {
|
|
|
|
"/proc/stat",
|
|
|
|
"/proc/rtc",
|
|
|
|
"/proc/meminfo",
|
|
|
|
"/proc/interrupts",
|
|
|
|
"/proc/self/status",
|
|
|
|
"/var/log/messages",
|
|
|
|
"/var/log/wtmp",
|
|
|
|
"/var/log/lastlog",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
#endif /* NEED_PRAND_CONF */
|