Fixed InterfaceUtils bug & refactored WI check.

Fixed a bug caused by lingering hex markers from device descriptors.
Refactored wireless interface checking for future extensibility.
This commit is contained in:
Matias Barcenas 2017-08-30 15:55:16 -05:00
parent 8d0c786d3c
commit 9944355832
1 changed files with 11 additions and 1 deletions

View File

@ -24,12 +24,19 @@ function interface_list_wireless() {
interface_list_all interface_list_all
local __interface_list_wireless__candidate local __interface_list_wireless__candidate
for __interface_list_wireless__candidate in "${InterfaceListAll[@]}"; do for __interface_list_wireless__candidate in "${InterfaceListAll[@]}"; do
if grep -qs "DEVTYPE=wlan" /sys/class/net/$__interface_list_wireless__candidate/uevent if interface_wireless $__interface_list_wireless__candidate
then InterfaceListWireless+=("$__interface_list_wireless__candidate") then InterfaceListWireless+=("$__interface_list_wireless__candidate")
fi fi
done done
} }
function interface_wireless() {
if grep -qs "DEVTYPE=wlan" /sys/class/net/$1/uevent
then return 0
else return 1
fi
}
function interface_driver() { function interface_driver() {
InterfaceDriver=$(basename $(readlink /sys/class/net/$1/device/driver)) InterfaceDriver=$(basename $(readlink /sys/class/net/$1/device/driver))
} }
@ -76,6 +83,9 @@ function interface_hardware() {
unset InterfaceHardwareID unset InterfaceHardwareID
unset InterfaceHardwareBus unset InterfaceHardwareBus
return 2 return 2
else
# Remove any extraneous hex markers.
InterfaceHardwareID=${InterfaceHardwareID//0x/}
fi fi
} }