/* ** Copyright (C) 2001-2007 by Carnegie Mellon University. ** ** @OPENSOURCE_HEADER_START@ ** ** Use of the SILK system and related source code is subject to the terms ** of the following licenses: ** ** GNU Public License (GPL) Rights pursuant to Version 2, June 1991 ** Government Purpose License Rights (GPLR) pursuant to DFARS 252.225-7013 ** ** NO WARRANTY ** ** ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER ** PROPERTY OR RIGHTS GRANTED OR PROVIDED BY CARNEGIE MELLON UNIVERSITY ** PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN ** "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY ** KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING, BUT NOT ** LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, ** MERCHANTABILITY, INFORMATIONAL CONTENT, NONINFRINGEMENT, OR ERROR-FREE ** OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT, ** SPECIAL OR CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY ** TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE, REGARDLESS OF ** WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. ** LICENSEE AGREES THAT IT WILL NOT MAKE ANY WARRANTY ON BEHALF OF ** CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON ** CONCERNING THE APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE ** DELIVERABLES UNDER THIS LICENSE. ** ** Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie ** Mellon University, its trustees, officers, employees, and agents from ** all claims or demands made against them (and any related losses, ** expenses, or attorney's fees) arising out of, or relating to Licensee's ** and/or its sub licensees' negligent use or willful misuse of or ** negligent conduct or willful misconduct regarding the Software, ** facilities, or other rights or assistance granted by Carnegie Mellon ** University under this License, including, but not limited to, any ** claims of product liability, personal injury, death, damage to ** property, or violation of any laws or regulations. ** ** Carnegie Mellon University Software Engineering Institute authored ** documents are sponsored by the U.S. Department of Defense under ** Contract F19628-00-C-0003. Carnegie Mellon University retains ** copyrights in all material produced under this contract. The U.S. ** Government retains a non-exclusive, royalty-free license to publish or ** reproduce these documents, or allow others to do so, for U.S. ** Government purposes only pursuant to the copyright license under the ** contract clause at 252.227.7013. ** ** @OPENSOURCE_HEADER_END@ */ #ifndef _SILK_H #define _SILK_H /* Wrap UNUSED() around unused parameters to silence gcc -W */ #ifdef __GNUC__ #define UNUSED(var) /*@unused@*/ var __attribute__((__unused__)) #else #define UNUSED(var) /*@unused@*/ var #endif /* * Create a variable for magic RCS variables: Define 'var' to be the * string in 'id'. Can be used in header, keep 'var's unique. Use: * RCSIDENTVAR(myheader, "$Magic RCS Var$"); */ #define RCSIDENTVAR(var, id) \ static const char /*@observer@*/ UNUSED(* var) = (id) /* Our first pass at autoconfiscation */ #include "silk_config.h" #ifdef HAVE_COMP_ATTRIBUTE_USED /* * Modify RCSIDENTVAR() to mark the variables as "used" so GCC * doesn't strip them. We need this AFTER silk_config.h, but * silk_config.h uses RCSIDENTVAR, so we need to define some version * of RCSIDENTVAR before. */ #undef RCSIDENTVAR #define RCSIDENTVAR(var, id) \ static const char /*@observer@*/ /*@unused@*/ * var __attribute__((__used__)) = (id) #endif /* * As above, except for C files since 'var' can be fixed. */ #define RCSIDENT(id) RCSIDENTVAR(_rcsID, (id)) RCSIDENTVAR(rcsID_SILK_H, "$SiLK: silk.h 7388 2007-06-05 21:29:52Z mthomas $"); #ifdef SK_NEED_REENTRANT # ifndef _REENTRANT # define _REENTRANT 1 # endif #endif #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif # if HAVE_MALLOC_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif #if HAVE_ASSERT_H # include #endif #if HAVE_CTYPE_H # include #endif #if HAVE_ERRNO_H # include #endif #if HAVE_FCNTL_H # include #endif #if HAVE_LIMITS_H # include #endif #if HAVE_MATH_H # include #endif #if HAVE_NETDB_H # include #endif #if HAVE_PTHREAD_H # include #endif #if HAVE_REGEX_H # include #endif #if HAVE_SIGNAL_H # include #endif #if HAVE_STDARG_H # include #endif #if HAVE_SYS_SELECT_H # include #endif #if HAVE_SYS_SOCKET_H # include #endif #if HAVE_NETINET_IN_H # include #endif #if HAVE_NETINET_TCP_H # include #endif #if HAVE_ARPA_INET_H # include #endif #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #if HAVE_DIRENT_H # include #else # define dirent direct # if HAVE_SYS_NDIR_H # include # endif # if HAVE_SYS_DIR_H # include # endif # if HAVE_NDIR_H # include # endif #endif #if HAVE_SYS_MMAN_H # include #endif #if HAVE_SYS_RESOURCE_H # include #endif #if HAVE_SYS_WAIT_H # include #endif #if HAVE_SYS_UIO_H # include #endif /* Maxima */ #if !HAVE_DECL_INT8_MAX # define INT8_MAX 127 #endif #if !HAVE_DECL_UINT8_MAX # define UINT8_MAX 255U #endif #if !HAVE_DECL_INT16_MAX # define INT16_MAX 32767 #endif #if !HAVE_DECL_UINT16_MAX # define UINT16_MAX 65535U #endif #if !HAVE_DECL_INT32_MAX # define INT32_MAX 2147483647 #endif #if !HAVE_DECL_UINT32_MAX # define UINT32_MAX 4294967295U #endif #if !HAVE_DECL_INT64_MAX # if (SIZEOF_UNSIGNED_LONG_LONG >= 8) # define INT64_MAX 9223372036854775807LL # else # if (SIZEOF_LONG >= 8) # define INT64_MAX 9223372036854775807L # endif # endif #endif #if !HAVE_DECL_UINT64_MAX # if (SIZEOF_UNSIGNED_LONG_LONG >= 8) # define UINT64_MAX 18446744073709551615ULL # else # if (SIZEOF_LONG >= 8) # define UINT64_MAX 18446744073709551615UL # endif # endif #endif #if !HAVE_DECL_ULLONG_MAX # if (SIZEOF_UNSIGNED_LONG_LONG == 8) # define ULLONG_MAX UINT64_MAX # endif #endif /* PRI* macros for printing */ #if !HAVE_DECL_PRIU32 /* Assume we either get them all or get none of them. */ # define PRId32 "d" # define PRIi32 "i" # define PRIo32 "o" # define PRIu32 "u" # define PRIx32 "x" # define PRIX32 "X" # define PRId16 PRId32 # define PRIi16 PRIi32 # define PRIo16 PRIo32 # define PRIu16 PRIu32 # define PRIx16 PRIx32 # define PRIX16 PRIX32 # define PRId8 PRId32 # define PRIi8 PRIi32 # define PRIo8 PRIo32 # define PRIu8 PRIu32 # define PRIx8 PRIx32 # define PRIX8 PRIX32 #endif /* !HAVE_DECL_PRIU32 */ #if !HAVE_DECL_PRIU64 # if (SIZEOF_LONG >= 8) # define PRId64 "l" PRId32 # define PRIi64 "l" PRIi32 # define PRIo64 "l" PRIo32 # define PRIu64 "l" PRIu32 # define PRIx64 "l" PRIx32 # define PRIX64 "l" PRIX32 # else # define PRId64 "ll" PRId32 # define PRIi64 "ll" PRIi32 # define PRIo64 "ll" PRIo32 # define PRIu64 "ll" PRIu32 # define PRIx64 "ll" PRIx32 # define PRIX64 "ll" PRIX32 # endif #endif /* !HAVE_DECL_PRIU64 */ #ifndef HAVE_INTMAX_T typedef int64_t intmax_t; #endif #ifndef HAVE_IMAXDIV_T typedef struct { intmax_t quot; /* Quotient */ intmax_t rem; /* Remainder */ } imaxdiv_t; #endif /* Endian macros */ #ifndef WORDS_BIGENDIAN # define IS_LITTLE_ENDIAN 1 # define IS_BIG_ENDIAN 0 #else # define IS_LITTLE_ENDIAN 0 # define IS_BIG_ENDIAN 1 #endif /* Define an enumeration type for endianess */ typedef enum { SILK_ENDIAN_BIG, SILK_ENDIAN_LITTLE, SILK_ENDIAN_NATIVE, SILK_ENDIAN_ANY } silk_endian_t; /* Defines generic file header and supported file types */ #include "silk_files.h" /* Name of environment variable pointing to the root of install */ #define ENV_SILK_PATH "SILK_PATH" /* First look for plugins in these sub-directories of $SILK_PATH; if * that fails, look for plugins in these sub-directories of the * binary's parent directory; if that fails, use platform's default * (LD_LIBRARY_PATH or similar). */ #define SILK_SUBDIR_PLUGINS {"lib/silk", "share/lib", "lib", (char*)NULL} /* Subdirectory of $SILK_PATH for support files */ #define SILK_SUBDIR_SUPPORT "share" /* Define an endianness-aware ip address structure. */ typedef union { #if IS_LITTLE_ENDIAN struct { uint8_t o4; uint8_t o3; uint8_t o2; uint8_t o1; } O; #else struct { uint8_t o1; uint8_t o2; uint8_t o3; uint8_t o4; } O; #endif uint32_t ipnum; } ipUnion; /* Bit-swapping macros for changing endianness */ #define BSWAP16(a) ((( (a) & 0xFF00) >> 8) | (( (a) & 0x00FF) << 8)) #define BSWAP32(a) ((((a) & 0x000000FF) << 24) | (((a) & 0x0000FF00) << 8) \ | (((a) & 0x00FF0000) >> 8) | (((a) >> 24) & 0x000000FF)) #define BSWAP64(a) ((((uint64_t)BSWAP32((uint32_t)((a) & 0xffffffff))) << 32) \ | BSWAP32((uint32_t)((a) >> 32))) /* provide a network-to-host swapper for 64bit values */ #ifdef WORDS_BIGENDIAN # define ntoh64(x) (x) #else # define ntoh64(x) BSWAP64(x) #endif #define hton64(x) ntoh64(x) /* various IP protocols */ #ifndef IPPROTO_ICMP # define IPPROTO_ICMP 1 #endif #ifndef IPPROTO_TCP # define IPPROTO_TCP 6 #endif #ifndef IPPROTO_UDP # define IPPROTO_UDP 17 #endif #include "silk_site.h" #endif /* _SILK_H */ /* ** Local Variables: ** mode:c ** indent-tabs-mode:nil ** c-basic-offset:4 ** End: */