+ [ -x /usr/sbin/brctl ] && {
+ ifconfig "br-$config" 2>/dev/null >/dev/null && {
+ local newdevs=
+
+ config_get devices "$config" device
+ for dev in $(sort_list "$devices" "$iface"); do
+ append newdevs "$dev"
+ done
+ uci_set_state network "$config" device "$newdevs"
+ $DEBUG brctl addif "br-$config" "$iface"
+ # Bridge existed already. No further processing necesary
+ } || {
+ $DEBUG brctl addbr "br-$config"
+ $DEBUG brctl setfd "br-$config" 0
+ $DEBUG ifconfig "br-$config" up
+ $DEBUG brctl addif "br-$config" "$iface"
+ $DEBUG brctl stp "br-$config" ${stp:-0}
+ # Creating the bridge here will have triggered a hotplug event, which will
+ # result in another setup_interface() call, so we simply stop processing
+ # the current event at this point.
+ }
+ ifconfig "$iface" up 2>/dev/null >/dev/null
+ return 1
+ }
+ ;;
+ esac
+ return 0
+}
+
+set_interface_ifname() {
+ local config="$1"
+ local ifname="$2"
+
+ config_get device "$1" device
+ uci_set_state network "$config" ifname "$ifname"
+ uci_set_state network "$config" device "$device"
+}
+
+setup_interface_none() {
+ env -i ACTION="ifup" INTERFACE="$2" DEVICE="$1" PROTO=none /sbin/hotplug-call "iface" &
+}
+
+setup_interface_static() {
+ local iface="$1"
+ local config="$2"
+
+ config_get ipaddr "$config" ipaddr
+ config_get netmask "$config" netmask
+ config_get ip6addr "$config" ip6addr
+ [ -z "$ipaddr" -o -z "$netmask" ] && [ -z "$ip6addr" ] && return 1
+
+ config_get gateway "$config" gateway
+ config_get ip6gw "$config" ip6gw
+ config_get dns "$config" dns
+ config_get bcast "$config" broadcast
+
+ [ -z "$ipaddr" ] || $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask" broadcast "${bcast:-+}"
+ [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr"
+ [ -z "$gateway" ] || $DEBUG route add default gw "$gateway" dev "$iface"
+ [ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw" dev "$iface"
+ [ -z "$dns" ] || {
+ for ns in $dns; do
+ grep "$ns" /tmp/resolv.conf.auto 2>/dev/null >/dev/null || {
+ echo "nameserver $ns" >> /tmp/resolv.conf.auto