Skip to content

Commit

Permalink
Added custom category support to ndpi_get_partial_detection()
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Apr 1, 2019
1 parent 1915a63 commit 6693151
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion example/ndpiReader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,8 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) {
if(category) {
int fields[4];

// printf("Loading %s\t%s\n", name, category);

if(verbose) printf("[Category] Loading %s\t%s\n", name, category);

if(sscanf(name, "%d.%d.%d.%d", &fields[0], &fields[1], &fields[2], &fields[3]) == 4)
ndpi_load_ip_category(ndpi_thread_info[thread_id].workflow->ndpi_struct,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@ static int hyperscanCustomEventHandler(unsigned int id,
/* *********************************************** */

int ndpi_match_custom_category(struct ndpi_detection_module_struct *ndpi_struct,
char *name, unsigned long *id) {
char *name, unsigned long *id) {
#ifdef DEBUG
printf("[NDPI] %s(%s) [enable_category_substring_match: %u]\n",
__FUNCTION__, name, ndpi_struct->enable_category_substring_match);
Expand Down Expand Up @@ -2518,7 +2518,7 @@ int ndpi_match_custom_category(struct ndpi_detection_module_struct *ndpi_struct,
/* *********************************************** */

int ndpi_get_custom_category_match(struct ndpi_detection_module_struct *ndpi_struct,
char *name_or_ip, unsigned long *id) {
char *name_or_ip, unsigned long *id) {
char ipbuf[64];
struct in_addr pin;

Expand Down Expand Up @@ -4180,7 +4180,8 @@ static ndpi_protocol ndpi_process_partial_detection(struct ndpi_detection_module

if(ret.app_protocol == NDPI_PROTOCOL_UNKNOWN)
ret.app_protocol = ret.master_protocol;


ndpi_fill_protocol_category(ndpi_struct, flow, &ret);
ndpi_int_change_protocol(ndpi_struct, flow, ret.app_protocol, ret.master_protocol);
return(ret);
}
Expand Down Expand Up @@ -6090,7 +6091,6 @@ static int ndpi_automa_match_string_subprotocol(struct ndpi_detection_module_str
matching_protocol_id = ndpi_match_string_subprotocol(ndpi_struct, string_to_match,
string_to_match_len, ret_match,
is_host_match);

#else
struct hs *hs = (struct hs*)ndpi_struct->hyperscan;
hs_error_t status;
Expand Down

0 comments on commit 6693151

Please sign in to comment.