about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-08-27 17:24:20 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-08-27 17:24:20 +0000
commit260b433632310e847b5c540f2812cc0856576273 (patch)
treeecf910a54c8c788bf838748acd738cc84459c6b0
parent9c49c8dd27cf0570703e39a11853f10bcf60fec1 (diff)
downloadzsh-260b433632310e847b5c540f2812cc0856576273.tar.gz
zsh-260b433632310e847b5c540f2812cc0856576273.tar.xz
zsh-260b433632310e847b5c540f2812cc0856576273.zip
Oliver (olipro): 30643: ipset completion update
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Linux/Command/_ipset162
2 files changed, 80 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog
index f3c91a44d..c7dbbecf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-08-27  Peter Stephenson  <p.w.stephenson@ntlworld. com>
+
+	* Oliver (olipro): 30643: Completion/Linux/Command/_ipset:
+	completion update.
+
 2012-08-25  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* John Stahara: 30641: Src/Zle/zle_keymap.c: bindkey -N
@@ -119,5 +124,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5711 $
+* $Revision: 1.5712 $
 *****************************************************
diff --git a/Completion/Linux/Command/_ipset b/Completion/Linux/Command/_ipset
index 7896eace7..0d6afc08e 100644
--- a/Completion/Linux/Command/_ipset
+++ b/Completion/Linux/Command/_ipset
@@ -5,159 +5,145 @@ local -a args from_to hash cmds listopts
 
 _set_types () {
 	_values -S \  "Set type" \
-		'ipmap[up to 65536 IP addresses]' \
-		'macipmap[up to 65536 IP addresses with MAC]' \
-		'portmap[up to 65536 ports]' \
-		'iphash[hash of IP addresses]' \
-		'nethash[hash of network addresses]' \
-		'ipporthash[hash of IP address and port pairs]' \
-		'ipportiphash[hash of IP address,port and IP address triples]' \
-		'ipportnethash[hash of IP address,port and network address triples]' \
-		'iptree[tree of IP addresses, optionally with timeout]' \
-		'iptreemap[tree of IP addresses or networks]' \
-		'setlist[list of sets]'
+		'bitmap\:ip[uses a memory range to store IPv4 host (default) or IPv4 subnet addresses up to 65536 elements]'\
+		'bitmap\:ip,mac[uses a memory range to store an IPv4 host/subnet and mac address pair up to 65536 elements]'\
+		'bitmap\:port[uses a memory range to store port numbers independent of L4 protocol at up to 65536 elements]'\
+		'hash\:ip[stores IPv4/IPv6 host/subnet addresses. 0.0.0.0 and :: cannot be stored]'\
+		'hash\:net[stores varying sizes of IPv4/IPv6 addresses. 0.0.0.0 and :: cannot be stored]'\
+		'hash\:ip,port[stores IPv4/IPv6 addresses and port numbers, including L4 proto - port 0 cannot be stored]'\
+		'hash\:net,port[stores varying sizes of IPv4/IPv6 addresses and port numbers, including L4 proto]'\
+		'hash\:ip,port,ip[stores IPv4/IPv6 addresses, a port with L4 proto and another IPv4/IPv6 address]'\
+		'hash\:ip,port,net[stores an IPv4/IPv6 address, port with L4 proto and an arbitrary size IPv4/IPv6 subnet]'\
+		'hash\:net,iface[stores an IPv4/IPv6 address and an interface name]'\
+		'list\:set[a simple list which stores names of other sets]'
 }
 
-if [[ $words[2] = (-q|--quiet) ]]; then
-	offset=1
-fi
+#if [[ $words[2] = (-q|--quiet) ]]; then
+#	offset=1
+#fi
 
 _ipsets () {
 	local -a vals
-	vals=( ${${(M)${(f)"$(_call_program ipsets ipset -nL)"}%Name: *}#Name: } )
+	vals=( ${${(M)${(f)"$(_call_program ipsets ipset -L)"}%Name: *}#Name: } )
 	_describe -t ipsets "IP sets" vals
 }
 _sets () {
 	_ipsets
 	local -a vals
-	case $words[offset+2]; in
-	  -X|--destroy)
-		vals=('\:all\::remove all not referenced sets')
-	  ;;
-	  -F|--flush)
-		vals=('\:all\::flush all sets')
-	  ;;
-	  -L|--list|-nL|-sL|-nsL|-snL|-n|-s|-ns|-sn)
-		vals=('\:all\::list all sets')
-	  ;;
-	  -S|--save)
-		vals=('\:all\::save all sets')
-	esac
-	_describe -t special_values "special values" vals
 }
 
 from_to=('(--network)--from[from IP or network (with --netmask)]:IP'
 	'(--network)--to[to IP or network (with --netmask)]:IP'
 	'(--from --to)--network[network]:IP/mask'
 )
-hash=(	'--hashsize[the initial hash size (default 1024)]:hash size'
-	'--probes[max number of tries to resolve clashing (default 8)]:probes'
-	'--resize[ratio of increasing hash size after unsuccessful <probes> number of double-hashing]:percent'
+
+_addressfamily () {
+	vals=(  inet
+	 	inet6
+	     )
+	_describe -t addressfamily "Address Family" vals
+}
+
+hash=(	'--hashsize[the initial hash size aligned to a power of 2(default 1024)]:hashsize'
+	'--maxelem[the maximum number of elements in the set (default 65536)]:maxelements'
+	'--family[the protocol family of addresses to be stored in the set (default inet)]:addressfamily:_addressfamily'
+	'--timeout[adds timeout support to the set with your specified value as default, (0 = forever)]:entrytimeout'
+	'--probes[max number of tries to resolve clashing, altering this is discouraged (default 8)]:probes'
+	'--resize[ratio of increasing hash size after unsuccessful <probes> of double-hashing, altering discouraged]:percent'
 )
 
 case $words[offset+2]; in
   -N|--create)
 	case $words[offset+4]; in
-	  ipmap)
-		args=(	$from_to
+	  bitmap\:ip)
+	  	args=(  $from_to
 			'--netmask[store network addresses instead of IP addresses]:CIDR'
 		)
 	  ;;
-	  macipmap)
-		args=(	$from_to
-			'--matchunset[always match IP addresses which could be stored in the set but are not]'
+	  bitmap\:ip,mac)
+	  	args=(  $from_to
+			'--netmask[store network addresses instead of IP addresses]:CIDR'
 		)
 	  ;;
-	  portmap)
-		args=(	'--from[from port]:port:_ports'
+	  bitmap\:port)
+	  	args=(	'--from[from port]:port:_ports'
 			'--to[to port]:port:_ports'
 		)
 	  ;;
-	  iphash)
-		args=(	$hash
+	  hash\:ip)
+	  	args=(  $hash
+			'--netmask[store network addresses instead of IP addresses]:CIDR'
+		)
+	  ;;
+	  hash\:net)
+	  	args=(	$hash  )
+	  ;;
+	  hash\:ip,port)
+	  	args=(	$hash
 			'--netmask[store network addresses instead of IP addresses]:CIDR'
 		)
 	  ;;
-	  nethash)
-		args=(	$hash )
+	  hash\:net,port)
+	  	args=(	$hash  )
 	  ;;
-	  ipporthash|ipportiphash|ipportnethash)
-		args=(	$from_to $hash )
+	  hash\:ip,port,ip)
+	  	args=(	$hash
+			'--netmask[store network addresses instead of IP addresses]:CIDR'
+		)
 	  ;;
-	  iptree)
-	  	args=(	'--timeout[timeout value for the entries in seconds (default 0)]:timeout' )
+	  hash\:ip,port,net)
+	  	args=(	$hash
+			'--netmask[store network addresses instead of IP addresses]:CIDR'
+		)
 	  ;;
-	  iptreemap)
-	  	args=(	'--gc[garbage collection inverval (default 300 seconds)]:timeout' )
+	  hash\:net,iface)
+	  	args=(	$hash  )
 	  ;;
-	  setlist)
-	  	args=(	'--size[size of the new setlist (default 8)]:size' )
+	  list\:set)
+	  	args=(	'--size[size of the new setlist (default 8)]:size'  )
 	  ;;
 	esac
   ;;
-  -T|--test)
-	args=(	'(-b --binding)'{-b,--binding}'[test whether '$words[offset+4]' points to the specified binding]:::_ipsets' )
-  ;;
-  -B|--bind)
-	args=(	'(-b --binding)'{-b,--binding}'[value of the binding]:::_ipsets' )
-  ;;
 esac
 
 _ips () {
 	if [[ $CURRENT -eq ((offset+4)) ]]; then
 		local ips=1 default
 		local -a vals vals1 vals2 bindings
-		vals=( ${${${(f)"$(_call_program ipsets ipset -nL $words[offset+3])"}[4,-1]}//\:/\\:} )
+		vals=( ${${${(f)"$(_call_program ipsets ipset -L $words[offset+3])"}[4,-1]}//\:/\\:} )
 		for i in $vals; do
 			if [[ $i = Default\ binding\\:* ]]; then default=${i#Default binding\\: }; continue; fi
-			if [[ $i = (Header\\:*|Members\\:) ]]; then continue; fi
+			if [[ $i = (Header\\:*|Members\\:*|Size in memory\\:*|References\\:*) ]]; then continue; fi
 			if [[ $i = 'Bindings\:' ]]; then ips=0; continue; fi
 			if (( $ips )); then vals1+=$i; else bindings+=${i/ ->/:}; fi
 		done
-		case $words[offset+2]; in
-		  -T|--test)
-			vals2=('\:default\::test default binding of the set for --binding')
-		  ;;
-		  -B|--binding)
-			vals2=('\:default\::set default binding of the set')
-		  ;;
-		  -U|--unbind)
-			vals1=()
-			vals2=('\:all\::destroy the bindings of all elements of a set')
-			if [[ -n "$default" ]]; then
-			vals2+=("\:default\::remove default binding of the set to '$default'")
-			fi
-			_describe -t ipb "IPs from $words[offset+3] set with bindings" bindings
-		  ;;
-		esac
 		_describe -t ips "IPs from $words[offset+3] set" vals1
 		_describe -t special_values "special values" vals2
 	fi
 }
 
-cmds=(-N -X -F -E -W -S -R -A -D -T -B -U -H --create --destroy --flush --rename --swap --save --restore --add --del --test --bind --unbind --help)
-listopts=(-n --numeric -s --sorted -L --list -nL -sL -nsL -snL -ns -sn)
+cmds=(-N -X -F -E -W -S -R -A -D -T -B -U -H --create --destroy --flush --rename --swap --save --restore --add --del --test --help)
+listopts=(-n --name -s --sorted -t --terse -r --resolve -L --list)
+addopts=(--timeout --timeout -! --exist -A --add)
 
 _arguments \
-	"($cmds $listopts)"{-N,--create}'[create a set]:set name::::_set_types' \
+	"($cmds $listopts $addopts)"{-N,--create}'[create a set]:set name::::_set_types' \
 	"($cmds $listopts)"{-X,--destroy}'[destroy specified set (or all if none specified)]:set name:_sets' \
 	"($cmds $listopts)"{-F,--flush}'[flush specified set (or all if none specified)]:set name:_sets' \
 	"($cmds $listopts)"{-E,--rename}'[rename set]:current set name:_ipsets:new set name:' \
 	"($cmds $listopts)"{-W,--swap}'[swap two sets]:::_ipsets:::_ipsets' \
-	"($cmds -L --list -q --quiet -nL -sL -nsL -snL)"{-L,--list}'[list the entries and bindings for the specified set (or all if none specified)]:::_sets' \
-	"($cmds -L --list -q --quiet -n --numeric -snL -nsL -sL -ns -sn)"-nL'[list the entries and bindings for the specified set (or all if none specified) \- numeric output]:::_sets' \
-	"($cmds -L --list -q --quiet -s --sorted  -snL -nsL -nL -ns -sn)"-sL'[list the entries and bindings for the specified set (or all if none specified) \- sorted output]:::_sets' \
-	"($cmds $listopts -q --quiet)"{-nsL,-snL}'[list the entries and bindings for the specified set (or all if none specified) \- sorted numeric output]:::_sets' \
+	"($cmds -L --list -q --quiet )"{-L,--list}'[list the entries and bindings for the specified set (or all if none specified)]:::_sets' \
 	"($cmds $listopts)"{-S,--save}'[save the given set (or all if none specified)]:::_sets' \
 	"($cmds $listopts)"{-R,--restore}'[restore a saved session generated by --save from stdin]' \
 	"($cmds $listopts)"{-A,--add}'[add an IP to a set]:::_ipsets:IP' \
 	"($cmds $listopts)"{-D,--del}'[delete an IP from a set]:::_ipsets:::_ips' \
-	"($cmds $listopts)"{-T,--test}'[test wether an IP is in a set or the IP points to the specified binding]:::_ipsets:::_ips' \
-	"($cmds $listopts)"{-B,--bind}'[bind the IP in setname to to-setname]:::_ipsets:::_ips' \
-	"($cmds $listopts)"{-U,--unbind}'[delete the binding belonging to IP in set setname]:::_ipsets:::_ips' \
+	"($cmds $listopts)"{-T,--test}'[test whether an IP is in a set]:::_ipsets:::_ips' \
 	"($cmds $listopts)"{-H,--help}'[print help and settype specific help if settype specified]:::_set_types' \
 	"(-q --quiet $listopts)"{-q,--quiet}'[suppress any output to stdout and stderr]' \
-	"($cmds -s --sorted  -q --quiet -sL -nsL -snL -ns -sn)"{-s,--sorted}'[sorted output]' \
-	"($cmds -n --numeric -q --quiet -nL -nsL -snL -ns -sn)"{-n,--numeric}"[numeric output; don't resolve host names, network names and services]" \
-	"($cmds -ns -sn  -q --quiet -nL -sL -nsL -snL -n --numeric -s --sorted)"{-ns,-sn}'[sorted numeric output]' \
+	"(-t --terse $listopts)"{-t,--terse}'[list set names and headers without entries]' \
+	"(-r --resolve $listopts)"{-r,--resolve}'[enforce DNS name lookup of addresses, slow!]' \
+	"(-! --exist $addopts)"{-!,--exist}'[ignore errors when creating an identical set, adding existing entry or deleting a non-existent one]'\
+	"(--timeout --timeout $addopts)"{--timeout,--timeout}'[set the timeout for this entry. set must have been created with timeout support]:timeout'\
+	"($cmds -s --sorted  -q --quiet)"{-s,--sorted}'[sorted output]' \
+	"($cmds -n --name -q --quiet)"{-n,--name}"[name output only; suppresses showing of set information]" \
 	"$args[@]"