aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c60
1 files changed, 20 insertions, 40 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 06d0c5013..029f784f2 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -390,7 +390,7 @@ void ndpiCheckHostStringMatch(char *testChar) {
testChar, match.protocol_id, match.protocol_breed,
match.protocol_category,
appBufStr,
- ndpi_get_proto_breed_name( ndpi_str, match.protocol_breed ),
+ ndpi_get_proto_breed_name( match.protocol_breed ),
ndpi_category_get_name( ndpi_str, match.protocol_category));
} else
printf("Match NOT Found for string: %s\n\n", testChar );
@@ -958,27 +958,6 @@ void printCSVHeader() {
fprintf(csv_fp, "\n");
}
-static int parse_two_unsigned_integer(char *param, u_int32_t *num1, u_int32_t *num2)
-{
- char *saveptr, *tmp_str, *num1_str, *num2_str;
-
- tmp_str = ndpi_strdup(param);
- if(tmp_str) {
- num1_str = strtok_r(tmp_str, ":", &saveptr);
- if(num1_str) {
- num2_str = strtok_r(NULL, ":", &saveptr);
- if(num2_str) {
- *num1 = atoi(num1_str);
- *num2 = atoi(num2_str);
- ndpi_free(tmp_str);
- return 0;
- }
- }
- }
- ndpi_free(tmp_str);
- return -1;
-}
-
static int parse_three_strings(char *param, char **s1, char **s2, char **s3)
{
char *saveptr, *tmp_str, *s1_str, *s2_str = NULL, *s3_str;
@@ -1602,8 +1581,7 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa
);
fprintf(csv_fp, "%s,",
- ndpi_protocol2id(ndpi_thread_info[thread_id].workflow->ndpi_struct,
- flow->detected_protocol, buf, sizeof(buf)));
+ ndpi_protocol2id(flow->detected_protocol, buf, sizeof(buf)));
fprintf(csv_fp, "%s,%s,%s,",
ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
@@ -1732,8 +1710,7 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa
fprintf(out, "%s:", ndpi_tunnel2str(flow->tunnel_type));
fprintf(out, "%s/%s][IP: %u/%s]",
- ndpi_protocol2id(ndpi_thread_info[thread_id].workflow->ndpi_struct,
- flow->detected_protocol, buf, sizeof(buf)),
+ ndpi_protocol2id(flow->detected_protocol, buf, sizeof(buf)),
ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
flow->detected_protocol, buf1, sizeof(buf1)),
flow->detected_protocol.protocol_by_ip,
@@ -2072,8 +2049,7 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa
}
}
-static void printFlowSerialized(u_int16_t thread_id,
- struct ndpi_flow_info *flow)
+static void printFlowSerialized(struct ndpi_flow_info *flow)
{
char *json_str = NULL;
u_int32_t json_str_len = 0;
@@ -2208,6 +2184,8 @@ static void node_print_unknown_proto_walker(const void *node,
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)node;
u_int16_t thread_id = *((u_int16_t*)user_data);
+ (void)depth;
+
if((flow->detected_protocol.master_protocol != NDPI_PROTOCOL_UNKNOWN)
|| (flow->detected_protocol.app_protocol != NDPI_PROTOCOL_UNKNOWN))
return;
@@ -2229,6 +2207,8 @@ static void node_print_known_proto_walker(const void *node,
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)node;
u_int16_t thread_id = *((u_int16_t*)user_data);
+ (void)depth;
+
if((flow->detected_protocol.master_protocol == NDPI_PROTOCOL_UNKNOWN)
&& (flow->detected_protocol.app_protocol == NDPI_PROTOCOL_UNKNOWN))
return;
@@ -2249,6 +2229,8 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept
struct ndpi_flow_info *flow = *(struct ndpi_flow_info **) node;
u_int16_t thread_id = *((u_int16_t *) user_data), proto;
+ (void)depth;
+
if(flow == NULL) return;
if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
@@ -2475,15 +2457,6 @@ static int acceptable(u_int32_t num_pkts) {
/* *********************************************** */
-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);
-}
-
-/* *********************************************** */
-
static int receivers_sort_asc(void *_a, void *_b) {
struct receiver *a = (struct receiver *)_a;
struct receiver *b = (struct receiver *)_b;
@@ -2649,6 +2622,8 @@ static void port_stats_walker(const void *node, ndpi_VISIT which, int depth, voi
u_int16_t sport, dport;
char proto[16];
+ (void)depth;
+
sport = ntohs(flow->src_port), dport = ntohs(flow->dst_port);
/* get app level protocol */
@@ -3070,6 +3045,9 @@ void printPortStats(struct port_stats *stats) {
static void node_flow_risk_walker(const void *node, ndpi_VISIT which, int depth, void *user_data) {
struct ndpi_flow_info *f = *(struct ndpi_flow_info**)node;
+ (void)depth;
+ (void)user_data;
+
if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
if(f->risk) {
u_int j;
@@ -3802,7 +3780,7 @@ static void printFlowsStats() {
for(i=0; i<num_flows; i++)
{
- printFlowSerialized(all_flows[i].thread_id, all_flows[i].flow);
+ printFlowSerialized(all_flows[i].flow);
}
}
@@ -4242,7 +4220,7 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
if(breed_stats_pkts[i] > 0) {
printf("\t%-20s packets: %-13llu bytes: %-13llu "
"flows: %-13llu\n",
- ndpi_get_proto_breed_name(ndpi_thread_info[0].workflow->ndpi_struct, i),
+ ndpi_get_proto_breed_name(i),
breed_stats_pkts[i], breed_stats_bytes[i], breed_stats_flows[i]);
}
}
@@ -4252,7 +4230,7 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
for(i=0; i < NUM_BREEDS; i++) {
if(breed_stats_pkts[i] > 0) {
fprintf(results_file, "%-20s %13llu %-13llu %-13llu\n",
- ndpi_get_proto_breed_name(ndpi_thread_info[0].workflow->ndpi_struct, i),
+ ndpi_get_proto_breed_name(i),
breed_stats_pkts[i], breed_stats_bytes[i], breed_stats_flows[i]);
}
}
@@ -4322,6 +4300,8 @@ void sigproc(int sig) {
static int called = 0;
int thread_id;
+ (void)sig;
+
if(called) return; else called = 1;
shutdown_app = 1;