revert to using *_ifnames internally, too many problems with firewall, ppp, etc....
[openwrt.git] / package / base-files / default / lib / network / config.sh
index 59ec84a..5bc74d1 100755 (executable)
@@ -4,16 +4,12 @@
 # DEBUG="echo"
 
 find_config() {
-       local type iface ifn
+       local iftype iface ifn
        for ifn in $interfaces; do
-               config_get type "$ifn" type
+               config_get iftype "$ifn" type
                config_get iface "$ifn" ifname
-               case "$type" in
-                       bridge)
-                               config_get iface "$ifn" ifnames
-                       ;;
-               esac
-               for ifc in $iface; do
+               config_get device "$ifn" device
+               for ifc in ${device:-$iface}; do
                        [ "$ifc" = "$1" ] && {
                                echo "$ifn"
                                return 0
@@ -25,23 +21,23 @@ find_config() {
 }
 
 scan_interfaces() {
-       local mode type iface
+       local mode iftype iface ifname device
        interfaces=
        config_cb() {
-               config_get type "$CONFIG_SECTION" TYPE
-               case "$type" in
+               config_get iftype "$CONFIG_SECTION" TYPE
+               case "$iftype" in
                        interface)
-                               config_get type "$CONFIG_SECTION" type
-                               config_get mode "$CONFIG_SECTION" proto
-                               case "$type" in
+                               config_get proto "$CONFIG_SECTION" proto
+                               append interfaces "$CONFIG_SECTION"
+                               config_get iftype "$CONFIG_SECTION" iftype
+                               case "$iftype" in
                                        bridge)
-                                               config_get iface "$CONFIG_SECTION" ifname
-                                               iface="${iface:-br-$CONFIG_SECTION}"
-                                               config_set "$CONFIG_SECTION" ifname "$iface"
+                                               config_get ifname "$CONFIG_SECTION" ifname
+                                               config_set "$CONFIG_SECTION" ifnames "$ifname"
+                                               config_set "$CONFIG_SECTION" ifname br-"$CONFIG_SECTION"
                                        ;;
                                esac
-                               append interfaces "$CONFIG_SECTION"
-                               ( type "scan_$mode" ) >/dev/null 2>/dev/null && eval "scan_$mode '$CONFIG_SECTION'"
+                               ( type "scan_$proto" ) >/dev/null 2>/dev/null && eval "scan_$proto '$CONFIG_SECTION'"
                        ;;
                esac
        }
@@ -79,16 +75,15 @@ setup_interface() {
        # Setup bridging
        case "$iftype" in
                bridge)
-                       config_get bridge_ifname "$config" ifname
                        ifconfig "$iface" up 2>/dev/null >/dev/null
-                       ifconfig "$bridge_ifname" 2>/dev/null >/dev/null && {
-                               $DEBUG brctl addif "$bridge_ifname" "$iface"
+                       ifconfig "br-$config" 2>/dev/null >/dev/null && {
+                               $DEBUG brctl addif "br-$config" "$iface"
                                return 0
                        } || {
-                               $DEBUG brctl addbr "$bridge_ifname"
-                               $DEBUG brctl setfd "$bridge_ifname" 0
-                               $DEBUG brctl addif "$bridge_ifname" "$iface"
-                               iface="$bridge_ifname"
+                               $DEBUG brctl addbr "br-$config"
+                               $DEBUG brctl setfd "br-$config" 0
+                               $DEBUG brctl addif "br-$config" "$iface"
+                               iface="br-$config"
                        }
                ;;
        esac
This page took 0.024768 seconds and 4 git commands to generate.