Merge pull request #737 from themadprofessor/dev
Add compiler warnings and fix them
This commit is contained in:
@@ -9,6 +9,8 @@ LT_INIT
|
|||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
AC_PROG_CC_STDC
|
||||||
|
AC_LANG_WERROR
|
||||||
AX_PTHREAD
|
AX_PTHREAD
|
||||||
|
|
||||||
NDPI_VERSION_SHORT="@NDPI_VERSION_SHORT@"
|
NDPI_VERSION_SHORT="@NDPI_VERSION_SHORT@"
|
||||||
|
|||||||
@@ -2852,7 +2852,7 @@ void bpf_filter_pkt_peak_filter(json_object **jObj_bpfFilter,
|
|||||||
int l;
|
int l;
|
||||||
|
|
||||||
if(port_array[0] != INIT_VAL)
|
if(port_array[0] != INIT_VAL)
|
||||||
strncat(filter, " and not (src ", sizeof(" and not (src "));
|
strncat(filter, " and not (src ", sizeof(filter)/sizeof(char));
|
||||||
else
|
else
|
||||||
strcpy(filter, "not (src ");
|
strcpy(filter, "not (src ");
|
||||||
|
|
||||||
@@ -2879,7 +2879,7 @@ void bpf_filter_pkt_peak_filter(json_object **jObj_bpfFilter,
|
|||||||
int l;
|
int l;
|
||||||
|
|
||||||
if(port_array[0] != INIT_VAL || src_host_array[0] != NULL)
|
if(port_array[0] != INIT_VAL || src_host_array[0] != NULL)
|
||||||
strncat(filter, " and not (dst ", sizeof(" and not (dst "));
|
strncat(filter, " and not (dst ", sizeof(filter)/sizeof(char));
|
||||||
else
|
else
|
||||||
strcpy(filter, "not (dst ");
|
strcpy(filter, "not (dst ");
|
||||||
|
|
||||||
@@ -3026,7 +3026,6 @@ void bpf_filter_port_array_add(int filter_array[], int size, int port) {
|
|||||||
float getAverage(struct json_object *jObj_stat, char *field){
|
float getAverage(struct json_object *jObj_stat, char *field){
|
||||||
json_object *field_stat;
|
json_object *field_stat;
|
||||||
json_bool res;
|
json_bool res;
|
||||||
float average;
|
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
int r;
|
int r;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
@@ -3074,11 +3073,11 @@ float getStdDeviation(struct json_object *jObj_stat, float average, char *field)
|
|||||||
json_object *field_stat;
|
json_object *field_stat;
|
||||||
json_bool res;
|
json_bool res;
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
int j;
|
int j = 0;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if((r = strcmp(field, "top.scanner.stats")) == 0){
|
if((r = strcmp(field, "top.scanner.stats")) == 0){
|
||||||
for(j=0; j<json_object_array_length(jObj_stat); j++) {
|
for(; j<json_object_array_length(jObj_stat); j++) {
|
||||||
field_stat = json_object_array_get_idx(jObj_stat, j);
|
field_stat = json_object_array_get_idx(jObj_stat, j);
|
||||||
json_object *jObj_tot_flows_number;
|
json_object *jObj_tot_flows_number;
|
||||||
|
|
||||||
@@ -3263,7 +3262,6 @@ static void produceBpfFilter(char *filePath) {
|
|||||||
const char *filterPktDstHosts[48];
|
const char *filterPktDstHosts[48];
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char *fileName;
|
|
||||||
char _filterFilePath[1024];
|
char _filterFilePath[1024];
|
||||||
json_object *jObj_bpfFilter;
|
json_object *jObj_bpfFilter;
|
||||||
void *fmap;
|
void *fmap;
|
||||||
@@ -3359,7 +3357,6 @@ static void produceBpfFilter(char *filePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fileName = basename(filePath);
|
|
||||||
snprintf(_filterFilePath, sizeof(_filterFilePath), "%s.bpf", filePath);
|
snprintf(_filterFilePath, sizeof(_filterFilePath), "%s.bpf", filePath);
|
||||||
|
|
||||||
if((fp = fopen(_filterFilePath,"w")) == NULL) {
|
if((fp = fopen(_filterFilePath,"w")) == NULL) {
|
||||||
|
|||||||
+1
-1
@@ -732,7 +732,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
|
|||||||
u_int16_t ip_offset = 0, ip_len;
|
u_int16_t ip_offset = 0, ip_len;
|
||||||
u_int16_t frag_off = 0, vlan_id = 0;
|
u_int16_t frag_off = 0, vlan_id = 0;
|
||||||
u_int8_t proto = 0;
|
u_int8_t proto = 0;
|
||||||
u_int32_t label;
|
/*u_int32_t label;*/
|
||||||
|
|
||||||
/* counters */
|
/* counters */
|
||||||
u_int8_t vlan_packet = 0;
|
u_int8_t vlan_packet = 0;
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ prefix = @prefix@
|
|||||||
libdir = ${prefix}/lib
|
libdir = ${prefix}/lib
|
||||||
includedir = ${prefix}/include/ndpi
|
includedir = ${prefix}/include/ndpi
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g
|
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g -Wall -Werror
|
||||||
RANLIB = ranlib
|
RANLIB = ranlib
|
||||||
|
|
||||||
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) ndpi_main.o ndpi_utils.o
|
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) ndpi_main.o ndpi_utils.o
|
||||||
|
|||||||
+1
-10
@@ -491,7 +491,6 @@ void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_mod,
|
|||||||
ndpi_protocol_match *match) {
|
ndpi_protocol_match *match) {
|
||||||
u_int16_t no_master[2] = { NDPI_PROTOCOL_NO_MASTER_PROTO, NDPI_PROTOCOL_NO_MASTER_PROTO };
|
u_int16_t no_master[2] = { NDPI_PROTOCOL_NO_MASTER_PROTO, NDPI_PROTOCOL_NO_MASTER_PROTO };
|
||||||
ndpi_port_range ports_a[MAX_DEFAULT_PORTS], ports_b[MAX_DEFAULT_PORTS];
|
ndpi_port_range ports_a[MAX_DEFAULT_PORTS], ports_b[MAX_DEFAULT_PORTS];
|
||||||
static u_int16_t generic_id = NDPI_LAST_IMPLEMENTED_PROTOCOL;
|
|
||||||
|
|
||||||
if(ndpi_mod->proto_defaults[match->protocol_id].protoName == NULL) {
|
if(ndpi_mod->proto_defaults[match->protocol_id].protoName == NULL) {
|
||||||
if(match->protocol_id == NDPI_PROTOCOL_GENERIC)
|
if(match->protocol_id == NDPI_PROTOCOL_GENERIC)
|
||||||
@@ -5862,7 +5861,6 @@ int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_stru
|
|||||||
AC_TEXT_t ac_input_text;
|
AC_TEXT_t ac_input_text;
|
||||||
ndpi_automa *automa = is_host_match ? &ndpi_struct->host_automa : &ndpi_struct->content_automa;
|
ndpi_automa *automa = is_host_match ? &ndpi_struct->host_automa : &ndpi_struct->content_automa;
|
||||||
AC_REP_t match = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_UNRATED };
|
AC_REP_t match = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_UNRATED };
|
||||||
int rc;
|
|
||||||
|
|
||||||
if((automa->ac_automa == NULL) || (string_to_match_len == 0))
|
if((automa->ac_automa == NULL) || (string_to_match_len == 0))
|
||||||
return(NDPI_PROTOCOL_UNKNOWN);
|
return(NDPI_PROTOCOL_UNKNOWN);
|
||||||
@@ -5873,22 +5871,15 @@ int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_stru
|
|||||||
}
|
}
|
||||||
|
|
||||||
ac_input_text.astring = string_to_match, ac_input_text.length = string_to_match_len;
|
ac_input_text.astring = string_to_match, ac_input_text.length = string_to_match_len;
|
||||||
rc = ac_automata_search(((AC_AUTOMATA_t*)automa->ac_automa), &ac_input_text, &match);
|
ac_automata_search(((AC_AUTOMATA_t*)automa->ac_automa), &ac_input_text, &match);
|
||||||
ac_automata_reset(((AC_AUTOMATA_t*)automa->ac_automa));
|
ac_automata_reset(((AC_AUTOMATA_t*)automa->ac_automa));
|
||||||
|
|
||||||
/* We need to take into account also rc==0 that is used for partial matches */
|
/* We need to take into account also rc==0 that is used for partial matches */
|
||||||
#if 0
|
|
||||||
if(rc) {
|
|
||||||
#endif
|
|
||||||
ret_match->protocol_id = match.number,
|
ret_match->protocol_id = match.number,
|
||||||
ret_match->protocol_category = match.category,
|
ret_match->protocol_category = match.category,
|
||||||
ret_match->protocol_breed = match.breed;
|
ret_match->protocol_breed = match.breed;
|
||||||
|
|
||||||
return(match.number);
|
return(match.number);
|
||||||
#if 0
|
|
||||||
} else
|
|
||||||
return(NDPI_PROTOCOL_UNKNOWN);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_HYPERSCAN
|
#ifdef HAVE_HYPERSCAN
|
||||||
|
|||||||
@@ -50,8 +50,6 @@
|
|||||||
|
|
||||||
#define NDPI_CONST_GENERIC_PROTOCOL_NAME "GenericProtocol"
|
#define NDPI_CONST_GENERIC_PROTOCOL_NAME "GenericProtocol"
|
||||||
|
|
||||||
static int _ndpi_debug_callbacks = 0;
|
|
||||||
|
|
||||||
// #define MATCH_DEBUG 1
|
// #define MATCH_DEBUG 1
|
||||||
|
|
||||||
/* implementation of the punycode check function */
|
/* implementation of the punycode check function */
|
||||||
|
|||||||
@@ -46,55 +46,6 @@ typedef unsigned long long int u_int64_t;
|
|||||||
|
|
||||||
int bt_parse_debug = 0;
|
int bt_parse_debug = 0;
|
||||||
|
|
||||||
static char *printXb(char *s,const u_int8_t *b,int l) {
|
|
||||||
int i;
|
|
||||||
for(i=0; i < l; i++)
|
|
||||||
snprintf(&s[i*2],41,"%02x",b[i]);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print20b(char *s,const u_int8_t *b) {
|
|
||||||
snprintf(s,41,"%08x%08x%08x%08x%08x",
|
|
||||||
htonl(*(u_int32_t*)b),
|
|
||||||
htonl(*(u_int32_t*)(b+4)),
|
|
||||||
htonl(*(u_int32_t*)(b+8)),
|
|
||||||
htonl(*(u_int32_t*)(b+12)),
|
|
||||||
htonl(*(u_int32_t*)(b+16)));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print_id_ip_p(char *s, const struct bt_nodes_data *b) {
|
|
||||||
u_int8_t *p = (u_int8_t*)b;
|
|
||||||
|
|
||||||
print20b(s,b->id);
|
|
||||||
snprintf(s+40,39," %d.%d.%d.%d:%u",
|
|
||||||
p[20], p[21], p[22], p[23], htons(b->port));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print_ip_p(char *s, const struct bt_ipv4p *b,int np) {
|
|
||||||
const u_int8_t *p = (const u_int8_t*)b;
|
|
||||||
|
|
||||||
snprintf(s,39,!np ? "%d.%d.%d.%d:%u":"%d.%d.%d.%d",
|
|
||||||
p[0], p[1], p[2], p[3], htons(b->port));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print_ip6_p(char *s, const struct bt_ipv6p *b,int np) {
|
|
||||||
u_int16_t *p = (u_int16_t*)b;
|
|
||||||
|
|
||||||
snprintf(s,79,!np ? "%x:%x:%x:%x:%x:%x:%x:%x.%u":"%x:%x:%x:%x:%x:%x:%x:%x",
|
|
||||||
htons(p[0]), htons(p[1]), htons(p[2]), htons(p[3]),
|
|
||||||
htons(p[4]), htons(p[5]), htons(p[6]), htons(p[7]),
|
|
||||||
htons(b->port));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print_id_ip6_p(char *s,const struct bt_nodes6_data *b) {
|
|
||||||
return print_ip6_p(s,(struct bt_ipv6p *)&b->ip,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void dump_bt_proto_struct(struct bt_parse_protocol *p) {
|
void dump_bt_proto_struct(struct bt_parse_protocol *p) {
|
||||||
char b20h[128];
|
char b20h[128];
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
|
|||||||
struct ndpi_flow_struct *flow) {
|
struct ndpi_flow_struct *flow) {
|
||||||
|
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
u_int8_t a;
|
|
||||||
|
|
||||||
if((!ndpi_struct->http_dont_dissect_response) && flow->http_detected && (flow->http.response_status_code != 0)) {
|
if((!ndpi_struct->http_dont_dissect_response) && flow->http_detected && (flow->http.response_status_code != 0)) {
|
||||||
ndpi_set_detected_protocol(ndpi_struct, flow, flow->http_upper_protocol, flow->http_lower_protocol);
|
ndpi_set_detected_protocol(ndpi_struct, flow, flow->http_upper_protocol, flow->http_lower_protocol);
|
||||||
@@ -425,10 +424,6 @@ static struct l_string {
|
|||||||
STATIC_STRING_L("REPORT ") };
|
STATIC_STRING_L("REPORT ") };
|
||||||
static const char *http_fs = "CDGHOPR";
|
static const char *http_fs = "CDGHOPR";
|
||||||
|
|
||||||
static uint8_t non_ctrl(uint8_t c) {
|
|
||||||
return c < 32 ? '.':c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u_int16_t http_request_url_offset(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
static u_int16_t http_request_url_offset(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
{
|
{
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
void ndpi_search_ookla(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
|
void ndpi_search_ookla(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
|
||||||
struct ndpi_packet_struct* packet = &flow->packet;
|
struct ndpi_packet_struct* packet = &flow->packet;
|
||||||
u_int32_t addr = 0;
|
u_int32_t addr = 0;
|
||||||
void *value;
|
|
||||||
|
|
||||||
NDPI_LOG_DBG(ndpi_struct, "Ookla detection\n");
|
NDPI_LOG_DBG(ndpi_struct, "Ookla detection\n");
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,6 @@
|
|||||||
#define P_PACKET_ID_ARRAY_LEN_OFFSET(hmac_size) (P_HARD_RESET_PACKET_ID_OFFSET(hmac_size) + 8)
|
#define P_PACKET_ID_ARRAY_LEN_OFFSET(hmac_size) (P_HARD_RESET_PACKET_ID_OFFSET(hmac_size) + 8)
|
||||||
#define P_HARD_RESET_CLIENT_MAX_COUNT 5
|
#define P_HARD_RESET_CLIENT_MAX_COUNT 5
|
||||||
|
|
||||||
static void ndpi_int_openvpn_add_connection(struct ndpi_detection_module_struct
|
|
||||||
*ndpi_struct, struct ndpi_flow_struct *flow) {
|
|
||||||
NDPI_LOG_INFO(ndpi_struct, "found memcached\n");
|
|
||||||
ndpi_set_detected_protocol(ndpi_struct, flow,
|
|
||||||
NDPI_PROTOCOL_MEMCACHED, NDPI_PROTOCOL_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
inline
|
inline
|
||||||
|
|||||||
@@ -633,7 +633,7 @@ int getSSLcertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
/* Move to the first extension
|
/* Move to the first extension
|
||||||
Type is u_int to avoid possible overflow on extension_len addition */
|
Type is u_int to avoid possible overflow on extension_len addition */
|
||||||
u_int extension_offset = 0;
|
u_int extension_offset = 0;
|
||||||
u_int32_t md5h[4], j;
|
u_int32_t j;
|
||||||
|
|
||||||
while(extension_offset < extensions_len) {
|
while(extension_offset < extensions_len) {
|
||||||
u_int16_t extension_id, extension_len, extn_off = offset+extension_offset;
|
u_int16_t extension_id, extension_len, extn_off = offset+extension_offset;
|
||||||
@@ -833,7 +833,6 @@ void getSSLorganization(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
for(i = 9; i < packet->payload_packet_len-4; i++) {
|
for(i = 9; i < packet->payload_packet_len-4; i++) {
|
||||||
/* Organization OID: 2.5.4.10 */
|
/* Organization OID: 2.5.4.10 */
|
||||||
if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x0a)) {
|
if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x0a)) {
|
||||||
u_int8_t type_tag = packet->payload[i+3]; // 0x0c: utf8string / 0x13: printable_string
|
|
||||||
u_int8_t server_len = packet->payload[i+4];
|
u_int8_t server_len = packet->payload[i+4];
|
||||||
|
|
||||||
num_found++;
|
num_found++;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
|||||||
u_int8_t *is_whatsapp) {
|
u_int8_t *is_whatsapp) {
|
||||||
u_int16_t msg_type, msg_len;
|
u_int16_t msg_type, msg_len;
|
||||||
struct stun_packet_header *h = (struct stun_packet_header*)payload;
|
struct stun_packet_header *h = (struct stun_packet_header*)payload;
|
||||||
u_int8_t can_this_be_whatsapp_voice = 1, wa = 0;
|
u_int8_t can_this_be_whatsapp_voice = 1;
|
||||||
|
|
||||||
flow->protos.stun_ssl.stun.num_processed_pkts++;
|
flow->protos.stun_ssl.stun.num_processed_pkts++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user