summaryrefslogtreecommitdiff
path: root/python/vyos/firewall.py
diff options
context:
space:
mode:
authorNicolas Fort <nicolasfort1988@gmail.com>2022-08-27 15:35:52 +0000
committerNicolas Fort <nicolasfort1988@gmail.com>2022-08-27 15:35:52 +0000
commit37cfa8cdb1c6a1d395109aabd3ee29e83db151da (patch)
tree8a710dc72fe799956330008f8031bc07f9d1a407 /python/vyos/firewall.py
parent9126170f0b09285cf79f8c40584312bccd67c3e8 (diff)
downloadvyos-1x-37cfa8cdb1c6a1d395109aabd3ee29e83db151da.tar.gz
vyos-1x-37cfa8cdb1c6a1d395109aabd3ee29e83db151da.zip
Firewall: T4651: Add options to match packet size on firewall rules.
Diffstat (limited to 'python/vyos/firewall.py')
-rw-r--r--python/vyos/firewall.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index 663c4394a..a4fd64830 100644
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -265,6 +265,32 @@ def parse_rule(rule_conf, fw_name, rule_id, ip_name):
if 'type' in rule_conf[icmp]:
output.append(icmp + ' type ' + rule_conf[icmp]['type'])
+
+ if 'ip_length' in rule_conf:
+ #proto = rule_conf['protocol']
+ length = rule_conf['ip_length'].split(',')
+
+ lengths = []
+ negated_lengths = []
+
+ for p in length:
+ if p[0] == '!':
+ negated_lengths.append(p[1:])
+ else:
+ lengths.append(p)
+
+ #if proto == 'tcp_udp':
+ # proto = 'th'
+
+ if lengths:
+ lengths_str = ','.join(lengths)
+ output.append(f'ip{def_suffix} length {{{lengths_str}}}')
+
+ if negated_lengths:
+ negated_lengths_str = ','.join(negated_lengths)
+ output.append(f'ip{def_suffix} length != {{{negated_lengths_str}}}')
+
+
if 'ipsec' in rule_conf:
if 'match_ipsec' in rule_conf['ipsec']:
output.append('meta ipsec == 1')