aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2020-04-15 18:07:24 +0200
committerNardi Ivan <nardi.ivan@gmail.com>2020-04-20 16:53:39 +0200
commitb1a6c6b8957b62ec8ada423abfdcfa5471c00147 (patch)
tree0d03df67b8fa0647050a74f473985301a027fa79
parente60354996737df132ef4a2a681839e1bf403c296 (diff)
Fix some compilation warnings
-rw-r--r--example/intrusion_detection.c6
-rw-r--r--example/ndpiReader.c4
-rw-r--r--example/reader_util.c4
-rw-r--r--src/include/ndpi_typedefs.h2
-rw-r--r--src/lib/ndpi_content_match.c.inc2
-rw-r--r--src/lib/protocols/rx.c5
-rw-r--r--src/lib/protocols/tls.c6
7 files changed, 17 insertions, 12 deletions
diff --git a/example/intrusion_detection.c b/example/intrusion_detection.c
index 5c83b5b8e..cce25a8b8 100644
--- a/example/intrusion_detection.c
+++ b/example/intrusion_detection.c
@@ -53,7 +53,6 @@ double get_flow_score(ndpi_norm_value* scores, int n_metrics){
/* ********************************** */
double Ddos_score(struct ndpi_flow_info* flow){
- double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_c_to_s_avg */
@@ -105,7 +104,6 @@ double Ddos_score(struct ndpi_flow_info* flow){
}
double Dos_goldeneye_score(struct ndpi_flow_info* flow){
- double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_s_to_c_max */
@@ -208,7 +206,6 @@ double Dos_hulk_score(struct ndpi_flow_info* flow){
}
double Dos_slow_score(struct ndpi_flow_info* flow){
- double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_s_to_c_max */
@@ -260,7 +257,6 @@ double Dos_slow_score(struct ndpi_flow_info* flow){
}
double Ftp_patator_score(struct ndpi_flow_info* flow){
- double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* iat_flow_min */
@@ -364,7 +360,6 @@ double Hearthbleed_score(struct ndpi_flow_info* flow){
}
double Infiltration_score(struct ndpi_flow_info* flow){
- double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_c_to_s_max */
@@ -416,7 +411,6 @@ double Infiltration_score(struct ndpi_flow_info* flow){
}
double Ssh_patator_score(struct ndpi_flow_info* flow){
- double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* fin */
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index d64918b85..f15ee0e66 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -218,6 +218,7 @@ FILE *trace = NULL;
*/
static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle);
+#if 0
static void reduceBDbits(uint32_t *bd, unsigned int len) {
int mask = 0;
int shift = 0;
@@ -238,6 +239,7 @@ static void reduceBDbits(uint32_t *bd, unsigned int len) {
for(i = 0; i < len; i++)
bd[i] = bd[i] >> shift;
}
+#endif
/**
* @brief Get flow byte distribution mean and variance
@@ -1530,12 +1532,14 @@ static int acceptable(u_int32_t num_pkts){
/* *********************************************** */
+#if 0
static int receivers_sort(void *_a, void *_b) {
struct receiver *a = (struct receiver *)_a;
struct receiver *b = (struct receiver *)_b;
return(b->num_pkts - a->num_pkts);
}
+#endif
/* *********************************************** */
diff --git a/example/reader_util.c b/example/reader_util.c
index 73d580cc1..db18496c7 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -1210,7 +1210,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
u_int8_t *payload;
u_int8_t src_to_dst_direction = 1;
u_int8_t begin_or_end_tcp = 0;
- struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
+ struct ndpi_proto nproto = NDPI_PROTOCOL_NULL;
if(iph)
flow = get_ndpi_flow_info(workflow, IPVERSION, vlan_id,
@@ -1441,7 +1441,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
/** --- IPv6 header --- **/
struct ndpi_ipv6hdr *iph6;
- struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
+ struct ndpi_proto nproto = NDPI_PROTOCOL_NULL;
ndpi_packet_tunnel tunnel_type = ndpi_no_tunnel;
/* lengths and offsets */
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h
index 69b6b3641..261a05425 100644
--- a/src/include/ndpi_typedefs.h
+++ b/src/include/ndpi_typedefs.h
@@ -966,7 +966,7 @@ typedef struct ndpi_proto {
ndpi_protocol_category_t category;
} ndpi_protocol;
-#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN }
+#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_CATEGORY_UNSPECIFIED }
#define NUM_CUSTOM_CATEGORIES 5
#define CUSTOM_CATEGORY_LABEL_LEN 32
diff --git a/src/lib/ndpi_content_match.c.inc b/src/lib/ndpi_content_match.c.inc
index 3d207d0bb..410586fb7 100644
--- a/src/lib/ndpi_content_match.c.inc
+++ b/src/lib/ndpi_content_match.c.inc
@@ -9137,7 +9137,7 @@ static ndpi_protocol_match host_match[] = {
{ "brasilbandalarga.com.br", NULL, "brasilbandalarga\\.com" TLD, "EAQ", NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_CATEGORY_NETWORK, NDPI_PROTOCOL_ACCEPTABLE },
{ ".eaqbr.com.br", NULL, "\\.eaqbr\\.com" TLD, "EAQ", NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_CATEGORY_NETWORK, NDPI_PROTOCOL_ACCEPTABLE },
- { NULL, NULL, NULL, 0 }
+ { NULL, NULL, NULL, NULL, NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_SAFE}
};
/* ******************************************************************** */
diff --git a/src/lib/protocols/rx.c b/src/lib/protocols/rx.c
index 64dbe7d0f..3bcab3b85 100644
--- a/src/lib/protocols/rx.c
+++ b/src/lib/protocols/rx.c
@@ -129,19 +129,24 @@ void ndpi_check_rx(struct ndpi_detection_module_struct *ndpi_struct,
header->flags == PLUS_2 || header->flags == REQ_ACK ||
header->flags == MORE_1)
goto security;
+ /* Fall-through */
case ACK:
if(header->flags == CLIENT_INIT_1 || header->flags == CLIENT_INIT_2 ||
header->flags == EMPTY)
goto security;
+ /* Fall-through */
case CHALLENGE:
if(header->flags == EMPTY || header->call_number == 0)
goto security;
+ /* Fall-through */
case RESPONSE:
if(header->flags == EMPTY || header->call_number == 0)
goto security;
+ /* Fall-through */
case ACKALL:
if(header->flags == EMPTY)
goto security;
+ /* Fall-through */
case BUSY:
goto security;
case ABORT:
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c
index 560e483ac..a6d7883ce 100644
--- a/src/lib/protocols/tls.c
+++ b/src/lib/protocols/tls.c
@@ -316,8 +316,10 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
i += 2;
- if((len > sizeof(dNSName)-1) || (len == 0 /* Looks something went wrong */))
- break; /* String too long */
+ /* The check "len > sizeof(dNSName) - 1" will be always false. If we add it,
+ the compiler is smart enough to detect it and throws a warning */
+ if((len == 0 /* Looks something went wrong */))
+ break;
strncpy(dNSName, (const char*)&packet->payload[i], len);
dNSName[len] = '\0';