]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/network
Remove remains of the "real" device type
[people/stevee/network.git] / src / network
old mode 100755 (executable)
new mode 100644 (file)
index a0f393a..81bb3bb
@@ -35,20 +35,20 @@ done
 
 . /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
 }
 
@@ -73,6 +73,9 @@ function cli_device() {
                discover)
                        cli_device_discover ${device} $@
                        ;;
+               monitor)
+                       cli_device_monitor "${device}" $@
+                       ;;
                status)
                        cli_device_status ${device}
                        ;;
@@ -125,17 +128,20 @@ function cli_device_status() {
 
        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})"
@@ -233,8 +239,8 @@ function cli_device_discover() {
        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
 
@@ -421,6 +427,19 @@ function cli_device_send_ussd_command() {
        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
@@ -454,22 +473,9 @@ function cli_port() {
                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}"
@@ -481,7 +487,7 @@ function cli_port() {
                shift
 
                case "${action}" in
-                       create|destroy)
+                       new|destroy)
                                port_${action} $@
                                ;;
                        *)
@@ -508,7 +514,7 @@ function cli_zone() {
 
                # Action aliases
                case "${action}" in
-                       start)
+                       start|reload)
                                action="up"
                                ;;
                        stop)
@@ -1039,7 +1045,7 @@ function cli_reset() {
 
        local port
        for port in $(ports_get --all); do
-               port_remove ${port}
+               port_destroy "${port}"
        done
 
        # Flush all DNS servers.
@@ -1138,7 +1144,7 @@ case "${action}" in
                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} $@
                ;;