]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/bash-completion/network
ipsec: security polices: Make cipher command plural
[people/ms/network.git] / src / bash-completion / network
index 820c2d41929f6c86bf6f0d356050e7b6ce858573..33bf456e56f45a5009e7b9d1c840b9faa0930e30 100644 (file)
@@ -340,6 +340,289 @@ _network_settings() {
        COMPREPLY=( $(compgen -W "${keys}" -- "${cur}") )
 }
 
+_network_vpn() {
+       local words=( $@ )
+
+       local commands="ipsec security-policies"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               ipsec)
+                       _network_vpn_ipsec ${args}
+                       ;;
+               security-policies)
+                       _network_vpn_security_policies ${args}
+                       ;;
+               esac
+}
+
+_network_vpn_ipsec() {
+       local words=( $@ )
+
+       local commands="connection"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               connection)
+                       _network_vpn_ipsec_connection ${args}
+                       ;;
+               esac
+}
+
+_network_vpn_ipsec_connection() {
+       local words=( $@ )
+
+       local commands="destroy new $(network raw list-ipsec-connections)"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               destroy)
+                       :
+                       ;;
+               new)
+                       :
+                       ;;
+               *)
+                       if network raw ipsec-connection-exists ${cmd}; then
+                               _network_vpn_ipsec_connection_subcommands ${cmd} ${args}
+                       fi
+                       ;;
+               esac
+}
+
+_network_vpn_ipsec_connection_subcommands() {
+       local connection=${1}
+       shift
+       local words=( $@ )
+
+       local commands="authentication color description down inactivity-timeout local mode peer remote security-policy show up"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               authentication)
+                       _network_vpn_ipsec_connection_subcommands_authentication ${connection} ${args}
+                       ;;
+               color)
+                       _network_color ${args}
+                       ;;
+               description)
+                       _network_description ${args}
+                       ;;
+               local)
+                       _network_vpn_ipsec_connection_subcommands_local_remote ${connection} "local" ${args}
+                       ;;
+               mode)
+                       _network_vpn_ipsec_connection_subcommands_mode ${args}
+                       ;;
+               remote)
+                       _network_vpn_ipsec_connection_subcommands_local_remote ${connection} "remote" ${args}
+                       ;;
+               security-policy)
+                       _network_vpn_ipsec_connection_subcommands_security_policy ${args}
+                       ;;
+               esac
+}
+
+_network_vpn_ipsec_connection_subcommands_authentication() {
+       local connection=${1}
+       shift
+       local words=( $@ )
+
+       local commands="mode pre-shared-key"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               mode)
+                       _network_vpn_ipsec_connection_subcommands_authentication_mode ${connection} ${args}
+                       ;;
+                       esac
+}
+
+_network_vpn_ipsec_connection_subcommands_local_remote() {
+       local connection=${1}
+       local type=${2}
+       shift 2
+       local words=( $@ )
+
+       local commands="id prefix"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               prefix)
+                       _network_vpn_ipsec_connection_subcommands_prefix "${connection}" "${type}" ${args}
+                       ;;
+                       esac
+}
+
+_network_vpn_ipsec_connection_subcommands_prefix() {
+       :
+}
+
+_network_vpn_ipsec_connection_subcommands_authentication_mode() {
+       local connection=${1}
+       shift
+       local words=( $@ )
+
+       local commands="PSK"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+}
+
+_network_vpn_ipsec_connection_subcommands_mode() {
+       local words=( $@ )
+
+       local commands="gre-transport tunnel vti"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+}
+
+_network_vpn_ipsec_connection_subcommands_security_policy() {
+       local words=( $@ )
+
+       local commands="$(network raw list-vpn-security-policies-all)"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+}
+
+_network_vpn_security_policies() {
+       local words=( $@ )
+
+       local commands="destroy new $(network raw list-vpn-security-policies-all)"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               destroy)
+                       :
+                       ;;
+               new)
+                       :
+                       ;;
+               *)
+                       if network raw vpn-security-policy-exists ${cmd}; then
+                               _network_vpn_security_policies_subcommands ${cmd} ${args}
+                       fi
+                       ;;
+               esac
+}
+
+_network_vpn_security_policies_subcommands() {
+       local policy=${1}
+       shift
+       local words=( $@ )
+
+       local commands="ciphers compression group-type integrity key-exchange lifetime pfs pseudo-random-functions show"
+       local cmd="$(_network_find_on_cmdline "${commands}")"
+       if [[ -z "${cmd}" ]]; then
+               COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+               return 0
+       fi
+
+
+       local args="${words[@]:1}"
+       case "${cmd}" in
+               ciphers)
+                       _network_vpn_security_policies_subcommands_ciphers ${policy} ${args}
+                       ;;
+               compression)
+                       _network_vpn_security_policies_subcommands_compression ${policy} ${args}
+                       ;;
+               group-type)
+                       _network_vpn_security_policies_subcommands_group_type ${policy} ${args}
+                       ;;
+               integrity)
+                       _network_vpn_security_policies_subcommands_integrity ${policy} ${args}
+                       ;;
+               pseudo-random-functions)
+                       _network_vpn_security_policies_subcommands_pseudo_random_functions "${policy}" "${args}"
+                       ;;
+               key-exchange)
+                       _network_vpn_security_policies_subcommands_key_exchange ${policy} ${args}
+                       ;;
+               pfs)
+                       _network_vpn_security_policies_subcommands_pfs ${policy} ${args}
+                       ;;
+               esac
+}
+
+_network_vpn_security_policies_subcommands_ciphers() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_compression() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_group_type() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_integrity() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_pseudo_random_functions() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_key_exchange() {
+       :
+}
+
+_network_vpn_security_policies_subcommands_pfs() {
+       :
+}
+
 _network_zone() {
        local words=( $@ )
 
@@ -421,7 +704,7 @@ _network_zone_subcommand_config() {
 
        local words=( $@ )
 
-       local commands="destroy list new $(network raw list-zone-config-ids ${zone})"
+       local commands="destroy list new $(network raw list-zone-config-hids ${zone})"
 
        local cmd="$(_network_find_on_cmdline "${commands}")"
        if [[ -z "${cmd}" ]]; then
@@ -437,12 +720,8 @@ _network_zone_subcommand_config() {
                destroy)
                        _network_zone_subcommand_config_destroy ${zone} ${args}
                        ;;
-               # We use no better globbing like [:digit:] here because hids would not match the glob
-               # Also bash is silly here and does not unterstand things like ^[[:digit:]]+$ here.
                *)
-                       # Check if we get a valid id
-                       # TODO: We should also accept a valid hid
-                       if network raw zone-config-id-is-valid ${zone} ${cmd}; then
+                       if network raw zone-config-id-is-valid ${zone} ${cmd} || network raw zone-config-hid-is-valid ${zone} ${cmd}; then
                                _network_zone_subcommand_config_subcommand ${zone} ${args}
                        fi
                        ;;
@@ -547,7 +826,7 @@ _network() {
                                ;;
                        *)
                                COMPREPLY=( $(compgen -W "device dhcpv4 dhcpv6 dns-server \
-                                       help hostname port reset route settings status zone" \
+                                       help hostname port reset route settings status vpn zone" \
                                        -- "${cur}") )
                                ;;
                esac
@@ -579,6 +858,9 @@ _network() {
                        # start, stop and status optionally take a zone
                        _network_complete_zones
                        ;;
+               vpn)
+                       _network_vpn ${args}
+                       ;;
                zone)
                        _network_zone ${args}
                        ;;