diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpiReader.c | 10 | ||||
-rw-r--r-- | example/ndpi_util.c | 16 |
2 files changed, 13 insertions, 13 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 76fad23dd..5a8f91139 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -757,16 +757,14 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa flow->detected_protocol.master_protocol, flow->detected_protocol.app_protocol, ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct, flow->detected_protocol, buf, sizeof(buf))); - - if(flow->detected_protocol.category != 0) - fprintf(out, "[cat: %u]", flow->detected_protocol.category); } else fprintf(out, "[proto: %u/%s]", flow->detected_protocol.app_protocol, ndpi_get_proto_name(ndpi_thread_info[thread_id].workflow->ndpi_struct, flow->detected_protocol.app_protocol)); - - if(flow->detected_protocol.category != 0) - fprintf(out, "[cat: %u]", flow->detected_protocol.category); + + if(flow->detected_protocol.category != 0) + fprintf(out, "[cat: %s]", ndpi_category_get_name(ndpi_thread_info[thread_id].workflow->ndpi_struct, + flow->detected_protocol.category)); fprintf(out, "[%u pkts/%llu bytes ", flow->src2dst_packets, (long long unsigned int) flow->src2dst_bytes); fprintf(out, "%s %u pkts/%llu bytes]", diff --git a/example/ndpi_util.c b/example/ndpi_util.c index 9695558ae..52cbc6f9b 100644 --- a/example/ndpi_util.c +++ b/example/ndpi_util.c @@ -114,13 +114,13 @@ static uint16_t ndpi_get_proto_id(struct ndpi_detection_module_struct *ndpi_mod, char *e; unsigned long p = strtol(name,&e,0); ndpi_proto_defaults_t *proto_defaults = ndpi_get_proto_defaults(ndpi_mod); - + if(e && !*e) { if(p < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS && proto_defaults[p].protoName) return (uint16_t)p; return NDPI_PROTOCOL_UNKNOWN; } - + for(proto_id=NDPI_PROTOCOL_UNKNOWN; proto_id < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS; proto_id++) { if(proto_defaults[proto_id].protoName && !strcasecmp(proto_defaults[proto_id].protoName,name)) @@ -128,6 +128,9 @@ static uint16_t ndpi_get_proto_id(struct ndpi_detection_module_struct *ndpi_mod, } return NDPI_PROTOCOL_UNKNOWN; } + +/* ***************************************************** */ + static NDPI_PROTOCOL_BITMASK debug_bitmask; static char _proto_delim[] = " \t,:;"; static int parse_debug_proto(struct ndpi_detection_module_struct *ndpi_mod, char *str) { @@ -184,7 +187,7 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n"); exit(-1); } - + ndpi_set_log_level(module, nDPI_LogLevel); if(_debug_protocols != NULL && ! _debug_protocols_ok) { @@ -377,8 +380,7 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow /* to avoid two nodes in one binary tree for a flow */ int is_changed = 0; - if(ret == NULL) - { + if(ret == NULL) { u_int32_t orig_src_ip = flow.src_ip; u_int16_t orig_src_port = flow.src_port; u_int32_t orig_dst_ip = flow.dst_ip; @@ -522,7 +524,7 @@ static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflo void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow) { if(!flow->ndpi_flow) return; - + snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s", flow->ndpi_flow->host_server_name); @@ -533,7 +535,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl for(i=0, j = 0; j < sizeof(flow->bittorent_hash)-1; i++) { sprintf(&flow->bittorent_hash[j], "%02x", flow->ndpi_flow->protos.bittorrent.hash[i]); - + j += 2, n += flow->ndpi_flow->protos.bittorrent.hash[i]; } |