/* * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- * http://www.ntop.org * * Copyright (C) 1998-2007 Luca Deri * * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* ntop's defines - what's what and what's where ntop.h This is the 'control' for the various globals-*.h files. It's a single include to drag in the necessary headers, defines ntop data structures (e.g. the structs), etc. A few globally #defined items which control expansion of the standard and system headers MUST be here. Any tests - #if () #error #endif type stuff goes here at the bottom. ntop.h includes config.h -- generated by ./configure various standard and system headers globals-defines.h All of the #defines used by ntop should be here, except for those explicitly discussed below. globals-structtypes.h Every struct and typedef, including #define used instead of typedef. and globals-core.h This defines the extern functions, exported from one ntop source file to the others. "function" which are actually #define macros are here. All programs must include ntop.h. Any program which requires the "reporting" functions also have to include globals-report.h. */ #ifndef NTOP_H #define NTOP_H #if defined(HAVE_CONFIG_H) #include "config.h" #endif /* See http://www.redhat.com/magazine/009jul05/features/execshield/ */ #ifndef _FORTIFY_SOURCE #define _FORTIFY_SOURCE 2 #endif /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Standard header expansion control items */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #if defined(__linux__) #ifndef LINUX #define LINUX #endif #endif #ifdef LINUX /* * This allows to hide the (minimal) differences between linux and BSD */ #include #define __FAVOR_BSD #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #endif /* linux */ #ifdef __GNUC__ #define _UNUSED_ __attribute__((unused)) #else #define _UNUSED_ #define __attribute__(a) #endif /* On some systems these defines make reentrant library routines available. Courtesy of Andreas Pfaller . */ #if !defined(_REENTRANT) #define _REENTRANT #endif #define _THREAD_SAFE /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* includes */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* ************************************************************************************** * * Standard c headers (operating system/gcc supplied) * * **************************************************************************************/ #include #include #include #ifndef WIN32 #include #endif #include #if defined(__linux__) #define _XOPEN_SOURCE /* glibc2 needs this */ #endif #include #include #include #include #ifndef WIN32 #include #endif #include #include #include #include #ifndef WIN32 #include #endif #ifndef WIN32 #include #endif #include #ifndef WIN32 #include #endif #ifdef HAVE_SYS_PARAM_H #include /* OpenBSD wants it */ #endif #ifdef HAVE_SYS_UTSNAME_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_SYS_LDR_H #include #endif #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_DL_H #include #endif #ifdef HAVE_DIRENT_H #include #endif #ifdef HAVE_DLFCN_H #include #endif /* Additions below courtesy of Abdelkader Lahmadi */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* Courtesy of Brent L. Bates */ /*WARNING: There is nothing in ./configure to test for or enable this * OTOP, there are no reported bugs either. * -----Burton (4/2003) */ #ifdef HAVE_STANDARDS_H #include #endif #ifdef HAVE_CRYPT_H /* Fix courtesy of Charles M. Gagnon */ #ifdef HAVE_OPENSSL #define des_encrypt MOVE_AWAY_des_encrypt #include #undef des_encrypt #else #include #endif #endif /* * thread management */ #ifdef MAKE_WITH_SCHED_YIELD #ifdef HAVE_SCHED_H # ifdef LINUX # undef HAVE_SCHED_H /* Linux doesn't seem to really like it */ # else # include # endif #endif #ifdef HAVE_SYS_SCHED_H #include #endif #endif /* MAKE_WITH_SCHED_YIELD */ #ifdef HAVE_PTHREAD_H #include #ifndef _THREAD_SAFE #define _THREAD_SAFE #endif #endif #ifdef HAVE_IF_H #include "if.h" /* OSF1 has it */ #endif /* ************************************************************************************** * * universal headers for network programming code * * **************************************************************************************/ #ifndef WIN32 #include #endif #ifdef HAVE_SYS_UN_H #include #endif #ifndef WIN32 #include #include #ifdef HAVE_ARPA_INET_H #include #endif #include #ifdef HAVE_SCTP #include #endif /* Additions below courtesy of Abdelkader Lahmadi And thanks to Julien TOUCHE [julien.touche@lycos.com] for pointing out the sys/socket.h <-> net/route.h dependency under OpenBSD. */ #ifdef HAVE_NET_IF_DL_H #include #endif #ifdef HAVE_NET_ROUTE_H #include #endif #include #include #include #include #include #ifndef HAVE_IPV6_H #include #endif #ifndef HAVE_ICMPV6_H #include #endif #endif #ifdef HAVE_NETINET_IF_ETHER_H #include #endif #ifdef HAVE_ARPA_NAMESER_H #include #endif #ifdef HAVE_NET_ETHERNET_H #include #endif #ifdef HAVE_ETHERTYPE_H #include #endif /* * #ifdefs below courtesy of * "David Masterson" * Scott Renfro (MinGW) * Combined and revised 12-2003 for libpcap 0.8.x - BMSIII */ #if defined(WIN32) && defined(__GNUC__) #include "bpf.h" #include "pcap.h" #endif /* ************************************************************************************** * * OS Specific stuff * * **************************************************************************************/ #ifndef WIN32 #ifdef HAVE_PWD_H #include #endif #endif /* * MAC OSX for plugins */ #ifndef RTLD_NOW #ifdef RTLD_LAZY #define RTLD_NOW RTLD_LAZY #else #define RTLD_NOW 1 /* MacOS X Patch */ #endif #endif /* ************************************************************************************** * * Feature specific stuff * * **************************************************************************************/ #if defined(HAVE_MYSQL_H) || defined(WIN32) #if defined(WIN32) #define my_socket_defined #define my_socket int #endif #include /* Headers for MySQL usage */ #include #endif #ifndef WIN32 #if defined(HAVE_SYS_SCHED_H) && !defined(FREEBSD) #include #endif #if defined(HAVE_SCHED_H) #include #endif /* * Switched pthread with semaphore. * Courtesy of * Wayne Roberts */ # include #endif /* WIN32 */ /* * Packet Capture Library by Lawrence Berkeley National Laboratory * Network Research Group */ #include "pcap.h" #ifdef HAVE_OPENSSL #include #include #include #include #include #include #endif /* HAVE_OPENSSL */ /* Compressed HTTP responses via zlib */ #include /* * gdbm */ #ifdef WIN32 #ifndef __GNUC__ #include #endif #endif /* WIN32 */ #include #ifdef HAVE_TCPD_H #include #endif /* * Syslog stuff. Any routine which expects to reference facilitynames must * define SYSLOG_NAMES before including ntop.h */ #ifdef HAVE_SYS_SYSLOG_H #include #else #ifdef HAVE_SYSLOG_H #include #endif #endif #ifdef HAVE_SHADOW_H #include #endif #ifdef HAVE_LIBPCRE #include #endif #ifndef EMBEDDED #include "rrd.h" #endif #ifdef HAVE_GETOPT_H #include "getopt.h" #endif /* ************************************************************************************** * * Used for debug * * **************************************************************************************/ #ifdef MAKE_WITH_SAFER_ROUTINES #elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 1) #elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 2) #elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 3) #include "leaks.h" #elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 4) #include #elif defined(MEMORY_DEBUG) #else #endif /* MAKE_WITH_SAFER_ROUTINES / MEMORY_DEBUG */ /* ************************************************************************************** * * The ntop globals-xxxx includes * * **************************************************************************************/ #include "globals-defines.h" #include "globals-structtypes.h" /* The WIN32 specific stuff */ #ifdef WIN32 #include "ntop_win32.h" #endif /* * i18n */ #ifdef MAKE_WITH_I18N #include #include #endif /* Now the external functions, using the above... */ #include "globals-core.h" /* ************************************************************************************** * * #define value tests * * put 'em here so people aren't tempted to override them... * * **************************************************************************************/ #if DEFAULT_SNAPLEN > MAX_PACKET_LEN #error DEFAULT_SNAPLEN > MAX_PACKET_LEN #endif /* XML dump plugin... * Check if we have the required headers... * otherwise all the code becomes nops */ #undef MAKE_WITH_XMLDUMP #if defined(HAVE_GLIBCONFIG_H) && \ defined(HAVE_GLIB_H) && \ defined(HAVE_GDOME_H) && \ defined(CONST_XMLDUMP_PLUGIN_NAME) #define MAKE_WITH_XMLDUMP #endif /* *************************************************************** */ /* Declaration of POSIX directory browsing functions and types for Win32. Kevlin Henney (mailto:kevlin@acm.org), March 1997. Copyright Kevlin Henney, 1997. All rights reserved. Permission to use, copy, modify, and distribute this software and its documentation for any purpose is hereby granted without fee, provided that this copyright and permissions notice appear in all copies and derivatives, and that no charge may be made for the software and its documentation except to cover cost of distribution. */ #if defined(WIN32) && defined(__GNUC__) #ifndef DIRENT_INCLUDED #define DIRENT_INCLUDED #include DIR *opendir(const char *); int closedir(DIR *); struct dirent *readdir(DIR *); void rewinddir(DIR *); #endif #endif /* WIN32 */ /* *************************************************************** */ #define HAVE_RRD #include "iface.h" #endif /* NTOP_H */