diff options
author | Luca Deri <deri@ntop.org> | 2020-12-11 17:25:43 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-12-11 17:25:57 +0100 |
commit | 5cb6ddfd221bd8c761d6a54e450e8ba9e920de00 (patch) | |
tree | 4dc03a49c29ed62e3baf473f95201563cc514970 | |
parent | 21ad3a177527e3b5d933c141274ea79afb6cb02f (diff) |
Rule changes work in progress
-rw-r--r-- | rules/sample_rules.txt | 7 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 25 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 2 |
3 files changed, 30 insertions, 4 deletions
diff --git a/rules/sample_rules.txt b/rules/sample_rules.txt index a941e1721..0a4f63c6b 100644 --- a/rules/sample_rules.txt +++ b/rules/sample_rules.txt @@ -1,3 +1,8 @@ -{"rule":{"id":1,"description":"dummy rule"},"network":{"transport":6,"protocol":"tls"},"client":{"ip":"192.168.0.1/24","port":1234},"server":{"ip":"0.0.0.0/0","port":25}} +# Pool definition +{"pool":{"id":1,"description":"my pool 1",ip:"192.168.0.1/24,10.0.0.0/8,2a03:b0c0:2:d0::360:4001/48"}} +{"pool":{"id":2,"description":"my pool 2",mac:"e8:06:88:ff:fe:e4:ba:2c,02:81:27:b5:f9:f3,00:01:01:e4:ba:2c"}} +# Rule definition +{"rule":{"id":1,"description":"dummy rule"},"network":{"transport":6,"protocol":"tls"},"client":{"pool":1,"port":1234},"server":{"pool":2,"port":25}} {"rule":{"id":2,"description":"dummy rule"},"network":{"transport":"tcp","protocol":"tls"},"action":{"verdict":"pass","marker":1}} +# Example of invalid rule {s"rule":{"id":3},"network":{"transport":"udp","protocol":"dns"}} diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 5c544aef0..20ea2c2ed 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -1571,17 +1571,38 @@ typedef enum { rule_drop } ndpi_rule_action; -typedef struct { +typedef struct _ndpi_rule { + /* Ancillary information */ u_int16_t id; char *description; + + /* Keys */ u_int8_t l4_proto; - ndpi_rule_action action; ndpi_rule_peer client, server; /* Network byte order */ u_int16_t l7_proto; + u_int8_t reverseable_rule:1 /* src <-> dst */, _not_used:7; + + /* Rule actions */ + ndpi_rule_action action; + + /* Internal use */ + struct _ndpi_rule *list_next; /* Linked list of rules */ + } ndpi_rule; +/* + Matching order + - L7 protocol + - match client/server + + */ typedef struct { u_int32_t num_rules; + ndpi_rule *root; + + ndpi_rule *l7_rules[NDPI_LAST_IMPLEMENTED_PROTOCOL], *l7_any; + + } ndpi_rules; #endif /* __NDPI_TYPEDEFS_H__ */ diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index f85538f9f..302a7fc03 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -1691,7 +1691,7 @@ u_int8_t ndpi_is_tor_flow(struct ndpi_detection_module_struct *ndpi_str, struct /* ******************************************* */ -static patricia_node_t *add_to_ptree(patricia_tree_t *tree, int family, void *addr, int bits) { +static patricia_node_t* add_to_ptree(patricia_tree_t *tree, int family, void *addr, int bits) { prefix_t prefix; patricia_node_t *node; |