aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2016-02-27 09:00:02 +0100
committerLuca Deri <deri@ntop.org>2016-02-27 09:00:02 +0100
commit20374b542d9830564cc9f50aabbf47656a9db4b0 (patch)
treebed86b1699ddc8e28b0c33cf0c5695b5f5d392ca /src/lib/ndpi_main.c
parent6df31099c21198643336cc3a064df33cb559c547 (diff)
Fixed warning
Reworked protocol initialization
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 636d3ca73..a42afa3d1 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -577,30 +577,36 @@ static int ndpi_remove_host_url_subprotocol(struct ndpi_detection_module_struct
/* ******************************************************************** */
-static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_mod) {
- int i;
-
- for(i=0; host_match[i].string_to_match != NULL; i++) {
- u_int16_t no_master[2] = { NDPI_PROTOCOL_NO_MASTER_PROTO, NDPI_PROTOCOL_NO_MASTER_PROTO };
- ndpi_port_range ports_a[MAX_DEFAULT_PORTS], ports_b[MAX_DEFAULT_PORTS];
-
- ndpi_add_host_url_subprotocol(ndpi_mod, host_match[i].string_to_match,
- host_match[i].protocol_id, host_match[i].protocol_breed);
+void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_mod,
+ ndpi_protocol_match *match) {
+ u_int16_t no_master[2] = { NDPI_PROTOCOL_NO_MASTER_PROTO, NDPI_PROTOCOL_NO_MASTER_PROTO };
+ ndpi_port_range ports_a[MAX_DEFAULT_PORTS], ports_b[MAX_DEFAULT_PORTS];
+
+ ndpi_add_host_url_subprotocol(ndpi_mod, match->string_to_match,
+ match->protocol_id, match->protocol_breed);
+
+ if(ndpi_mod->proto_defaults[match->protocol_id].protoName == NULL) {
+ ndpi_mod->proto_defaults[match->protocol_id].protoName = ndpi_strdup(match->proto_name);
+ ndpi_mod->proto_defaults[match->protocol_id].protoId = match->protocol_id;
+ ndpi_mod->proto_defaults[match->protocol_id].protoBreed = match->protocol_breed;
+ }
+
+ ndpi_set_proto_defaults(ndpi_mod,
+ ndpi_mod->proto_defaults[match->protocol_id].protoBreed,
+ ndpi_mod->proto_defaults[match->protocol_id].protoId,
+ no_master, no_master,
+ ndpi_mod->proto_defaults[match->protocol_id].protoName,
+ ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
+ ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
+}
- if(ndpi_mod->proto_defaults[host_match[i].protocol_id].protoName == NULL) {
- ndpi_mod->proto_defaults[host_match[i].protocol_id].protoName = ndpi_strdup(host_match[i].proto_name);
- ndpi_mod->proto_defaults[host_match[i].protocol_id].protoId = host_match[i].protocol_id;
- ndpi_mod->proto_defaults[host_match[i].protocol_id].protoBreed = host_match[i].protocol_breed;
- }
+/* ******************************************************************** */
- ndpi_set_proto_defaults(ndpi_mod,
- ndpi_mod->proto_defaults[host_match[i].protocol_id].protoBreed,
- ndpi_mod->proto_defaults[host_match[i].protocol_id].protoId,
- no_master, no_master,
- ndpi_mod->proto_defaults[host_match[i].protocol_id].protoName,
- ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
- ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
- }
+static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_mod) {
+ int i;
+
+ for(i=0; host_match[i].string_to_match != NULL; i++)
+ ndpi_init_protocol_match(ndpi_mod, &host_match[i]);
#ifdef DEBUG
ac_automata_display(ndpi_mod->host_automa.ac_automa, 'n');