diff options
author | Luca Deri <deri@ntop.org> | 2022-04-22 19:03:50 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2022-04-22 19:03:50 +0200 |
commit | 9d31b7450bea4f6677179fd3b4837e0afd331e70 (patch) | |
tree | d45d2757ecb6354e0b69b5e271b23dcdc4e21db0 | |
parent | d5ae9170ba5c909fd1b027e2d2f71bdc4d7abbe7 (diff) |
Code cleanup (removed redundancy)
-rw-r--r-- | src/lib/ndpi_main.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index e1c3ee85e..3d4f7e96c 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -3301,7 +3301,8 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, char *rule, char *at, *proto, *elem; ndpi_proto_defaults_t *def; u_int subprotocol_id, i; - + int id; + at = strrchr(rule, '@'); if(at == NULL) { /* This looks like a mask rule or an invalid rule */ @@ -3353,15 +3354,12 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, char *rule, } } - for(i = 0, def = NULL; i < ndpi_str->ndpi_num_supported_protocols; i++) { - if(ndpi_str->proto_defaults[i].protoName - && strcasecmp(ndpi_str->proto_defaults[i].protoName, proto) == 0) { - def = &ndpi_str->proto_defaults[i]; - subprotocol_id = i; - break; - } - } - + if((id = ndpi_get_protocol_id(ndpi_str, proto)) != -1) { + subprotocol_id = (u_int)id; + def = &ndpi_str->proto_defaults[subprotocol_id]; + } else + def = NULL; + if(def == NULL) { if(!do_add) { /* We need to remove a rule */ |