add broadcast setting for /etc/config/network interfaces
[openwrt.git] / package / base-files / files / lib / network / config.sh
index ffce9f6..ffe637b 100755 (executable)
@@ -88,21 +88,23 @@ setup_interface() {
        # Setup bridging
        case "$iftype" in
                bridge)
-                       ifconfig "$iface" up 2>/dev/null >/dev/null
-                       ifconfig "br-$config" 2>/dev/null >/dev/null && {
-                               $DEBUG brctl addif "br-$config" "$iface"
-                               return 0
-                       } || {
-                               $DEBUG brctl addbr "br-$config"
-                               $DEBUG brctl setfd "br-$config" 0
-                               $DEBUG brctl addif "br-$config" "$iface"
-                               iface="br-$config"
+                       [ -x /usr/sbin/brctl ] && {
+                               ifconfig "$iface" up 2>/dev/null >/dev/null
+                               ifconfig "br-$config" 2>/dev/null >/dev/null && {
+                                       $DEBUG brctl addif "br-$config" "$iface"
+                                       return 0
+                               } || {
+                                       $DEBUG brctl addbr "br-$config"
+                                       $DEBUG brctl setfd "br-$config" 0
+                                       $DEBUG brctl addif "br-$config" "$iface"
+                                       iface="br-$config"
                                
-                               # need to bring up the bridge and wait a second for 
-                               # it to switch to the 'forwarding' state, otherwise
-                               # it will lose its routes...
-                               ifconfig "$iface" up
-                               sleep 1
+                                       # need to bring up the bridge and wait a second for 
+                                       # it to switch to the 'forwarding' state, otherwise
+                                       # it will lose its routes...
+                                       ifconfig "$iface" up
+                                       sleep 1
+                               }
                        }
                ;;
        esac
@@ -122,10 +124,12 @@ setup_interface() {
                        config_get ip6addr "$config" ip6addr
                        config_get gateway "$config" gateway
                        config_get dns "$config" dns
+                       config_get bcast "$config" broadcast
                        
                        [ -z "$ipaddr" ] || $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
                        [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" inet6 add "$ip6addr" 
-                       [ -z "$gateway" ] || route add default gw "$gateway"
+                       [ -z "$gateway" ] || $DEBUG route add default gw "$gateway"
+                       [ -z "$bcast" ] || $DEBUG ifconfig "$iface" broadcast "$bcast"
                        [ -z "$dns" -o -f /tmp/resolv.conf.auto ] || {
                                for ns in $dns; do
                                        echo "nameserver $ns" >> /tmp/resolv.conf.auto