Cleaned up code moving specific includes in files their are using it. Thi prevents ndpi_config.h to be included everywhere in apps using nDPI that might leade to #define redefinitions after the latest changes
This commit is contained in:
@@ -179,11 +179,6 @@
|
|||||||
#define NDPI_JABBER_FT_TIMEOUT 5
|
#define NDPI_JABBER_FT_TIMEOUT 5
|
||||||
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
|
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
|
||||||
|
|
||||||
#ifndef _NDPI_CONFIG_H_
|
|
||||||
#include "ndpi_config.h" /* To have access to NDPI_ENABLE_DEBUG_MESSAGES */
|
|
||||||
#define _NDPI_CONFIG_H_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
#define NDPI_LOG(proto, m, log_level, args...) \
|
#define NDPI_LOG(proto, m, log_level, args...) \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
@@ -31,10 +31,6 @@
|
|||||||
/* Used by both nDPI core and patricia code under third-party */
|
/* Used by both nDPI core and patricia code under third-party */
|
||||||
#include "ndpi_patricia_typedefs.h"
|
#include "ndpi_patricia_typedefs.h"
|
||||||
|
|
||||||
#ifdef HAVE_MAXMINDDB
|
|
||||||
#include <maxminddb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* NDPI_LOG_LEVEL */
|
/* NDPI_LOG_LEVEL */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NDPI_LOG_ERROR,
|
NDPI_LOG_ERROR,
|
||||||
@@ -1034,15 +1030,6 @@ typedef struct ndpi_proto {
|
|||||||
#define _NDPI_CONFIG_H_
|
#define _NDPI_CONFIG_H_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PCRE
|
|
||||||
#include <pcre.h>
|
|
||||||
|
|
||||||
struct pcre_struct {
|
|
||||||
pcre *compiled;
|
|
||||||
pcre_extra *optimized;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ndpi_stun_cache,
|
ndpi_stun_cache,
|
||||||
ndpi_hangout_cache
|
ndpi_hangout_cache
|
||||||
@@ -1171,10 +1158,9 @@ struct ndpi_detection_module_struct {
|
|||||||
#include "../../../nDPI-custom/custom_ndpi_typedefs.h"
|
#include "../../../nDPI-custom/custom_ndpi_typedefs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MAXMINDDB
|
/* GeoIP */
|
||||||
MMDB_s mmdb_city, mmdb_as;
|
void *mmdb_city, *mmdb_as;
|
||||||
u_int8_t mmdb_city_loaded, mmdb_as_loaded;
|
u_int8_t mmdb_city_loaded, mmdb_as_loaded;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Current packet */
|
/* Current packet */
|
||||||
struct ndpi_packet_struct packet;
|
struct ndpi_packet_struct packet;
|
||||||
|
|||||||
+19
-10
@@ -21,10 +21,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "ndpi_config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -33,6 +29,10 @@
|
|||||||
#include "ndpi_api.h"
|
#include "ndpi_api.h"
|
||||||
#include "ndpi_config.h"
|
#include "ndpi_config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_MAXMINDDB
|
||||||
|
#include <maxminddb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ********************************************************************************* */
|
/* ********************************************************************************* */
|
||||||
|
|
||||||
int ndpi_load_geoip(struct ndpi_detection_module_struct *ndpi_str,
|
int ndpi_load_geoip(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
@@ -40,13 +40,19 @@ int ndpi_load_geoip(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
#ifdef HAVE_MAXMINDDB
|
#ifdef HAVE_MAXMINDDB
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
ndpi_str->mmdb_city = (void*)ndpi_malloc(sizeof(MMDB_s));
|
||||||
|
ndpi_str->mmdb_as = (void*)ndpi_malloc(sizeof(MMDB_s));
|
||||||
|
|
||||||
|
if((ndpi_str->mmdb_city == NULL) || (ndpi_str->mmdb_as == NULL))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
/* Open the MMDB files */
|
/* Open the MMDB files */
|
||||||
if((status = MMDB_open(ip_city_data, MMDB_MODE_MMAP, &ndpi_str->mmdb_city)) != MMDB_SUCCESS)
|
if((status = MMDB_open(ip_city_data, MMDB_MODE_MMAP, (MMDB_s*)ndpi_str->mmdb_city)) != MMDB_SUCCESS)
|
||||||
return(-1);
|
return(-1);
|
||||||
else
|
else
|
||||||
ndpi_str->mmdb_city_loaded = 1;
|
ndpi_str->mmdb_city_loaded = 1;
|
||||||
|
|
||||||
if((status = MMDB_open(ip_as_data, MMDB_MODE_MMAP, &ndpi_str->mmdb_as)) != MMDB_SUCCESS)
|
if((status = MMDB_open(ip_as_data, MMDB_MODE_MMAP, (MMDB_s*)ndpi_str->mmdb_as)) != MMDB_SUCCESS)
|
||||||
return(-2);
|
return(-2);
|
||||||
else
|
else
|
||||||
ndpi_str->mmdb_as_loaded = 1;
|
ndpi_str->mmdb_as_loaded = 1;
|
||||||
@@ -61,8 +67,11 @@ int ndpi_load_geoip(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
|
|
||||||
void ndpi_free_geoip(struct ndpi_detection_module_struct *ndpi_str) {
|
void ndpi_free_geoip(struct ndpi_detection_module_struct *ndpi_str) {
|
||||||
#ifdef HAVE_MAXMINDDB
|
#ifdef HAVE_MAXMINDDB
|
||||||
if(ndpi_str->mmdb_city_loaded) MMDB_close(&ndpi_str->mmdb_city);
|
if(ndpi_str->mmdb_city_loaded) MMDB_close((MMDB_s*)ndpi_str->mmdb_city);
|
||||||
if(ndpi_str->mmdb_as_loaded) MMDB_close(&ndpi_str->mmdb_as);
|
if(ndpi_str->mmdb_as_loaded) MMDB_close((MMDB_s*)ndpi_str->mmdb_as);
|
||||||
|
|
||||||
|
ndpi_free(ndpi_str->mmdb_city);
|
||||||
|
ndpi_free(ndpi_str->mmdb_as);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +84,7 @@ int ndpi_get_geoip_asn(struct ndpi_detection_module_struct *ndpi_str, char *ip,
|
|||||||
MMDB_entry_data_s entry_data;
|
MMDB_entry_data_s entry_data;
|
||||||
|
|
||||||
if(ndpi_str->mmdb_as_loaded) {
|
if(ndpi_str->mmdb_as_loaded) {
|
||||||
result = MMDB_lookup_string(&ndpi_str->mmdb_as, ip, &gai_error, &mmdb_error);
|
result = MMDB_lookup_string((MMDB_s*)ndpi_str->mmdb_as, ip, &gai_error, &mmdb_error);
|
||||||
|
|
||||||
if((gai_error != 0)
|
if((gai_error != 0)
|
||||||
|| (mmdb_error != MMDB_SUCCESS)
|
|| (mmdb_error != MMDB_SUCCESS)
|
||||||
@@ -112,7 +121,7 @@ int ndpi_get_geoip_country_continent(struct ndpi_detection_module_struct *ndpi_s
|
|||||||
if(ndpi_str->mmdb_city_loaded) {
|
if(ndpi_str->mmdb_city_loaded) {
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
result = MMDB_lookup_string(&ndpi_str->mmdb_city, ip, &gai_error, &mmdb_error);
|
result = MMDB_lookup_string((MMDB_s*)ndpi_str->mmdb_city, ip, &gai_error, &mmdb_error);
|
||||||
|
|
||||||
if((gai_error != 0)
|
if((gai_error != 0)
|
||||||
|| (mmdb_error != MMDB_SUCCESS)
|
|| (mmdb_error != MMDB_SUCCESS)
|
||||||
|
|||||||
@@ -59,6 +59,15 @@
|
|||||||
|
|
||||||
// #define DEBUG_REASSEMBLY
|
// #define DEBUG_REASSEMBLY
|
||||||
|
|
||||||
|
#ifdef HAVE_PCRE
|
||||||
|
#include <pcre.h>
|
||||||
|
|
||||||
|
struct pcre_struct {
|
||||||
|
pcre *compiled;
|
||||||
|
pcre_extra *optimized;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ****************************************** */
|
/* ****************************************** */
|
||||||
|
|
||||||
/* implementation of the punycode check function */
|
/* implementation of the punycode check function */
|
||||||
|
|||||||
Reference in New Issue
Block a user