This patch provides a new function: /lib/network/config.sh:find_configs(). It 
is based on the existing /lib/network/config.sh:find_config(). These functions 
differ in what output they provide: while the original one otuputs a single 
name of the first interface config found that matches the interface name 
passed as an argument, the new one gives a list of all matching config names.

This function will be used by a patch that adds support for multiple configs 
over one network interface that I'm going to provide.

Created and tested against openwrt svn revision 20252.

Signed-off-by: Janusz Krzysztofik <[email protected]>
---
--- trunk/package/base-files/files/lib/network/config.sh.orig   2010-03-17 
13:48:28.000000000 +0100
+++ trunk/package/base-files/files/lib/network/config.sh        2010-03-17 
14:18:47.000000000 +0100
@@ -23,6 +23,29 @@ find_config() {
        return 1;
 }
 
+find_configs() {
+       local iftype device iface ifaces ifn
+       local ret=1
+       for ifn in $interfaces; do
+               config_get iftype "$ifn" type
+               config_get iface "$ifn" ifname
+               case "$iftype" in
+                       bridge) config_get ifaces "$ifn" ifnames;;
+                       *) ifnames=;;
+               esac
+               config_get device "$ifn" device
+               for ifc in $device $iface $ifaces; do
+                       [ ."$ifc" = ."$1" ] && {
+                               echo "$ifn"
+                               ret=0
+                               break
+                       }
+               done
+       done
+
+       return ret;
+}
+
 scan_interfaces() {
        local cfgfile="${1:-network}"
        interfaces=
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to