summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-02-08 17:56:17 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2008-02-08 17:56:17 -0800
commitc1555b7c75752abe885ec10c605124c5c85238af (patch)
tree06df686406fb4cd4a322ddab3598868c0deeb87b
parent2e269d3a39f8198ceaffbd4cf82074c6f4aedc52 (diff)
downloadvyatta-nat-c1555b7c75752abe885ec10c605124c5c85238af.tar.gz
vyatta-nat-c1555b7c75752abe885ec10c605124c5c85238af.zip
merge address range into address
-rw-r--r--scripts/VyattaNatRule.pm68
-rw-r--r--templates-cfg/service/nat/rule/node.tag/inside-address/address/node.def7
-rw-r--r--templates-cfg/service/nat/rule/node.tag/inside-address/range/node.def1
-rw-r--r--templates-cfg/service/nat/rule/node.tag/inside-address/range/start/node.def2
-rw-r--r--templates-cfg/service/nat/rule/node.tag/inside-address/range/stop/node.def2
-rw-r--r--templates-cfg/service/nat/rule/node.tag/outside-address/address/node.def7
-rw-r--r--templates-cfg/service/nat/rule/node.tag/outside-address/range/node.def1
-rw-r--r--templates-cfg/service/nat/rule/node.tag/outside-address/range/start/node.def2
-rw-r--r--templates-cfg/service/nat/rule/node.tag/outside-address/range/stop/node.def2
9 files changed, 47 insertions, 45 deletions
diff --git a/scripts/VyattaNatRule.pm b/scripts/VyattaNatRule.pm
index 5f237db..020c444 100644
--- a/scripts/VyattaNatRule.pm
+++ b/scripts/VyattaNatRule.pm
@@ -84,19 +84,27 @@ sub setup {
$self->{_inside_addr}->{_addr}
= $config->returnValue("inside-address address");
- $self->{_inside_addr}->{_range}->{_start}
- = $config->returnValue("inside-address range start");
- $self->{_inside_addr}->{_range}->{_stop}
- = $config->returnValue("inside-address range stop");
+ $self->{_inside_addr}->{_range}->{_start} = undef;
+ $self->{_inside_addr}->{_range}->{_stop} = undef;
+ if (defined($self->{_inside_addr}->{_addr})
+ && $self->{_inside_addr}->{_addr} =~ /^([^-]+)-([^-]+)$/) {
+ $self->{_inside_addr}->{_range}->{_start} = $1;
+ $self->{_inside_addr}->{_range}->{_stop} = $2;
+ $self->{_inside_addr}->{_addr} = undef;
+ }
$self->{_inside_addr}->{_port}
= $config->returnValue("inside-address port");
$self->{_outside_addr}->{_addr}
= $config->returnValue("outside-address address");
- $self->{_outside_addr}->{_range}->{_start}
- = $config->returnValue("outside-address range start");
- $self->{_outside_addr}->{_range}->{_stop}
- = $config->returnValue("outside-address range stop");
+ $self->{_outside_addr}->{_range}->{_start} = undef;
+ $self->{_outside_addr}->{_range}->{_stop} = undef;
+ if (defined($self->{_outside_addr}->{_addr})
+ && $self->{_outside_addr}->{_addr} =~ /^([^-]+)-([^-]+)$/) {
+ $self->{_outside_addr}->{_range}->{_start} = $1;
+ $self->{_outside_addr}->{_range}->{_stop} = $2;
+ $self->{_outside_addr}->{_addr} = undef;
+ }
$self->{_outside_addr}->{_port}
= $config->returnValue("outside-address port");
@@ -138,19 +146,27 @@ sub setupOrig {
$self->{_inside_addr}->{_addr}
= $config->returnOrigValue("inside-address address");
- $self->{_inside_addr}->{_range}->{_start}
- = $config->returnOrigValue("inside-address range start");
- $self->{_inside_addr}->{_range}->{_stop}
- = $config->returnOrigValue("inside-address range stop");
+ $self->{_inside_addr}->{_range}->{_start} = undef;
+ $self->{_inside_addr}->{_range}->{_stop} = undef;
+ if (defined($self->{_inside_addr}->{_addr})
+ && $self->{_inside_addr}->{_addr} =~ /^([^-]+)-([^-]+)$/) {
+ $self->{_inside_addr}->{_range}->{_start} = $1;
+ $self->{_inside_addr}->{_range}->{_stop} = $2;
+ $self->{_inside_addr}->{_addr} = undef;
+ }
$self->{_inside_addr}->{_port}
= $config->returnOrigValue("inside-address port");
$self->{_outside_addr}->{_addr}
= $config->returnOrigValue("outside-address address");
- $self->{_outside_addr}->{_range}->{_start}
- = $config->returnOrigValue("outside-address range start");
- $self->{_outside_addr}->{_range}->{_stop}
- = $config->returnOrigValue("outside-address range stop");
+ $self->{_outside_addr}->{_range}->{_start} = undef;
+ $self->{_outside_addr}->{_range}->{_stop} = undef;
+ if (defined($self->{_outside_addr}->{_addr})
+ && $self->{_outside_addr}->{_addr} =~ /^([^-]+)-([^-]+)$/) {
+ $self->{_outside_addr}->{_range}->{_start} = $1;
+ $self->{_outside_addr}->{_range}->{_stop} = $2;
+ $self->{_outside_addr}->{_addr} = undef;
+ }
$self->{_outside_addr}->{_port}
= $config->returnOrigValue("outside-address port");
@@ -344,28 +360,18 @@ sub print_str {
"type[$self->{_type}] " .
"in_if[$self->{_inbound_if}] out_if[$self->{_outbound_if}] " .
"proto[$self->{_proto}] saddr[$self->{_source}->{_addr}] ".
- "snet[$self->{_source}->{_net}] spnum[@{$self->{_source}->{_port_num}}] ".
- "spname[@{$self->{_source}->{_port_name}}] " .
- "sprange[$self->{_source}->{_port_range}->{_start}" .
- "-$self->{_source}->{_port_range}->{_stop}] " .
+ "snet[$self->{_source}->{_net}] sp[@{$self->{_source}->{_port}}] ".
"daddr[$self->{_destination}->{_addr}] " .
"dnet[$self->{_destination}->{_net}] " .
- "dpnum[@{$self->{_destination}->{_port_num}}] " .
- "dpname[@{$self->{_destination}->{_port_name}}] " .
- "dprange[$self->{_destination}->{_port_range}->{_start}-" .
- "$self->{_destination}->{_port_range}->{_stop}] " .
+ "dp[@{$self->{_destination}->{_port}}] " .
"inaddr[$self->{_inside_addr}->{_addr}] " .
"inrange[$self->{_inside_addr}->{_range}->{_start}-" .
"$self->{_inside_addr}->{_range}->{_stop}] " .
- "inp[$self->{_inside_addr}->{_port_num}] " .
- "inprange[$self->{_inside_addr}->{_port_range}->{_start}-" .
- "$self->{_inside_addr}->{_port_range}->{_stop}] " .
+ "inp[$self->{_inside_addr}->{_port}] " .
"outaddr[$self->{_outside_addr}->{_addr}] " .
"outrange[$self->{_outside_addr}->{_range}->{_start}-" .
- "$self->{_outside_addr}->{_range}->{_stop}]";
- "outp[$self->{_outside_addr}->{_port_num}] " .
- "outprange[$self->{_outside_addr}->{_port_range}->{_start}-" .
- "$self->{_outside_addr}->{_port_range}->{_stop}] " .
+ "$self->{_outside_addr}->{_range}->{_stop}]" .
+ "outp[$self->{_outside_addr}->{_port}] ";
return $str;
}
diff --git a/templates-cfg/service/nat/rule/node.tag/inside-address/address/node.def b/templates-cfg/service/nat/rule/node.tag/inside-address/address/node.def
index 023988a..0f3e879 100644
--- a/templates-cfg/service/nat/rule/node.tag/inside-address/address/node.def
+++ b/templates-cfg/service/nat/rule/node.tag/inside-address/address/node.def
@@ -1,2 +1,5 @@
-type: ipv4
-help: Inside address to NAT
+type: txt
+help: Configure inside IP address or range for NAT
+comp_help: Possible completions:
+ <IP address> NAT to the specified IP address
+ <IP address>-<IP address> NAT to the specified IP range
diff --git a/templates-cfg/service/nat/rule/node.tag/inside-address/range/node.def b/templates-cfg/service/nat/rule/node.tag/inside-address/range/node.def
deleted file mode 100644
index ca078b2..0000000
--- a/templates-cfg/service/nat/rule/node.tag/inside-address/range/node.def
+++ /dev/null
@@ -1 +0,0 @@
-help: Inside address range
diff --git a/templates-cfg/service/nat/rule/node.tag/inside-address/range/start/node.def b/templates-cfg/service/nat/rule/node.tag/inside-address/range/start/node.def
deleted file mode 100644
index 5295026..0000000
--- a/templates-cfg/service/nat/rule/node.tag/inside-address/range/start/node.def
+++ /dev/null
@@ -1,2 +0,0 @@
-type: ipv4
-help: Inside address range start
diff --git a/templates-cfg/service/nat/rule/node.tag/inside-address/range/stop/node.def b/templates-cfg/service/nat/rule/node.tag/inside-address/range/stop/node.def
deleted file mode 100644
index 82d8698..0000000
--- a/templates-cfg/service/nat/rule/node.tag/inside-address/range/stop/node.def
+++ /dev/null
@@ -1,2 +0,0 @@
-type: ipv4
-help: Inside address range stop
diff --git a/templates-cfg/service/nat/rule/node.tag/outside-address/address/node.def b/templates-cfg/service/nat/rule/node.tag/outside-address/address/node.def
index b6aa4ed..4434bdb 100644
--- a/templates-cfg/service/nat/rule/node.tag/outside-address/address/node.def
+++ b/templates-cfg/service/nat/rule/node.tag/outside-address/address/node.def
@@ -1,2 +1,5 @@
-type: ipv4
-help: Outside address to NAT
+type: txt
+help: Configure outside IP address or range for NAT
+comp_help: Possible completions:
+ <IP address> NAT to the specified IP address
+ <IP address>-<IP address> NAT to the specified IP range
diff --git a/templates-cfg/service/nat/rule/node.tag/outside-address/range/node.def b/templates-cfg/service/nat/rule/node.tag/outside-address/range/node.def
deleted file mode 100644
index 5a053ea..0000000
--- a/templates-cfg/service/nat/rule/node.tag/outside-address/range/node.def
+++ /dev/null
@@ -1 +0,0 @@
-help: Outside address range
diff --git a/templates-cfg/service/nat/rule/node.tag/outside-address/range/start/node.def b/templates-cfg/service/nat/rule/node.tag/outside-address/range/start/node.def
deleted file mode 100644
index cc5a8d1..0000000
--- a/templates-cfg/service/nat/rule/node.tag/outside-address/range/start/node.def
+++ /dev/null
@@ -1,2 +0,0 @@
-type: ipv4
-help: Outside address range start
diff --git a/templates-cfg/service/nat/rule/node.tag/outside-address/range/stop/node.def b/templates-cfg/service/nat/rule/node.tag/outside-address/range/stop/node.def
deleted file mode 100644
index dee5ac6..0000000
--- a/templates-cfg/service/nat/rule/node.tag/outside-address/range/stop/node.def
+++ /dev/null
@@ -1,2 +0,0 @@
-type: ipv4
-help: Outside address range stop