summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@build-vm.localdomain>2007-12-19 15:27:04 -0800
committerAn-Cheng Huang <ancheng@build-vm.localdomain>2007-12-19 15:27:04 -0800
commit56880bec43eef6af8301cdfbe9c764b4257bd24b (patch)
treea7ba2a4a6c73f93e0a94e2d2db9cda264bfec254
parent561ec07cb56696b05f683a325098c06422d00f86 (diff)
downloadvyatta-nat-56880bec43eef6af8301cdfbe9c764b4257bd24b.tar.gz
vyatta-nat-56880bec43eef6af8301cdfbe9c764b4257bd24b.zip
* add completion help/value check.
* fix show command.
-rwxr-xr-xscripts/vyatta-show-nat.pl2
-rw-r--r--templates-cfg/service/nat/rule/node.tag/inbound-interface/node.def5
-rw-r--r--templates-cfg/service/nat/rule/node.tag/outbound-interface/node.def5
-rw-r--r--templates-cfg/service/nat/rule/node.tag/protocols/node.def5
-rw-r--r--templates-cfg/service/nat/rule/node.tag/type/node.def7
-rw-r--r--xsl/url-decode.xsl48
6 files changed, 63 insertions, 9 deletions
diff --git a/scripts/vyatta-show-nat.pl b/scripts/vyatta-show-nat.pl
index 5ae67b8..bb25500 100755
--- a/scripts/vyatta-show-nat.pl
+++ b/scripts/vyatta-show-nat.pl
@@ -32,7 +32,7 @@ while (<STATS>) {
}
close STATS;
-open(RENDER, "| /opt/vyatta/libexec/xorp/render_xml $xsl_file") or exit 1;
+open(RENDER, "| /opt/vyatta/sbin/render_xml $xsl_file") or exit 1;
# begin
print RENDER "<opcommand name='natrules'><format type='row'>\n";
diff --git a/templates-cfg/service/nat/rule/node.tag/inbound-interface/node.def b/templates-cfg/service/nat/rule/node.tag/inbound-interface/node.def
index c87d281..533a592 100644
--- a/templates-cfg/service/nat/rule/node.tag/inbound-interface/node.def
+++ b/templates-cfg/service/nat/rule/node.tag/inbound-interface/node.def
@@ -1,5 +1,4 @@
type: txt
help: "Inbound interface of NAT traffic"
-## iptables allow any interface names.
-#syntax: exec "sh -c 'if grep -q '\\''^ \\+$(@):'\\'' /proc/net/dev; \
-#then exit 0; else exit 1; fi' " ; "invalid interface $(@)"
+#allowed: ls /sys/class/net 2>/dev/null
+#comp_help:Enter a network interface name, for example, "eth0"
diff --git a/templates-cfg/service/nat/rule/node.tag/outbound-interface/node.def b/templates-cfg/service/nat/rule/node.tag/outbound-interface/node.def
index bf3e8a2..096629f 100644
--- a/templates-cfg/service/nat/rule/node.tag/outbound-interface/node.def
+++ b/templates-cfg/service/nat/rule/node.tag/outbound-interface/node.def
@@ -1,5 +1,4 @@
type: txt
help: "Outbound interface for NAT traffic"
-## iptables allow any interface names.
-#syntax: exec "sh -c 'if grep -q '\\''^ \\+$(@):'\\'' /proc/net/dev; \
-#then exit 0; else exit 1; fi' " ; "invalid interface $(@)"
+#allowed: ls /sys/class/net 2>/dev/null
+#comp_help:Enter a network interface name, for example, "eth0"
diff --git a/templates-cfg/service/nat/rule/node.tag/protocols/node.def b/templates-cfg/service/nat/rule/node.tag/protocols/node.def
index 75ccb86..619fad9 100644
--- a/templates-cfg/service/nat/rule/node.tag/protocols/node.def
+++ b/templates-cfg/service/nat/rule/node.tag/protocols/node.def
@@ -1,3 +1,8 @@
type: txt
help: "Protocol to NAT (this can be a protocol name in /etc/protocols, a protocol number, or \"all\")"
syntax: exec "/opt/vyatta/sbin/vyatta-validate-type.pl protocol_negate '$(@)'" ; "invalid protocol \"$(@)\""
+#comp_help:Possible completions:
+# <name> A protocol name, for example, "tcp"
+# <number> A protocol number
+# all All protocols
+#(Note: a protocol can also be negated, for example, "!tcp")
diff --git a/templates-cfg/service/nat/rule/node.tag/type/node.def b/templates-cfg/service/nat/rule/node.tag/type/node.def
index 9df10a9..831dd3b 100644
--- a/templates-cfg/service/nat/rule/node.tag/type/node.def
+++ b/templates-cfg/service/nat/rule/node.tag/type/node.def
@@ -1,4 +1,7 @@
type: txt
help: "Source, destination, or masquerade NAT"
-syntax: ($(@) == "source" || $(@) == "destination" || $(@) == "masquerade") ; \
-"invalid type $(@)"
+syntax: $(@) in "source", "destination", "masquerade"; "invalid type $(@)"
+#comp_help:Possible completions:
+# source Source NAT
+# destination Destination NAT
+# masquerade Masquerade NAT
diff --git a/xsl/url-decode.xsl b/xsl/url-decode.xsl
new file mode 100644
index 0000000..6e3db40
--- /dev/null
+++ b/xsl/url-decode.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Obtained from http://skew.org/xml/stylesheets/url-encode/url-decode.xsl -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:output method="text" indent="no" encoding="iso-8859-1"/>
+
+<!-- <xsl:param name="url" select="'urn:check%20out%20my%20r%E9sum%E9'"/>-->
+
+ <xsl:variable name="hex" select="'0123456789ABCDEF'"/>
+ <xsl:variable name="ascii"> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable>
+ <xsl:variable name="latin1">&#160;&#161;&#162;&#163;&#164;&#165;&#166;&#167;&#168;&#169;&#170;&#171;&#172;&#173;&#174;&#175;&#176;&#177;&#178;&#179;&#180;&#181;&#182;&#183;&#184;&#185;&#186;&#187;&#188;&#189;&#190;&#191;&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#215;&#216;&#217;&#218;&#219;&#220;&#221;&#222;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#240;&#241;&#242;&#243;&#244;&#245;&#246;&#247;&#248;&#249;&#250;&#251;&#252;&#253;&#254;&#255;</xsl:variable>
+
+<!-- <xsl:template match="/">
+ <xsl:call-template name="decode">
+ <xsl:with-param name="encoded" select="$url"/>
+ </xsl:call-template>
+ </xsl:template> -->
+
+ <xsl:template name="decode">
+ <xsl:param name="encoded"/>
+ <xsl:choose>
+ <xsl:when test="contains($encoded,'%')">
+ <xsl:value-of select="substring-before($encoded,'%')"/>
+ <xsl:variable name="hexpair" select="translate(substring(substring-after($encoded,'%'),1,2),'abcdef','ABCDEF')"/>
+ <xsl:variable name="decimal" select="(string-length(substring-before($hex,substring($hexpair,1,1))))*16 + string-length(substring-before($hex,substring($hexpair,2,1)))"/>
+ <xsl:choose>
+ <xsl:when test="$decimal &lt; 127 and $decimal &gt; 31">
+ <xsl:value-of select="substring($ascii,$decimal - 31,1)"/>
+ </xsl:when>
+ <xsl:when test="$decimal &gt; 159">
+ <xsl:value-of select="substring($latin1,$decimal - 159,1)"/>
+ </xsl:when>
+ <xsl:otherwise>?</xsl:otherwise>
+ </xsl:choose>
+ <xsl:call-template name="decode">
+ <xsl:with-param name="encoded" select="substring(substring-after($encoded,'%'),3)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$encoded"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>