mirror of
https://github.com/vel21ripn/nDPI.git
synced 2026-05-06 03:45:32 +00:00
commit
98b3268bfb
2 changed files with 17 additions and 17 deletions
|
|
@ -1502,7 +1502,7 @@ static void saveScannerStats(json_object **jObj_group, struct single_flow_info *
|
|||
if(j >= 10) break;
|
||||
}
|
||||
|
||||
json_object_object_add(jObj_stat,"top.ports",jArray_ports);
|
||||
json_object_object_add(jObj_stat,"top.dst.ports",jArray_ports);
|
||||
json_object_array_add(jArray_stats, jObj_stat);
|
||||
|
||||
j = 0;
|
||||
|
|
@ -1510,7 +1510,7 @@ static void saveScannerStats(json_object **jObj_group, struct single_flow_info *
|
|||
if(i >= 10) break;
|
||||
}
|
||||
|
||||
json_object_object_add(*jObj_group, "scanner.stats", jArray_stats);
|
||||
json_object_object_add(*jObj_group, "top.scanner.stats", jArray_stats);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1545,8 +1545,8 @@ static void saveTopStats(json_object **jObj_group,
|
|||
json_object_new_double(((double)s->num_flows)/s->num_pkts));
|
||||
else json_object_object_add(jObj_stat,"flows.num_packets",json_object_new_double(0.0));
|
||||
|
||||
json_object_object_add(jObj_stat,"aggressive.ip",json_object_new_string(s->top_ip));
|
||||
json_object_object_add(jObj_stat,"protocol",json_object_new_string(s->proto));
|
||||
json_object_object_add(jObj_stat,"aggressive.host",json_object_new_string(s->top_ip));
|
||||
json_object_object_add(jObj_stat,"host.app.protocol",json_object_new_string(s->proto));
|
||||
|
||||
json_object_array_add(jArray_stats, jObj_stat);
|
||||
i++;
|
||||
|
|
@ -1569,8 +1569,8 @@ static void saveTopStats(json_object **jObj_group,
|
|||
|
||||
json_object *jObj_stat = json_object_new_object();
|
||||
json_object_object_add(jObj_stat,"port",json_object_new_int(s->port));
|
||||
json_object_object_add(jObj_stat,"ip.total",json_object_new_int64(s->num_addr));
|
||||
json_object_object_add(jObj_stat,"ip.percent",json_object_new_double((s->num_addr*100.0)/total_ip_addr));
|
||||
json_object_object_add(jObj_stat,"host.number",json_object_new_int64(s->num_addr));
|
||||
json_object_object_add(jObj_stat,"host.percent",json_object_new_double((s->num_addr*100.0)/total_ip_addr));
|
||||
json_object_object_add(jObj_stat,"flows.number",json_object_new_double(s->num_flows));
|
||||
|
||||
json_object_array_add(jArray_stats,jObj_stat);
|
||||
|
|
@ -1580,7 +1580,7 @@ static void saveTopStats(json_object **jObj_group,
|
|||
}
|
||||
|
||||
json_object_object_add(*jObj_group, (direction == DIR_SRC) ?
|
||||
"top.src.ip.stats" : "top.dst.ip.stats", jArray_stats);
|
||||
"top.src.host.stats" : "top.dst.host.stats", jArray_stats);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -2500,7 +2500,7 @@ void bpf_filter_port_array_add(int filter_array[], int size, int port) {
|
|||
/* *********************************************** */
|
||||
|
||||
/*
|
||||
* @brief add ports which have (flows/packets > treshold)
|
||||
* @brief add ports which have (flows/packets > threshold)
|
||||
* and have (#flows > %1 of total flows) to the srcPortArray
|
||||
* to filter
|
||||
*/
|
||||
|
|
@ -2529,7 +2529,7 @@ void getPacketBasedSourcePortsToFilter(struct json_object *jObj_stat, int srcPor
|
|||
double flows_packets = json_object_get_double(jObj_flows_packets);
|
||||
|
||||
|
||||
if((flows_packets > FLOWS_PACKETS_TRESHOLD) && (flows_percent >= FLOWS_PERCENT_TRESHOLD)) {
|
||||
if((flows_packets > FLOWS_PACKETS_THRESHOLD) && (flows_percent >= FLOWS_PERCENT_THRESHOLD)) {
|
||||
if((res = json_object_object_get_ex(src_pkts_stat, "port", &jObj_port)) == 0) {
|
||||
fprintf(stderr, "ERROR: can't get \"port\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
exit(-1);
|
||||
|
|
@ -2602,8 +2602,8 @@ void getTopReceiverHostsToFilter(struct json_object *jObj_stat, int duration, co
|
|||
|
||||
|
||||
if(flows_percent > 0.2) {
|
||||
if((res = json_object_object_get_ex(scanner_stat, "aggressive.ip", &jObj_host_address)) == 0) {
|
||||
fprintf(stderr, "ERROR: can't get \"aggressive.ip\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
if((res = json_object_object_get_ex(scanner_stat, "aggressive.host", &jObj_host_address)) == 0) {
|
||||
fprintf(stderr, "ERROR: can't get \"aggressive.host\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
exit(-1);
|
||||
}
|
||||
const char *host_address = json_object_get_string(jObj_host_address);
|
||||
|
|
@ -2719,8 +2719,8 @@ static void produceBpfFilter(char *filePath) {
|
|||
json_object *stats = json_object_array_get_idx(jObj_statistics, i);
|
||||
json_object *val;
|
||||
|
||||
if((res = json_object_object_get_ex(stats, "scanner.stats", &val)) == 0) {
|
||||
fprintf(stderr,"ERROR: can't get \"scanner.stats\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
if((res = json_object_object_get_ex(stats, "top.scanner.stats", &val)) == 0) {
|
||||
fprintf(stderr,"ERROR: can't get \"top.scanner.stats\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
exit(-1);
|
||||
}
|
||||
getScannerHostsToFilter(val, duration, filterSrcHosts, HOST_ARRAY_SIZE);
|
||||
|
|
@ -2733,8 +2733,8 @@ static void produceBpfFilter(char *filePath) {
|
|||
getPacketBasedSourcePortsToFilter(val, filterSrcPorts, PORT_ARRAY_SIZE);
|
||||
|
||||
|
||||
if((res = json_object_object_get_ex(stats, "top.src.ip.stats", &val)) == 0) {
|
||||
fprintf(stderr,"ERROR: can't get \"top.src.ip.stats\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
if((res = json_object_object_get_ex(stats, "top.src.host.stats", &val)) == 0) {
|
||||
fprintf(stderr,"ERROR: can't get \"top.src.host.stats\", use -x flag only with .json files generated by ndpiReader -b flag.\n");
|
||||
exit(-1);
|
||||
}
|
||||
getHostBasedSourcePortsToFilter(val, duration, filterSrcPorts, PORT_ARRAY_SIZE);
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@
|
|||
#define DIR_DST 20
|
||||
#define PORT_ARRAY_SIZE 20
|
||||
#define HOST_ARRAY_SIZE 20
|
||||
#define FLOWS_PACKETS_TRESHOLD 0.9
|
||||
#define FLOWS_PERCENT_TRESHOLD 1.0
|
||||
#define FLOWS_PACKETS_THRESHOLD 0.9
|
||||
#define FLOWS_PERCENT_THRESHOLD 1.0
|
||||
#define INIT_VAL -1
|
||||
|
||||
// flow tracking
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue