aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c60
-rw-r--r--example/ndpiSimpleIntegration.c3
-rw-r--r--example/reader_util.c19
3 files changed, 28 insertions, 54 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;
diff --git a/example/ndpiSimpleIntegration.c b/example/ndpiSimpleIntegration.c
index 4517edbdf..dc14928c9 100644
--- a/example/ndpiSimpleIntegration.c
+++ b/example/ndpiSimpleIntegration.c
@@ -900,8 +900,7 @@ static void ndpi_process_packet(uint8_t * const args,
ip != NULL ? (uint8_t *)ip : (uint8_t *)ip6,
ip_size, time_ms, NULL);
- if (ndpi_is_protocol_detected(workflow->ndpi_struct,
- flow_to_process->detected_l7_protocol) != 0 &&
+ if (ndpi_is_protocol_detected(flow_to_process->detected_l7_protocol) != 0 &&
flow_to_process->detection_completed == 0)
{
if (flow_to_process->detected_l7_protocol.master_protocol != NDPI_PROTOCOL_UNKNOWN ||
diff --git a/example/reader_util.c b/example/reader_util.c
index d42b92d25..1afe4418f 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -114,7 +114,6 @@ u_int16_t max_pattern_len = 8;
/* *********************************************************** */
int ndpi_analyze_payload(struct ndpi_flow_info *flow,
- u_int8_t src_to_dst_direction,
u_int8_t *payload,
u_int16_t payload_len,
u_int32_t packet_id) {
@@ -194,7 +193,6 @@ int ndpi_analyze_payload(struct ndpi_flow_info *flow,
/* *********************************************************** */
void ndpi_payload_analyzer(struct ndpi_flow_info *flow,
- u_int8_t src_to_dst_direction,
u_int8_t *payload, u_int16_t payload_len,
u_int32_t packet_id) {
u_int16_t i, j;
@@ -215,7 +213,7 @@ void ndpi_payload_analyzer(struct ndpi_flow_info *flow,
for(i=0; i<scan_len; i++) {
for(j=min_pattern_len; j <= max_pattern_len; j++) {
if((i+j) < payload_len) {
- if(ndpi_analyze_payload(flow, src_to_dst_direction, &payload[i], j, packet_id) == -1) {
+ if(ndpi_analyze_payload(flow, &payload[i], j, packet_id) == -1) {
LOG(NDPI_LOG_ERROR, "Error ndpi_analyze_payload (allocation failure)\n");
}
}
@@ -687,7 +685,6 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
ndpi_packet_tunnel tunnel_type,
const struct ndpi_iphdr *iph,
const struct ndpi_ipv6hdr *iph6,
- u_int16_t ip_offset,
u_int16_t ipsize,
u_int16_t l4_packet_len,
u_int16_t l4_offset,
@@ -973,7 +970,6 @@ static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflo
u_int16_t vlan_id,
ndpi_packet_tunnel tunnel_type,
const struct ndpi_ipv6hdr *iph6,
- u_int16_t ip_offset,
u_int16_t ipsize,
struct ndpi_tcphdr **tcph,
struct ndpi_udphdr **udph,
@@ -1002,7 +998,7 @@ static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflo
iph.protocol = l4proto;
return(get_ndpi_flow_info(workflow, 6, vlan_id, tunnel_type,
- &iph, iph6, ip_offset, ipsize,
+ &iph, iph6, ipsize,
ip_len, l4ptr - (const u_int8_t *)iph6,
tcph, udph, sport, dport,
proto, payload,
@@ -1430,7 +1426,6 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
ndpi_packet_tunnel tunnel_type,
const struct ndpi_iphdr *iph,
struct ndpi_ipv6hdr *iph6,
- u_int16_t ip_offset,
u_int16_t ipsize, u_int16_t rawsize,
const struct pcap_pkthdr *header,
const u_char *packet,
@@ -1453,7 +1448,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
if(iph)
flow = get_ndpi_flow_info(workflow, IPVERSION, vlan_id,
tunnel_type, iph, NULL,
- ip_offset, ipsize,
+ ipsize,
ntohs(iph->tot_len) ? (ntohs(iph->tot_len) - (iph->ihl * 4)) : ipsize - (iph->ihl * 4) /* TSO */,
iph->ihl * 4,
&tcph, &udph, &sport, &dport,
@@ -1461,7 +1456,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
&payload, &payload_len, &src_to_dst_direction, when);
else
flow = get_ndpi_flow_info6(workflow, vlan_id,
- tunnel_type, iph6, ip_offset, ipsize,
+ tunnel_type, iph6, ipsize,
&tcph, &udph, &sport, &dport,
&proto,
&payload, &payload_len, &src_to_dst_direction, when);
@@ -1554,7 +1549,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
#endif
if(enable_payload_analyzer && (payload_len > 0))
- ndpi_payload_analyzer(flow, src_to_dst_direction,
+ ndpi_payload_analyzer(flow,
payload, payload_len,
workflow->stats.ip_packet_count);
@@ -1613,7 +1608,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
}
if((!skip) && ((flow->src2dst_packets+flow->dst2src_packets) < 100)) {
- if(ndpi_has_human_readeable_string(workflow->ndpi_struct, (char*)packet, header->caplen,
+ if(ndpi_has_human_readeable_string((char*)packet, header->caplen,
human_readeable_string_len,
flow->human_readeable_string_buffer,
sizeof(flow->human_readeable_string_buffer)) == 1)
@@ -2369,7 +2364,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
/* process the packet */
return(packet_processing(workflow, time_ms, vlan_id, tunnel_type, iph, iph6,
- ip_offset, header->caplen - ip_offset,
+ header->caplen - ip_offset,
header->caplen, header, packet, header->ts,
flow_risk));
}