From 512b3ba9bb4422c10ae45fdc460500255cd5d4e9 Mon Sep 17 00:00:00 2001 From: lakinduakash Date: Fri, 12 Apr 2019 18:50:48 +0530 Subject: [PATCH] Don't change frequency band automatically if set by manually --- src/scripts/create_ap | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/scripts/create_ap b/src/scripts/create_ap index 20663a7..5bee73f 100755 --- a/src/scripts/create_ap +++ b/src/scripts/create_ap @@ -345,19 +345,19 @@ is_5ghz_frequency() { [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})$ ]] } -#is_wifi_connected() { -# if [[ $USE_IWCONFIG -eq 0 ]]; then -# iw dev "$1" link 2>&1 | grep -E '^Connected to' > /dev/null 2>&1 && return 0 -# else -# iwconfig "$1" 2>&1 | grep -E 'Access Point: [0-9a-fA-F]{2}:' > /dev/null 2>&1 && #return 0 -# fi -# return 1 -#} - is_wifi_connected() { + if [[ $USE_IWCONFIG -eq 0 ]]; then + iw dev "$1" link 2>&1 | grep -E '^Connected to' > /dev/null 2>&1 && return 0 + else + iwconfig "$1" 2>&1 | grep -E 'Access Point: [0-9a-fA-F]{2}:' > /dev/null 2>&1 && return 0 + fi return 1 } +#is_wifi_connected() { +# return 1 +#} + is_macaddr() { echo "$1" | grep -E "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" > /dev/null 2>&1 } @@ -629,6 +629,7 @@ VHT_CAPAB= DRIVER=nl80211 NO_VIRT=0 COUNTRY= +FREQ_BAND_SET=0 FREQ_BAND=2.4 NEW_MACADDR= DAEMONIZE=0 @@ -1136,6 +1137,7 @@ while :; do --freq-band) shift FREQ_BAND="$1" + FREQ_BAND_SET=1 shift ;; --mac) @@ -1531,7 +1533,8 @@ if [[ $NO_VIRT -eq 0 ]]; then echo "DONE" fi - if is_wifi_connected ${WIFI_IFACE}; then + + if is_wifi_connected ${WIFI_IFACE} && [[ $FREQ_BAND_SET -eq 0 ]]; then WIFI_IFACE_FREQ=$(iw dev ${WIFI_IFACE} link | grep -i freq | awk '{print $2}') WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel ${WIFI_IFACE_FREQ}) echo -n "${WIFI_IFACE} is already associated with channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)" @@ -1542,12 +1545,16 @@ if [[ $NO_VIRT -eq 0 ]]; then fi if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then echo ", fallback to channel ${WIFI_IFACE_CHANNEL}" - #CHANNEL=$WIFI_IFACE_CHANNEL + CHANNEL=$WIFI_IFACE_CHANNEL else - echo + echo "channel------------------ ${CHANNEL}" fi + elif is_wifi_connected ${WIFI_IFACE} && [[ $FREQ_BAND_SET -eq 1 ]]; then + echo "Custom frequency band set with ${FREQ_BAND}Mhz with channel ${CHANNEL}" fi + + VIRTDIEMSG="Maybe your WiFi adapter does not fully support virtual interfaces. Try again with --no-virt." echo -n "Creating a virtual WiFi interface... "