#!/bin/sh
if [ "$ACTION" = "ifup" -a "${INTERFACE:0:4}" = "wifi" -a "${DEVICE:0:4}" = "wlan" ] ; then
  # Setup the txpower for devices which dont respect the value set in /etc/config/wireless
  txpower=$(uci -q get wireless.radio${DEVICE:4}.txpower)
  if [ "${txpower}" != "" ]; then
    iw phy${DEVICE:4} set txpower fixed 0
    iw phy${DEVICE:4} set txpower fixed ${txpower}00
  fi
  # Make sure it has a link local address
  sysctl -q -w net.ipv6.conf.${DEVICE}.addr_gen_mode=1
  sysctl -q -w net.ipv6.conf.${DEVICE}.addr_gen_mode=0
fi
