1
0
Просмотр исходного кода

New ping and route commands implementation in xml-examples. Regards to lff.

git-svn-id: https://klish.googlecode.com/svn/trunk@271 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 14 лет назад
Родитель
Сommit
6073c2c287
1 измененных файлов с 160 добавлено и 77 удалено
  1. 160 77
      xml-examples/klish/etc/clish-xml/ping.xml

+ 160 - 77
xml-examples/klish/etc/clish-xml/ping.xml

@@ -8,117 +8,200 @@
 <VIEW name="ping-view"
 	prompt="${SYSTEM_NAME}# ">
 
+<!-- commands set: ping, ping6, arping, traceroute, traceroute6 -->
+<!-- ping, ping6, arping -->
 	<COMMAND name="ping"
-		help="Send echo messages">
-		<PARAM name="ip"
-			help="IP echo"
-			ptype="SUBCOMMAND"
-			mode="subcommand"
-			optional="true"/>
+		help="Send messages to network hosts">
+		<PARAM name="proto"
+			help="Protocol to use for the ping"
+			optional="true"
+			mode="switch"
+			ptype="SUBCOMMAND">
+			<PARAM name="ip"
+				help="Send ICMP IPv4 messages to network hosts (default)"
+				mode="subcommand"
+				ptype="SUBCOMMAND"/>
+			<PARAM name="ipv6"
+				help="Send ICMP IPv6 messages to network hosts"
+				mode="subcommand"
+				ptype="SUBCOMMAND"/>
+			<PARAM name="arp"
+				help="Send ARP requests to a neighbour host"
+				mode="subcommand"
+				ptype="SUBCOMMAND"/>
+		</PARAM>
 		<PARAM name="dst"
-			help="Ping destination address or hostname"
+			help="Hostname or IP-address to ping"
 			ptype="STRING"/>
-		<PARAM name="resolve"
-			help="Resolve names"
-			ptype="SUBCOMMAND"
-			mode="subcommand"
-			optional="true"/>
-		<PARAM name="broadcast"
-			help="Ping broadcast address"
-			ptype="SUBCOMMAND"
+		<PARAM name="source"
+			help="Source IP-address (ip) or interface (ip and arp)"
+			optional="true"
 			mode="subcommand"
-			optional="true"/>
+			ptype="SUBCOMMAND">
+			<PARAM name="src"
+				help="Source IP-address (ip) or interface name (ip and arp)"
+				ptype="STRING"/>
+		</PARAM>
 		<PARAM name="repeat"
-			help="Specify repeat count"
+			help="Requests to send count, default is 5"
 			optional="true"
 			mode="subcommand"
 			ptype="SUBCOMMAND">
 			<PARAM name="count"
-				help="Repeat count"
-				default="5"
+				help="Requests count"
 				ptype="UINT"/>
 		</PARAM>
+		<PARAM name="resolve"
+			test='"${proto}"!="arp"'
+			help="Resolve names"
+			optional="true"
+			mode="subcommand"
+			ptype="SUBCOMMAND"/>
+		<PARAM name="broadcast"
+			test='"${proto}"!="arp"'
+			help="Ping broadcast address"
+			optional="true"
+			mode="subcommand"
+			ptype="SUBCOMMAND"/>
 		<PARAM name="size"
-			help="Specify datagram size"
+			test='"${proto}"!="arp"'
+			help="Packet size"
 			optional="true"
 			mode="subcommand"
 			ptype="SUBCOMMAND">
 			<PARAM name="psize"
-				help="Datagram size"
+				help="Number of data bytes to send"
 				ptype="UINT"/>
 		</PARAM>
-		<PARAM name="source"
-			help="Specify source address or name"
+		<PARAM name="interval"
+			test='"${proto}"!="arp"'
+			help="The time interval between packets, default is 1"
 			optional="true"
 			mode="subcommand"
 			ptype="SUBCOMMAND">
-			<PARAM name="src"
-				help="Interface name or IP-address"
+			<PARAM name="period"
+				help="Interval between packets"
 				ptype="STRING"/>
 		</PARAM>
-		<PARAM name="packet_interval"
-			value="interval"
-			help="Specify interval between packets"
-			optional="true"
-			ptype="SUBCOMMAND">
-			<PARAM name="interval"
-				help="Interval beetween packets"
-				default="2"
-				ptype="UINT"/>
-		</PARAM>
 		<PARAM name="flood"
+			test='"${proto}"!="arp"'
 			help="Flood ping"
-			ptype="SUBCOMMAND"
+			optional="true"
 			mode="subcommand"
-			optional="true"/>
+			ptype="SUBCOMMAND"/>
+		<PARAM name="duplicate-detect"
+			test='"${proto}"="arp"'
+			help="Duplicate address detection mode"
+			optional="true"
+			mode="subcommand"
+			ptype="SUBCOMMAND"/>
 		<ACTION>
-		cmd="ping ${dst}"
-		# Resolve names
-		if [[ ! -n "${resolve}" ]]; then
-			cmd=$cmd" -n"
-		fi
-		# Ping broadcast
-		if [[ -n "${broadcast}" ]]; then
-			cmd=$cmd" -b"
-		fi
-		# Ping from interface or address
-		cmd=$cmd"${ -I :src}"
-		# Packets count
-		if [[ ! -n "${count}" ]]; then
-			cmd=$cmd" -c 5"
-		else
-			cmd=$cmd"${ -c :count}"
-		fi
-		# Packet size
-		cmd=$cmd"${ -s :psize}"
-		# Interval between packets
-		if [[ ! -n "${interval}" ]]; then
-			cmd=$cmd" -i 2"
-		else
-			cmd=$cmd"${ -i :interval}"
-		fi
-		# Flood ping
-		if [[ -n "${flood}" ]]; then
-			cmd=$cmd" -f"
-		fi
-		# Change it to exec or...
-		$cmd
+			case "${proto}" in
+				"ipv6")
+					cmd="ping6"
+					;;
+				"arp")
+					cmd="arping"
+					;;
+				*)
+					cmd="ping"
+					;;
+			esac
+			if test "${proto}" != "arp"; then
+				# Resolve names
+				if test -z "${resolve}"; then
+					cmd=$cmd" -n"
+				fi
+				# Ping broadcast
+				cmd=$cmd"`expr substr '${ -b :broadcast}' 1 3`"
+				# Packet size
+				cmd=$cmd"${ -s :psize}"
+				# Interval between packets 
+				if test -n "${period}"; then
+					cmd=$cmd"${ -i :period}"
+				else
+					cmd=$cmd" -i 1"
+				fi
+				# Flood ping
+				cmd=$cmd"`expr substr '${ -f :flood}' 1 3`"
+			else
+				# Detect MAC duplicate
+				cmd=$cmd"`expr substr '${ -D :duplicate-detect}' 1 3`"
+			fi
+			# Interface or address
+			cmd=$cmd"${ -I :src}"
+			# Request count
+			if test -z "${count}"; then
+				cmd=$cmd" -c 5"
+			else
+				cmd=$cmd"${ -c :count}"
+			fi
+			#
+			cmd=$cmd" ${dst}"
+			$cmd
 		</ACTION>
 	</COMMAND>
 
+<!-- traceroute, traceroute6 -->
 	<COMMAND name="traceroute"
-		help="Trace route to destination"
-		lock="false">
-		<PARAM name="ip"
-			help="IP trace"
-			ptype="STRING"
+		help="Print the route packets trace to network host">
+		<PARAM name="proto"
+			help="Protocol to use"
+			optional="true"
+			mode="switch"
+			ptype="SUBCOMMAND">
+			<PARAM name="ip"
+				help="IPv4"
+				mode="subcommand"
+				ptype="SUBCOMMAND"/>
+			<PARAM name="ipv6"
+				help="IPv6"
+				mode="subcommand"
+				ptype="SUBCOMMAND"/>
+		</PARAM>
+		<PARAM name="dst"
+			help="Hostname or IP-address to trace the route"
+			ptype="STRING"/>
+		<PARAM name="resolve"
+			help="Resolve names"
+			ptype="SUBCOMMAND"
 			mode="subcommand"
 			optional="true"/>
-		<PARAM name="addr"
-			help="Trace route to destination address or hostname"
-			ptype="STRING"/>
+		<PARAM name="source"
+			help="Source IP-address"
+			optional="true"
+			mode="subcommand"
+			ptype="SUBCOMMAND">
+			<PARAM name="src"
+				help="IP-address"
+				ptype="STRING"/>
+		</PARAM>
+		<PARAM name="interface"
+			help="Source interface"
+			optional="true"
+			mode="subcommand"
+			ptype="SUBCOMMAND">
+			<PARAM name="if"
+				help="Interface name"
+				ptype="STRING"/>
+		</PARAM>
 		<ACTION>
-		traceroute ${addr}
+			if test -n "${ipv6}"; then
+				cmd="traceroute6"
+			else
+				cmd="traceroute"
+			fi
+			#Resolve names
+			if test -z "${resolve}"; then
+				cmd=$cmd" -n"
+			fi
+			# Source address
+			cmd=$cmd"${ -s :src}"
+			# Source interface
+			cmd=$cmd"${ -i :if}"
+			#
+			cmd=$cmd" ${dst}"
+			$cmd
 		</ACTION>
 	</COMMAND>