Some drivers still use the old WiFi subsystem, use iwconfig/iwlist in these cases
Fixes #43
This commit is contained in:
parent
6252e6fd88
commit
309b56f5fc
41
create_ap
41
create_ap
@ -76,6 +76,17 @@ version_cmp() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
USE_IWCONFIG=0
|
||||||
|
|
||||||
|
is_wifi_interface() {
|
||||||
|
which iw > /dev/null 2>&1 && iw dev $1 info > /dev/null 2>&1 && return 0
|
||||||
|
if which iwconfig > /dev/null 2>&1 && iwconfig $1 > /dev/null 2>&1; then
|
||||||
|
USE_IWCONFIG=1
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
get_phy_device() {
|
get_phy_device() {
|
||||||
for x in /sys/class/ieee80211/*; do
|
for x in /sys/class/ieee80211/*; do
|
||||||
[[ ! -d "$x" ]] && continue
|
[[ ! -d "$x" ]] && continue
|
||||||
@ -103,12 +114,19 @@ get_adapter_info() {
|
|||||||
can_transmit_to_channel() {
|
can_transmit_to_channel() {
|
||||||
IFACE=$1
|
IFACE=$1
|
||||||
CHANNEL=$2
|
CHANNEL=$2
|
||||||
CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep "MHz \[${CHANNEL}\]")
|
|
||||||
|
|
||||||
[[ -z "${CHANNEL_INFO}" ]] && return 1
|
if [[ $USE_IWCONFIG -eq 0 ]]; then
|
||||||
[[ "${CHANNEL_INFO}" == *no\ IR* ]] && return 1
|
CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep "MHz \[${CHANNEL}\]")
|
||||||
[[ "${CHANNEL_INFO}" == *disabled* ]] && return 1
|
[[ -z "${CHANNEL_INFO}" ]] && return 1
|
||||||
return 0
|
[[ "${CHANNEL_INFO}" == *no\ IR* ]] && return 1
|
||||||
|
[[ "${CHANNEL_INFO}" == *disabled* ]] && return 1
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
CHANNEL=$(printf '%02d' ${CHANNEL})
|
||||||
|
CHANNEL_INFO=$(iwlist ${IFACE} channel | grep "Channel ${CHANNEL} :")
|
||||||
|
[[ -z "${CHANNEL_INFO}" ]] && return 1
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_macaddr() {
|
get_macaddr() {
|
||||||
@ -364,11 +382,20 @@ fi
|
|||||||
|
|
||||||
WIFI_IFACE=$1
|
WIFI_IFACE=$1
|
||||||
|
|
||||||
if ! iw dev ${WIFI_IFACE} info > /dev/null 2>&1; then
|
if ! is_wifi_interface ${WIFI_IFACE}; then
|
||||||
echo "ERROR: ${WIFI_IFACE} is not a WiFi interface" >&2
|
echo "ERROR: '${WIFI_IFACE}' is not a WiFi interface" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $NO_VIRT -eq 0 && $USE_IWCONFIG -eq 1 ]]; then
|
||||||
|
NO_VIRT=1
|
||||||
|
if which iw > /dev/null 2>&1; then
|
||||||
|
echo "'iw' can not recognize your adapter, virtual interface can not be created" >&2
|
||||||
|
else
|
||||||
|
echo "'iw' is not installed, virtual interface can not be created" >&2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$SHARE_METHOD" != "nat" && "$SHARE_METHOD" != "bridge" && "$SHARE_METHOD" != "none" ]]; then
|
if [[ "$SHARE_METHOD" != "nat" && "$SHARE_METHOD" != "bridge" && "$SHARE_METHOD" != "none" ]]; then
|
||||||
echo "ERROR: Wrong Internet sharing method" >&2
|
echo "ERROR: Wrong Internet sharing method" >&2
|
||||||
echo
|
echo
|
||||||
|
Loading…
Reference in New Issue
Block a user