X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=scripts%2Fnetifd-wireless.sh;h=8816bff80abf235519309d2a1425a19e2cdaffd7;hp=67ba38b3f888f80fb87bab1e13ba325580655b0f;hb=HEAD;hpb=fbb4a83633fd935748dd3c26d4fc28821db71cdd diff --git a/scripts/netifd-wireless.sh b/scripts/netifd-wireless.sh index 67ba38b..8816bff 100644 --- a/scripts/netifd-wireless.sh +++ b/scripts/netifd-wireless.sh @@ -15,11 +15,13 @@ add_driver() { wireless_setup_vif_failed() { local error="$1" + echo "Interface $_w_iface setup failed: $error" } wireless_setup_failed() { local error="$1" + echo "Device setup failed: $error" wireless_set_retry 0 } @@ -46,17 +48,17 @@ _wdev_prepare_channel() { hwmode_n="${hwmode##n}" case "$channel" in - 0|auto) + ""|0|auto) channel=0 auto_channel=1 ;; - [0-9]+) ;; + [0-9]*) ;; *) wireless_setup_failed "INVALID_CHANNEL" ;; esac - [[ "$hwmode_n" = "$hwmode" ]] && { + [[ "$hwmode_n" = "$hwmode" ]] || { enable_ht=1 hwmode="$hwmode_n" @@ -156,9 +158,13 @@ _wireless_set_data() { _wireless_add_process() { _wdev_notify_init $CMD_PROCESS_ADD + local exe="$2" + [ -L "$exe" ] && exe="$(readlink -f "$exe")" json_add_int pid "$1" - json_add_string exe "$2" + json_add_string exe "$exe" [ -n "$3" ] && json_add_boolean required 1 + exe2="$(readlink -f /proc/$1/exe)" + [ "$exe" != "$exe2" ] && echo "WARNING (wireless_add_process): executable path $exe does not match process $1 path ($exe2)" _wdev_notify } @@ -189,15 +195,15 @@ wireless_vif_parse_encryption() { auth_mode_open=1 auth_mode_shared=0 auth_type=none - wpa_pairwise=CCMP + wpa_cipher=CCMP case "$encryption" in - *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) wpa_pairwise="CCMP TKIP";; - *aes|*ccmp) wpa_pairwise="CCMP";; - *tkip) wpa_pairwise="TKIP";; + *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) wpa_cipher="CCMP TKIP";; + *aes|*ccmp) wpa_cipher="CCMP";; + *tkip) wpa_cipher="TKIP";; esac # 802.11n requires CCMP for WPA - [ "$enable_ht:$wpa_pairwise" = "1:TKIP" ] && wpa_pairwise="CCMP TKIP" + [ "$enable_ht:$wpa_cipher" = "1:TKIP" ] && wpa_cipher="CCMP TKIP" # Examples: # psk-mixed/tkip => WPA1+2 PSK, TKIP @@ -216,9 +222,10 @@ wireless_vif_parse_encryption() { ;; *) wpa=0 - wpa_pairwise= + wpa_cipher= ;; esac + wpa_pairwise="$wpa_cipher" case "$encryption" in *psk*) @@ -242,12 +249,14 @@ wireless_vif_parse_encryption() { esac } -_get_vif_vars() { - # internal use - json_get_var _w_type mode +_wireless_set_brsnoop_isolation() { + local multicast_to_unicast="$1" + local isolate - # for drivers - json_get_var network_bridge bridge + json_get_var isolate isolate + + [ ${isolate:-0} -gt 0 -o -z "$network_bridge" ] && return + [ ${multicast_to_unicast:-1} -gt 0 ] && json_add_boolean isolate 1 } for_each_interface() { @@ -256,13 +265,18 @@ for_each_interface() { local _w_type local _w_found + local multicast_to_unicast + json_get_keys _w_ifaces interfaces json_select interfaces for _w_iface in $_w_ifaces; do json_select "$_w_iface" if [ -n "$_w_types" ]; then + json_get_var network_bridge bridge + json_get_var multicast_to_unicast multicast_to_unicast json_select config - _get_vif_vars + _wireless_set_brsnoop_isolation "$multicast_to_unicast" + json_get_var _w_type mode json_select .. _w_types=" $_w_types " [[ "${_w_types%$_w_type*}" = "$_w_types" ]] && { @@ -277,11 +291,11 @@ for_each_interface() { } _wdev_common_device_config() { - config_add_string channel hwmode + config_add_string channel hwmode htmode noscan } _wdev_common_iface_config() { - config_add_string mode ssid encryption key + config_add_string mode ssid encryption 'key:wpakey' } init_wireless_driver() { @@ -291,6 +305,8 @@ init_wireless_driver() { case "$cmd" in dump) add_driver() { + eval "drv_$1_cleanup" + json_init json_add_string name "$1"