added ip range feature for file loaded with -p option to support custom protocols specified

This commit is contained in:
Campus
2015-12-31 17:07:22 +01:00
parent a2c51a586e
commit 5336aecde7
+14 -3
View File
@@ -1623,14 +1623,23 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp
patricia_node_t *node; patricia_node_t *node;
struct in_addr pin; 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); 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; node->value.user_value = protocol_id;
}
return(0); return 0;
} }
#endif #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) { int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_mod, char* rule, u_int8_t do_add) {
char *at, *proto, *elem; char *at, *proto, *elem;
ndpi_proto_defaults_t *def; ndpi_proto_defaults_t *def;
int subprotocol_id, i; 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) { int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char* path) {
FILE *fd = fopen(path, "r"); FILE *fd = fopen(path, "r");
int i; int i;