From 7d01f7fec95f65705ec886f4de8bce21e0bfee07 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 16 May 2020 22:20:43 +0200 Subject: nat: nptv6: T2198: add XML/Python skeleton - define XML CLI interface - read CLI into Python dict --- .../include/nat-outbound-interface.xml.i | 8 +++ interface-definitions/nat.xml.in | 81 +++++++++++++++++++--- src/conf_mode/nat.py | 10 ++- 3 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 interface-definitions/include/nat-outbound-interface.xml.i diff --git a/interface-definitions/include/nat-outbound-interface.xml.i b/interface-definitions/include/nat-outbound-interface.xml.i new file mode 100644 index 000000000..d562f7f03 --- /dev/null +++ b/interface-definitions/include/nat-outbound-interface.xml.i @@ -0,0 +1,8 @@ + + + Outbound interface of NAT traffic + + + + + diff --git a/interface-definitions/nat.xml.in b/interface-definitions/nat.xml.in index af9dd1eff..a0b3b815b 100644 --- a/interface-definitions/nat.xml.in +++ b/interface-definitions/nat.xml.in @@ -52,22 +52,87 @@ - + - Source NAT settings + IPv6-to-IPv6 Network Prefix Translation Settings - #include + + NPTv6 rule number + + 1-9999 + Number for this rule + + + + + NAT rule number must be between 1 and 9999 + - + - Outbound interface of NAT traffic - - - + Rule description + + + Disable NAT rule + + + + #include + + + IPv6 source prefix options + + + + + IPv6 prefix to be translated + + ipv6net + IPv6 prefix + + + + + + + + + + + Translated IPv6 prefix options + + + + + IPv6 prefix to translate to + + ipv6net + IPv6 prefix + + + + + + + + + + + + + + + Source NAT settings + + + #include + + + #include Outside NAT IP (source NAT only) diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py index 5cb1af1f1..406ec1caf 100755 --- a/src/conf_mode/nat.py +++ b/src/conf_mode/nat.py @@ -102,8 +102,10 @@ def parse_source_destination(conf, source_dest): 'protocol': 'all', 'number': number, 'source_address': '', + 'source_prefix': '', 'source_port': '', 'translation_address': '', + 'translation_prefix': '', 'translation_port': '' } conf.set_level(base_level + ['rule', number]) @@ -138,12 +140,18 @@ def parse_source_destination(conf, source_dest): if conf.exists(['source', 'address']): rule['source_address'] = conf.return_value(['source', 'address']) + if conf.exists(['source', 'prefix']): + rule['source_prefix'] = conf.return_value(['source', 'prefix']) + if conf.exists(['source', 'port']): rule['source_port'] = conf.return_value(['source', 'port']) if conf.exists(['translation', 'address']): rule['translation_address'] = conf.return_value(['translation', 'address']) + if conf.exists(['translation', 'prefix']): + rule['translation_prefix'] = conf.return_value(['translation', 'prefix']) + if conf.exists(['translation', 'port']): rule['translation_port'] = conf.return_value(['translation', 'port']) @@ -193,7 +201,7 @@ def get_config(): # use a common wrapper function to read in the source / destination # tree from the config - thus we do not need to replicate almost the # same code :-) - for tgt in ['source', 'destination']: + for tgt in ['source', 'destination', 'nptv6']: nat[tgt] = parse_source_destination(conf, tgt) return nat -- cgit v1.2.3