esac
}
+function _network_dhcpd() {
+ local proto="${1}"
+ shift
+
+ local words=( $@ )
+
+ local commands="edit reload restart show start stop subnet"
+ 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
+ subnet)
+ _network_dhcpd_subnet "${proto}" ${args}
+ ;;
+ esac
+}
+
+function _network_dhcpd_subnet() {
+ local proto="${1}"
+ shift
+
+ local words=( $@ )
+
+ local commands="new remove show $(network raw list-dhcpd-subnets "${proto}")"
+ local cmd="$(_network_find_on_cmdline "${commands}")"
+ if [[ -z "${cmd}" ]]; then
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+ return 0
+ fi
+
+ local subnet="${words[0]}"
+ local args="${words[@]:1}"
+ case "${cmd}" in
+ new)
+ : # TODO
+ ;;
+ remove)
+ : # TODO
+ ;;
+ [0-9]*)
+ _network_dhcpd_subnet_subcommand "${proto}" "${subnet}" ${args}
+ ;;
+ esac
+}
+
+function _network_dhcpd_subnet_subcommand() {
+ local proto="${1}"
+ local subnet="${2}"
+ shift 2
+
+ local words=( $@ )
+
+ local commands="edit options range 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
+ edit)
+ : # TODO
+ ;;
+ options)
+ _network_dhcpd_subnet_subcommand_options "${proto}" "${subnet}" ${args}
+ ;;
+ range)
+ _network_dhcpd_subnet_subcommand_range "${proto}" "${subnet}" ${args}
+ ;;
+ esac
+}
+
+function _network_dhcpd_subnet_subcommand_options() {
+ local proto="${1}"
+ local subnet="${2}"
+ shift 2
+
+ local options option
+ for option in $(network raw list-dhcpd-subnet-options "${proto}"); do
+ options="${options} ${option}="
+ done
+
+ COMPREPLY=( $(compgen -W "${options}" -- "${cur}") )
+}
+
+function _network_dhcpd_subnet_subcommand_range() {
+ local proto="${1}"
+ local subnet="${2}"
+ shift 2
+
+ local words=( $@ )
+
+ local commands="new remove"
+ local cmd="$(_network_find_on_cmdline "${commands}")"
+ if [[ -z "${cmd}" ]]; then
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+ return 0
+ fi
+
+ case "${cmd}" in
+ new)
+ COMPREPLY=( $(compgen -W "--end= --start=" -- "${cur}") )
+ ;;
+ remove)
+ COMPREPLY=( $(compgen -W "$(network raw list-dhcpd-ranges-of-subnet "${proto}" "${subnet}")" \
+ -- "${cur}") )
+ ;;
+ esac
+}
+
function _network_dns_server() {
local words=( $@ )
COMPREPLY=( $(compgen -W "--debug" -- "${cur}") )
;;
*)
- COMPREPLY=( $(compgen -W "device dns-server help hostname \
- port reset route settings status zone" -- "${cur}") )
+ COMPREPLY=( $(compgen -W "device dhcpv4 dhcpv6 dns-server \
+ help hostname port reset route settings status zone" \
+ -- "${cur}") )
;;
esac
device)
_network_device ${args}
;;
+ dhcpv[64])
+ _network_dhcpd "${cmd/dhcpv/ipv}" ${args}
+ ;;
dns-server)
_network_dns_server ${args}
;;
cli_headline $(( ${level} + 2 )) "Options"
local option
- for option in $(dhcpd_subnet_options ${proto}); do
+ for option in $(dhcpd_subnet_options_list ${proto}); do
[ -n "${options[${option}]}" ] || continue
cli_print_fmt1 $(( ${level} + 2 )) \
cli_space
}
-function cli_dhcpd_options() {
+function cli_dhcpd_subnet_options() {
local proto=${1}
assert isset proto
shift
assert isset subnet_id
shift
- local valid_options=$(dhcpd_subnet_options ${proto})
-
local key val
while [ $# -gt 0 ]; do
case "${1}" in
list-devices)
device_list
;;
+ list-dhcpd-ranges-of-subnet)
+ dhcpd_subnet_range_list $@
+ ;;
+ list-dhcpd-settings)
+ dhcpd_global_settings_list $@
+ ;;
+ list-dhcpd-subnets)
+ dhcpd_subnet_list $@
+ ;;
+ list-dhcpd-subnet-options)
+ dhcpd_subnet_options_list $@
+ ;;
list-dns-servers)
dns_server_list
;;