From 3873ed2c155788ab03512a35431f702beacd3749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20De=20Keersmaeker?= <francois.dekeersmaeker@uclouvain.be> Date: Sat, 19 Oct 2024 19:43:53 +0200 Subject: [PATCH] CoAP: request or response --- coap.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/coap.py b/coap.py index 5a0733d..4d45950 100644 --- a/coap.py +++ b/coap.py @@ -23,6 +23,20 @@ class coap(Custom): Optional, default is "src". :return: Dictionary containing the (forward and backward) nftables and nfqueue rules for this policy. """ + # Request or response + coap_response_rule = {} + if "response" in self.protocol_data and self.protocol_data["response"]: + if is_backward: + coap_response_rule = {"template": "{}coap_is_request(coap_message)", "match": ""} + else: + coap_response_rule = {"template": "{}coap_is_request(coap_message)", "match": "!"} + else: + if is_backward: + coap_response_rule = {"template": "{}coap_is_request(coap_message)", "match": "!"} + else: + coap_response_rule = {"template": "{}coap_is_request(coap_message)", "match": ""} + self.rules["nfq"].append(coap_response_rule) + # Lambda functions to convert a CoAP type or method to its C representation (upper case and separated by underscores) func_coap_type = lambda type: f"COAP_{type.upper().replace('-', '_')}" func_coap_method = lambda method: f"HTTP_{method.upper().replace('-', '_')}" -- GitLab