+ # All interfaces must have unique mac addresses
+ # which can either be explicitly set in the device
+ # section, or automatically generated
+ config_get macaddr "$device" macaddr
+ local mac_1="${macaddr%%:*}"
+ local mac_2="${macaddr#*:}"
+
+ config_get vif_mac "$vif" macaddr
+ [ -n "$vif_mac" ] || {
+ if [ "$i" -gt 0 ]; then
+ offset="$(( 2 + $i * 4 ))"
+ else
+ offset="0"
+ fi
+ vif_mac="$( printf %02x $(($mac_1 + $offset)) ):$mac_2"
+ }
+ ifconfig "$ifname" hw ether "$vif_mac"
+
+ # We attempt to set teh channel for all interfaces, although
+ # mac80211 may not support it or the driver might not yet
+ [ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel"
+
+ local key keystring
+
+ # Valid values are:
+ # wpa / wep / none
+ #
+ # !! ap !!
+ #
+ # ALL ap functionality will be passed to hostapd
+ #
+ # !! mesh / adhoc / station !!
+ # none -> NO encryption
+ #
+ # wep + keymgmt = '' -> we use iw to connect to the
+ # network.
+ #
+ # wep + keymgmt = 'NONE' -> wpa_supplicant will be
+ # configured to handle the wep connection
+ if [ ! "$mode" = "ap" ]; then
+ case "$enc" in
+ wep)
+ config_get keymgmt "$vif" keymgmt
+ if [ -e "$keymgmt" ]; then
+ for idx in 1 2 3 4; do
+ local zidx
+ zidx = idx - 1
+ config_get key "$vif" "key${idx}"
+ if [ -n "$key" ]; then
+ append keystring "${zidx}:${key} "
+ fi
+ done
+ fi
+ ;;
+ wpa)
+ config_get key "$vif" key
+ ;;
+ esac
+ fi
+
+ # txpower is not yet implemented in iw