Skip to content

Commit 0ffd133

Browse files
committed
[pfsense_nat_port_forward] Add ipprotocol paramter
1 parent 624684a commit 0ffd133

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

plugins/module_utils/nat_port_forward.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
disabled=dict(default=False, required=False, type='bool'),
1717
nordr=dict(default=False, required=False, type='bool'),
1818
interface=dict(required=False, type='str'),
19+
ipprotocol=dict(default='inet', choices=['inet', 'inet6']),
1920
protocol=dict(default='tcp', required=False, choices=["tcp", "udp", "tcp/udp", "icmp", "esp", "ah", "gre", "ipv6", "igmp", "pim", "ospf"]),
2021
source=dict(required=False, type='str'),
2122
destination=dict(required=False, type='str'),
@@ -70,6 +71,7 @@ def _params_to_obj(self):
7071
obj['descr'] = self.params['descr']
7172
if self.params['state'] == 'present':
7273
obj['interface'] = self.pfsense.parse_interface(self.params['interface'])
74+
self._get_ansible_param(obj, 'ipprotocol')
7375
self._get_ansible_param(obj, 'protocol')
7476
self._get_ansible_param(obj, 'poolopts')
7577
self._get_ansible_param(obj, 'source_hash_key')
@@ -389,6 +391,7 @@ def _log_fields(self, before=None):
389391
values += self.format_cli_field(self.params, 'disabled', fvalue=self.fvalue_bool, default=False)
390392
values += self.format_cli_field(self.params, 'nordr', fvalue=self.fvalue_bool, default=False)
391393
values += self.format_cli_field(self.params, 'interface')
394+
values += self.format_cli_field(self.params, 'ipprotocol', default='inet')
392395
values += self.format_cli_field(self.params, 'protocol', default='tcp')
393396
values += self.format_cli_field(self.params, 'source')
394397
values += self.format_cli_field(self.params, 'destination')
@@ -406,6 +409,7 @@ def _log_fields(self, before=None):
406409
values += self.format_updated_cli_field(self.obj, before, 'disabled', fvalue=self.fvalue_bool, default=False, add_comma=(values))
407410
values += self.format_updated_cli_field(self.obj, before, 'nordr', fvalue=self.fvalue_bool, default=False, add_comma=(values))
408411
values += self.format_updated_cli_field(fafter, fbefore, 'interface', add_comma=(values))
412+
values += self.format_updated_cli_field(self.obj, before, 'ipprotocol', add_comma=(values))
409413
values += self.format_updated_cli_field(self.obj, before, 'protocol', fvalue=self.fprotocol, add_comma=(values))
410414
values += self.format_updated_cli_field(fafter, fbefore, 'source', add_comma=(values))
411415
values += self.format_updated_cli_field(fafter, fbefore, 'destination', add_comma=(values))

plugins/modules/pfsense_aggregate.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@
252252
description: The interface for the rule
253253
required: false
254254
type: str
255+
ipprotocol:
256+
description: The IP protocol
257+
default: inet
258+
choices: [ "inet", "inet6" ]
259+
type: str
255260
protocol:
256261
description: Which protocol this rule should match.
257262
default: tcp

plugins/modules/pfsense_nat_port_forward.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
# Copyright: (c) 2019, Frederic Bor <[email protected]>
5+
# Copyright: (c) 2023, Orion Poplawski <[email protected]>
56
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
67

78
from __future__ import absolute_import, division, print_function
@@ -38,6 +39,11 @@
3839
description: The interface for the rule
3940
required: false
4041
type: str
42+
ipprotocol:
43+
description: The IP protocol
44+
default: inet
45+
choices: [ "inet", "inet6" ]
46+
type: str
4147
protocol:
4248
description: Which protocol this rule should match.
4349
default: tcp

tests/unit/plugins/modules/fixtures/pfsense_nat_port_forward_config.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
<network>wanip</network>
269269
<port>22022</port>
270270
</destination>
271+
<ipprotocol>inet</ipprotocol>
271272
<protocol>tcp</protocol>
272273
<target>10.255.1.20</target>
273274
<local-port>22</local-port>
@@ -291,6 +292,7 @@
291292
<network>wanip</network>
292293
<port>22022</port>
293294
</destination>
295+
<ipprotocol>inet</ipprotocol>
294296
<protocol>tcp</protocol>
295297
<target>10.255.1.20</target>
296298
<local-port>22</local-port>
@@ -314,6 +316,7 @@
314316
<network>wanip</network>
315317
<port>22022</port>
316318
</destination>
319+
<ipprotocol>inet</ipprotocol>
317320
<protocol>tcp</protocol>
318321
<target>10.255.1.20</target>
319322
<local-port>22</local-port>
@@ -339,6 +342,7 @@
339342
<network>wanip</network>
340343
<port>22022</port>
341344
</destination>
345+
<ipprotocol>inet</ipprotocol>
342346
<protocol>tcp</protocol>
343347
<interface>wan</interface>
344348
<descr>NAT last</descr>
@@ -375,6 +379,7 @@
375379
<username></username>
376380
<time>1545574416</time>
377381
</updated>
382+
<ipprotocol>inet</ipprotocol>
378383
<protocol>tcp</protocol>
379384
<descr>test_rule</descr>
380385
<created>
@@ -399,6 +404,7 @@
399404
<username></username>
400405
<time>1545574416</time>
401406
</updated>
407+
<ipprotocol>inet</ipprotocol>
402408
<protocol>tcp</protocol>
403409
<log></log>
404410
<descr>test_rule_2</descr>
@@ -424,6 +430,7 @@
424430
<username></username>
425431
<time>1545574416</time>
426432
</updated>
433+
<ipprotocol>inet</ipprotocol>
427434
<protocol>tcp</protocol>
428435
<descr>test_lan_100_1</descr>
429436
<created>
@@ -449,6 +456,7 @@
449456
<username></username>
450457
<time>1545574416</time>
451458
</updated>
459+
<ipprotocol>inet</ipprotocol>
452460
<protocol>tcp</protocol>
453461
<descr>test_lan_100_2</descr>
454462
<created>
@@ -475,6 +483,7 @@
475483
<username></username>
476484
<time>1545574416</time>
477485
</updated>
486+
<ipprotocol>inet</ipprotocol>
478487
<protocol>tcp</protocol>
479488
<descr>test_lan_100_3</descr>
480489
<created>
@@ -500,6 +509,7 @@
500509
<username></username>
501510
<time>1545574416</time>
502511
</updated>
512+
<ipprotocol>inet</ipprotocol>
503513
<protocol>tcp</protocol>
504514
<descr>test_lan_100_4</descr>
505515
<created>
@@ -526,6 +536,7 @@
526536
<username></username>
527537
<time>1545574416</time>
528538
</updated>
539+
<ipprotocol>inet</ipprotocol>
529540
<protocol>tcp</protocol>
530541
<descr>test_lan_100_5</descr>
531542
<created>
@@ -551,6 +562,7 @@
551562
<username></username>
552563
<time>1545574416</time>
553564
</updated>
565+
<ipprotocol>inet</ipprotocol>
554566
<protocol>tcp</protocol>
555567
<descr>test_rule_3</descr>
556568
<created>
@@ -576,6 +588,7 @@
576588
<username></username>
577589
<time>1545574416</time>
578590
</updated>
591+
<ipprotocol>inet</ipprotocol>
579592
<protocol>tcp</protocol>
580593
<descr>antilock_out_3</descr>
581594
<created>
@@ -601,6 +614,7 @@
601614
<username>fbor</username>
602615
<time>1545907554</time>
603616
</updated>
617+
<ipprotocol>inet</ipprotocol>
604618
<protocol>tcp</protocol>
605619
<descr>test_rule_floating</descr>
606620
<created>

tests/unit/plugins/modules/test_pfsense_nat_port_forward.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def check_target_elt(self, obj, target_elt, target_idx=-1):
5252
self.check_param_equal_or_not_find(obj, target_elt, 'natreflection', not_find_val='system-default')
5353

5454
self.check_value_equal(target_elt, 'interface', self.unalias_interface(obj['interface']))
55+
self.check_param_equal(obj, target_elt, 'ipprotocol', 'inet')
5556
self.check_param_equal(obj, target_elt, 'protocol', 'tcp')
5657

5758
self.check_rule_idx(obj, target_idx)

0 commit comments

Comments
 (0)