. /usr/lib/network/functions
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
-function cli_config() {
+function cli_settings() {
if cli_help_requested $@; then
- cli_show_man network-config
+ cli_show_man network-settings
exit ${EXIT_OK}
fi
if [ -n "${1}" ]; then
- config_set $@
- network_config_write
+ settings_set $@
+ network_settings_write
else
- network_config_print
+ network_settings_print
fi
}
discover)
cli_device_discover ${device} $@
;;
+ monitor)
+ cli_device_monitor "${device}" $@
+ ;;
status)
cli_device_status ${device}
;;
cli_print_fmt1 1 "Status" "${status}"
cli_print_fmt1 1 "Type" "${type}"
+
+ # Ethernet-compatible?
+ device_is_ethernet_compatible "${device}" &>/dev/null
+ cli_print_fmt1 1 "Ethernet-compatible" "$(cli_print_bool $?)"
+
cli_print_fmt1 1 "Address" "$(device_get_address ${device})"
cli_space
# Print the link speed for ethernet devices.
if device_is_up ${device} &>/dev/null; then
- case "${type}" in
- ethernet)
- cli_print_fmt1 1 "Link" \
- "$(device_get_speed ${device}) MBit/s $(device_get_duplex ${device}) duplex"
- ;;
- esac
+ local link="$(device_get_link_string "${device}")"
+ if isset link; then
+ cli_print_fmt1 1 "Link" "${link}"
+ fi
fi
cli_print_fmt1 1 "MTU" "$(device_get_mtu ${device})"
local device=${1}
shift
- local device_type=$(device_get_type ${device})
- if [ "${device_type}" != "real" ]; then
+ # This can only be executed for ethernet (or compatible) devices
+ if ! device_is_ethernet_compatible "${device}"; then
return ${EXIT_OK}
fi
exit $?
}
+function cli_device_monitor() {
+ local device="${1}"
+ assert isset device
+
+ if ! device_is_wireless "${device}"; then
+ error "This action only works with wireless devices. Exiting."
+ exit ${EXIT_ERROR}
+ fi
+
+ wireless_monitor "${device}"
+ exit $?
+}
+
function cli_hostname() {
if cli_help_requested $@; then
cli_show_man network
action=${2}
shift 2
- # Action aliases
- case "${action}" in
- start)
- action="up"
- ;;
- stop)
- action="down"
- ;;
- show)
- action="status"
- ;;
- esac
-
case "${action}" in
- edit|up|down|status)
- port_${action} ${port} $@
+ edit|create|remove|up|down|status)
+ port_${action} "${port}" $@
;;
*)
error "Unrecognized argument: ${action}"
shift
case "${action}" in
- create|destroy)
+ new|destroy)
port_${action} $@
;;
*)
# Action aliases
case "${action}" in
- start)
+ start|reload)
action="up"
;;
stop)
local port
for port in $(ports_get --all); do
- port_remove ${port}
+ port_destroy "${port}"
done
# Flush all DNS servers.
init_run
;;
- config|hostname|port|device|zone|start|stop|restart|status|reset|route)
+ settings|hostname|port|device|zone|start|stop|restart|status|reset|route)
cli_${action} $@
;;