# Check if the device is a loopback device
function device_is_loopback() {
- local device=$(devicify ${1})
+ local device=${1}
+
[ "${device}" = "lo" ]
}
# Get the device type
function device_get_type() {
- local device=$(devicify ${1})
+ local device=${1}
if device_is_virtual ${device}; then
echo "vlan"
# Check if a device has a cable plugged in
function device_has_carrier() {
- local device=$(devicify ${1})
+ local device=${1}
+ assert isset device
+
[ "$(<${SYS_CLASS_NET}/${device}/carrier)" = "1" ]
}
# Check if the device is used
function device_is_used() {
- local device=$(devicify ${1})
+ local device=${1}
device_has_virtuals ${device} && \
return ${EXIT_OK}
# Set device up
function device_set_up() {
- local device=$(devicify ${1})
+ local device=${1}
# Silently fail if device was not found
[ -z "${device}" ] && return ${EXIT_ERROR}
# Set device down
function device_set_down() {
- local device=$(devicify ${1})
+ local device=${1}
+ assert isset device
local ret=${EXIT_OK}