diff options
author | Campus <campus@ntop.org> | 2015-11-30 12:37:15 +0100 |
---|---|---|
committer | Campus <campus@ntop.org> | 2015-11-30 12:37:15 +0100 |
commit | 587f156557c67a8dd4e025d7ce08b154cbb1132d (patch) | |
tree | 2cf3eeb8de5ae09d809215e577443d42f6b64a0e /src/include | |
parent | f04c3c6acb59de55741b112dfcdd19cc9379db9d (diff) |
reorganized header files - added ndpi_includes.h
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 4 | ||||
-rw-r--r-- | src/include/ndpi_api.h | 7 | ||||
-rw-r--r-- | src/include/ndpi_define.h | 4 | ||||
-rw-r--r-- | src/include/ndpi_includes.h | 68 | ||||
-rw-r--r-- | src/include/ndpi_main.h | 39 | ||||
-rw-r--r-- | src/include/ndpi_protocol_ids.h | 2 | ||||
-rw-r--r-- | src/include/ndpi_protocols.h | 6 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 21 | ||||
-rw-r--r-- | src/include/ndpi_win32.h | 36 |
9 files changed, 105 insertions, 82 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 05266a106..cd901f58b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -5,4 +5,6 @@ library_include_HEADERS = ndpi_api.h \ ndpi_typedefs.h \ ndpi_main.h \ ndpi_protocol_ids.h \ - ndpi_protocols.h + ndpi_protocols.h \ + ndpi_win32.h \ + ndpi_includes.h diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h index f62b1222b..c788dcb29 100644 --- a/src/include/ndpi_api.h +++ b/src/include/ndpi_api.h @@ -23,8 +23,8 @@ */ -#ifndef __NDPI_PUBLIC_FUNCTIONS_H__ -#define __NDPI_PUBLIC_FUNCTIONS_H__ +#ifndef __NDPI_API_H__ +#define __NDPI_API_H__ #include "ndpi_main.h" @@ -236,4 +236,5 @@ extern "C" { #ifdef __cplusplus } #endif -#endif + +#endif /* __NDPI_API_H__ */ diff --git a/src/include/ndpi_define.h b/src/include/ndpi_define.h index 1a135732c..a2880fb15 100644 --- a/src/include/ndpi_define.h +++ b/src/include/ndpi_define.h @@ -194,7 +194,7 @@ #else /* NDPI_ENABLE_DEBUG_MESSAGES */ -#if defined(WIN32) +#ifdef WIN32 #define NDPI_LOG(...) {} #else #define NDPI_LOG(proto, mod, log_level, args...) {} @@ -236,7 +236,7 @@ #define NDPI_BITMASK_SET(a, b) { memcpy(&a, &b, sizeof(NDPI_PROTOCOL_BITMASK)); } /* this is a very very tricky macro *g*, - * the compiler will remove all shifts here if the protocol is static... + * the compiler will remove all shifts here if the protocol is static... */ #define NDPI_ADD_PROTOCOL_TO_BITMASK(bmask,value) NDPI_SET(&bmask,value) #define NDPI_DEL_PROTOCOL_FROM_BITMASK(bmask,value) NDPI_CLR(&bmask,value) diff --git a/src/include/ndpi_includes.h b/src/include/ndpi_includes.h new file mode 100644 index 000000000..57284d808 --- /dev/null +++ b/src/include/ndpi_includes.h @@ -0,0 +1,68 @@ +/* + * ndpi_includes.h + * + * Copyright (C) 2011-15 - ntop.org + * + * This file is part of nDPI, an open source deep packet inspection + * library based on the OpenDPI and PACE technology by ipoque GmbH + * + * nDPI is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * nDPI 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with nDPI. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __NDPI_INCLUDES_H__ +#define __NDPI_INCLUDES_H__ + +#include <stdint.h> +#include <stdio.h> +#include <stdarg.h> +#include <string.h> +#include <ctype.h> +#include <time.h> +#include <sys/param.h> +#include <limits.h> + +#ifdef WIN32 +#include "ndpi_win32.h" +#else +#include <pthread.h> +#include <arpa/inet.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/tcp.h> +#include <netinet/udp.h> + +#if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__ +#include <endian.h> +#include <byteswap.h> + +#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ +#include <netinet/in.h> + +#if defined __NetBSD__ || defined __OpenBSD__ +#include <netinet/in_systm.h> + +#ifdef __OpenBSD__ +#include <pthread.h> + +#endif +#endif +#endif +#endif + +#endif /* Win32 */ + +#endif /* __NDPI_INCLUDES_H__ */ diff --git a/src/include/ndpi_main.h b/src/include/ndpi_main.h index d5c15c7e4..a70f35c8d 100644 --- a/src/include/ndpi_main.h +++ b/src/include/ndpi_main.h @@ -22,41 +22,10 @@ * */ -#ifndef __NDPI_MAIN_INCLUDE_FILE__ -#define __NDPI_MAIN_INCLUDE_FILE__ - -#include <stdint.h> -#include <stdio.h> -#include <stdarg.h> -#include <string.h> -#ifndef WIN32 -#include <pthread.h> -#endif -#include <ctype.h> -#include <time.h> - - -#ifdef WIN32 -#include <winsock2.h> -#include <ws2tcpip.h> -#else -#include <arpa/inet.h> -#include <sys/time.h> -#include <sys/socket.h> -#if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__ -#include <endian.h> -#include <byteswap.h> -#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ -#include <netinet/in.h> -#endif -#endif - -/* default includes */ - -#include <sys/param.h> -#include <limits.h> -#endif +#ifndef __NDPI_MAIN_H__ +#define __NDPI_MAIN_H__ +#include "ndpi_includes.h" #include "ndpi_define.h" #include "ndpi_protocol_ids.h" #include "ndpi_typedefs.h" @@ -138,4 +107,4 @@ void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct * const char **file, const char **func, u_int32_t * line); #endif -#endif /* __NDPI_MAIN_INCLUDE_FILE__ */ +#endif /* __NDPI_MAIN_H__ */ diff --git a/src/include/ndpi_protocol_ids.h b/src/include/ndpi_protocol_ids.h index 9bccf743b..2bfa42d68 100644 --- a/src/include/ndpi_protocol_ids.h +++ b/src/include/ndpi_protocol_ids.h @@ -23,7 +23,7 @@ */ -#ifndef __NDPI_API_INCLUDE_FILE__ +#ifndef __NDPI_API_H__ #endif diff --git a/src/include/ndpi_protocols.h b/src/include/ndpi_protocols.h index 963aac6f2..240f7b42e 100644 --- a/src/include/ndpi_protocols.h +++ b/src/include/ndpi_protocols.h @@ -23,8 +23,8 @@ */ -#ifndef __NDPI_PROTOCOLS_INCLUDE_FILE__ -#define __NDPI_PROTOCOLS_INCLUDE_FILE__ +#ifndef __NDPI_PROTOCOLS_H__ +#define __NDPI_PROTOCOLS_H__ #include "ndpi_main.h" @@ -337,4 +337,4 @@ void init_zmq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3 void init_stracraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ubntac2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); -#endif /* __NDPI_PROTOCOLS_INCLUDE_FILE__ */ +#endif /* __NDPI_PROTOCOLS_H__ */ diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 5ce848841..d73768f52 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -28,7 +28,6 @@ #include "ndpi_define.h" #define BT_ANNOUNCE -#define _WS2TCPIP_H_ /* Avoid compilation problems */ #define SNAP_EXT @@ -56,18 +55,6 @@ typedef struct node_t struct node_t *left, *right; } ndpi_node; -#ifdef WIN32 -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int uint; -typedef unsigned long u_long; -typedef u_char u_int8_t; -typedef u_short u_int16_t; -typedef uint u_int32_t; -typedef uint u_int; -typedef unsigned __int64 u_int64_t; -#endif - /* NDPI_MASK_SIZE */ typedef u_int32_t ndpi_ndpi_mask; @@ -585,7 +572,7 @@ struct ndpi_flow_tcp_struct { u_char prev_zmq_pkt[10]; #endif } -#if !defined(WIN32) +#ifndef WIN32 __attribute__ ((__packed__)) #endif ; @@ -634,7 +621,7 @@ struct ndpi_flow_udp_struct { u_int32_t eaq_sequence; #endif } -#if !defined(WIN32) +#ifndef WIN32 __attribute__ ((__packed__)) #endif ; @@ -663,7 +650,7 @@ typedef struct ndpi_packet_struct { u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_HISTORY_SIZE]; -#if !defined(WIN32) +#ifndef WIN32 __attribute__ ((__packed__)) #endif u_int16_t protocol_stack_info; @@ -861,7 +848,7 @@ typedef struct ndpi_detection_module_struct { typedef struct ndpi_flow_struct { u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE]; -#if !defined(WIN32) +#ifndef WIN32 __attribute__ ((__packed__)) #endif u_int16_t protocol_stack_info; diff --git a/src/include/ndpi_win32.h b/src/include/ndpi_win32.h index f653caa51..645c022e5 100644 --- a/src/include/ndpi_win32.h +++ b/src/include/ndpi_win32.h @@ -22,36 +22,34 @@ * */ -#ifndef __NDPI_WIN32_INCLUDE_FILE__ -#define __NDPI_WIN32_INCLUDE_FILE__ +#ifndef __NDPI_WIN32_H__ +#define __NDPI_WIN32_H__ -#ifdef WIN32 -#include <Winsock2.h> /* winsock.h is included automatically */ +#include <winsock2.h> +#include <ws2tcpip.h> #include <process.h> #include <io.h> -#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */ -#include <process.h> /* for getpid() and the exec..() family */ +#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */ +#include <process.h> /* for getpid() and the exec..() family */ +#include <stdint.h> #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif -#define snprintf _snprintf -extern char* strsep(char **stringp, const char *delim); +#define _WS2TCPIP_H_ /* Avoid compilation problems */ + +extern char* strsep(char **sp, const char *sep); -#define __attribute__(x) -#include <stdint.h> -#ifndef __GNUC__ typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int uint; typedef unsigned long u_long; -#endif -typedef u_char u_int8_t; -typedef u_short u_int16_t; -typedef unsigned int u_int32_t; -typedef unsigned __int64 u_int64_t; - +typedef u_char u_int8_t; +typedef u_short u_int16_t; +typedef uint u_int32_t; +typedef uint u_int; +typedef unsigned __int64 u_int64_t; #define pthread_t HANDLE #define pthread_mutex_t HANDLE @@ -68,6 +66,4 @@ extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */); #define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */) -#endif /* Win32 */ - -#endif /* __NDPI_WIN32_INCLUDE_FILE__ */ +#endif /* __NDPI_WIN32_H__ */ |