diff --git a/lq-wave-300_5_x/files/lib/netifd/wireless/iopsys_utils.sh b/lq-wave-300_5_x/files/lib/netifd/wireless/iopsys_utils.sh index 3fb294985247842c2d68a15f4f8589c6057a1cb3..647430267a828fd9e53e906b8658a7adc9df93b2 100755 --- a/lq-wave-300_5_x/files/lib/netifd/wireless/iopsys_utils.sh +++ b/lq-wave-300_5_x/files/lib/netifd/wireless/iopsys_utils.sh @@ -94,3 +94,92 @@ wifi_generate_ifname() { } done } + +remove_from_networks() { + local iface=$1 + local ifname="" + + for net in $(uci show network | grep network.*.interface | awk -F'[.,=]' '{print$2}' | tr '\n' ' '); do + ifname="" + for ifc in $(uci -q get network.$net.ifname); do + if [ "$ifc" != "$iface" ]; then + ifname="$ifname $ifc" + fi + done + uci -q set network.$net.ifname="$(echo $ifname | sed 's/[ \t]*$//')" + uci commit network + done +} + +remove_disabled_vifs() { + local cfg=$1 + local vif=$2 + + config_get is_lan $cfg is_lan "0" + config_get type $cfg type + + [ "$is_lan" == "0" -o "$type" != "bridge" ] && return + + ifname=$(uci -q get network.$cfg.ifname) + + for ifc in $ifname; do + [ -n "${ifc/wlan*/}" ] && continue + + vif_cfg=$(uci show wireless | grep @wifi-iface | grep "ifname=\'$ifc\'" | awk -F '.' '{print $2}') + + device=$(uci -q get wireless.$vif_cfg.device) + radio_disabled=$(uci -q get wireless.$device.disabled) + disabled=$(uci -q get wireless.$vif_cfg.disabled) + net=$(uci -q get wireless.$vif_cfg.network) + [ "$disabled" == "1" -o "$net" != "$cfg" -o "$radio_disabled" == "1" -o -z "$vif_cfg" ] || continue + + remove_from_networks $ifc + done +} + +network_remove_disabled_vifs() { + config_load network + config_foreach remove_disabled_vifs interface +} + +add_to_network() { + local cfg=$1 + local nets=$2 + local iface="" + local ifname="" + + config_get network $cfg network + config_get iface $cfg ifname + config_get disabled $cfg disabled "0" + + [ -n "$iface" ] || return + + [ "$disabled" == "1" ] && return + + config_get device $cfg device + radio_disabled=$(uci -q get wireless.$device.disabled) + [ "$radio_disabled" == "1" ] && return + + for net in $nets; do + is_lan="$(uci -q get network.$net.is_lan)" + is_lan=${is_lan:-0} + type="$(uci -q get network.$net.type)" + + [ "$is_lan" == "1" -a "$type" == "bridge" ] || continue + + ifname="$(uci -q get network.$net.ifname)" + if [ "$net" == "$network" ]; then + ifname="$ifname $iface" + fi + + uci -q set network.$net.ifname="$(echo $ifname | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/[ \t]*$//')" + done + uci commit network +} + +network_add_vifs() { + nets=$(uci show network | grep network.*.interface | awk -F'[.,=]' '{print$2}') + + config_load wireless + config_foreach add_to_network wifi-iface "$nets" +} \ No newline at end of file diff --git a/lq-wave-300_5_x/files/lib/wifi/intel.sh b/lq-wave-300_5_x/files/lib/wifi/intel.sh index 823d92d211a27c445446fdc122acb7bcf5e518ef..07291383a3793ec6fc527f8d1801b169af5dafce 100755 --- a/lq-wave-300_5_x/files/lib/wifi/intel.sh +++ b/lq-wave-300_5_x/files/lib/wifi/intel.sh @@ -188,17 +188,4 @@ EOF detect_intel_interfaces $dev $radioname $ifidx devidx=$(($devidx + 1)) done -} - -config_load network -for radio in wlan0 wlan2; do - config_foreach remove_disabled_vifs interface $radio - - for idx in 1 2 3 4; do - vif="$radio.$idx" - config_foreach remove_disabled_vifs interface $vif - done -done - -config_load wireless -config_foreach add_to_network wifi-iface \ No newline at end of file +} \ No newline at end of file diff --git a/lq-wave-300_5_x/files/lib/wifi/iopsys_wifi_addons.sh b/lq-wave-300_5_x/files/lib/wifi/iopsys_wifi_addons.sh index c70b433e8bcce5169bb6b4cad195c7fb6bc759cf..eb72676fc7bf65e20f9344983c90712d42df221e 100755 --- a/lq-wave-300_5_x/files/lib/wifi/iopsys_wifi_addons.sh +++ b/lq-wave-300_5_x/files/lib/wifi/iopsys_wifi_addons.sh @@ -1,83 +1,5 @@ #!/bin/sh -remove_from_networks() { - local iface=$1 - local ifname="" - - for net in $(uci show network | grep network.*.interface | awk -F'[.,=]' '{print$2}' | tr '\n' ' '); do - ifname="" - for ifc in $(uci -q get network.$net.ifname); do - if [ "$ifc" != "$iface" ]; then - ifname="$ifname $ifc" - fi - done - uci -q set network.$net.ifname="$(echo $ifname | sed 's/[ \t]*$//')" - uci commit network - done -} - -remove_disabled_vifs() { - local cfg=$1 - local vif=$2 - - config_load network - config_get is_lan $cfg is_lan "0" - config_get type $cfg type - - [ "$is_lan" == "0" -o "$type" != "bridge" ] && return - - ifname=$(uci -q get network.$cfg.ifname) - - for ifc in $ifname; do - vif_cfg=$(uci show wireless | grep @wifi-iface | grep "ifname=\'$ifc\'" | awk -F '.' '{print $2}') - - device=$(uci -q get wireless.$vif_cfg.device) - radio_disabled=$(uci -q get wireless.$device.disabled) - disabled=$(uci -q get wireless.$vif_cfg.disabled) - net=$(uci -q get wireless.$vif_cfg.network) - [ "$disabled" == "1" -o "$net" != "$cfg" -o "$radio_disabled" == "1" ] || continue - - if [ $ifc == $vif ]; then - #echo "wifi: remove $ifc from $interface" >/dev/console - remove_from_networks $interface $ifc - break - fi - done -} - -add_to_network() { - local cfg=$1 - local iface="" - local ifname="" - - config_get network $cfg network - config_get iface $cfg ifname - config_get disabled $cfg disabled "0" - - [ "$disabled" == "1" ] && return - - config_get device $cfg device - radio_disabled=$(uci -q get wireless.$device.disabled) - [ "$radio_disabled" == "1" ] && return - - for net in $(uci show network | grep network.*.interface | awk -F'[.,=]' '{print$2}'); do - is_lan="$(uci -q get network.$net.is_lan)" - is_lan=${is_lan:-0} - type="$(uci -q get network.$net.type)" - - - [ "$is_lan" == "1" -a "$type" == "bridge" ] || continue - - ifname="$(uci -q get network.$net.ifname)" - if [ "$net" == "$network" ]; then - ifname="$ifname $iface" - fi - - uci -q set network.$net.ifname="$(echo $ifname | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/[ \t]*$//')" - done - uci commit network -} - wifi_add_section_status() { if ! uci -q get wireless.status >/dev/null; then [ -f /etc/config/wireless ] || touch /etc/config/wireless