diff options
author | Campus <campus@ntop.org> | 2015-12-31 17:07:22 +0100 |
---|---|---|
committer | Campus <campus@ntop.org> | 2015-12-31 17:07:22 +0100 |
commit | 5336aecde7e6f40e22810538dba9dd6601291145 (patch) | |
tree | 0388381b55fb59196217e82f5ac00045d2760204 /src | |
parent | a2c51a586ebae66da84d658dd53df60b3ad140a0 (diff) |
added ip range feature for file loaded with -p option to support custom protocols specified
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_main.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 49d8f8a9f..4ec1fa503 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -1623,14 +1623,23 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp patricia_node_t *node; struct in_addr pin; - + int bits = 32; + char *ptr = strrchr(value, '/'); + + if (ptr) + { + ptr[0] = '\0'; + ptr++; + if (atoi(ptr)>=0 && atoi(ptr)<=32) + bits = atoi(ptr); + } + inet_pton(AF_INET, value, &pin); - - if((node = add_to_ptree(ndpi_struct->protocols_ptree, AF_INET, &pin, 32)) != NULL) { + + if((node = add_to_ptree(ndpi_struct->protocols_ptree, AF_INET, &pin, bits)) != NULL) node->value.user_value = protocol_id; - } - - return(0); + + return 0; } #endif @@ -1846,6 +1855,7 @@ char * strsep(char **sp, char *sep) int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_mod, char* rule, u_int8_t do_add) { + char *at, *proto, *elem; ndpi_proto_defaults_t *def; int subprotocol_id, i; @@ -1960,6 +1970,7 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_mod, char* rule, */ int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char* path) { + FILE *fd = fopen(path, "r"); int i; |