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[1]. Example usage for PPPoE over LAN is provided as well[2]. Initially created against openwrt svn revision 20252. Applied and tested successfully on both Kamikaze 8.09.2 and Backfire 10.03, in combination with two other related patches: [1] https://lists.openwrt.org/pipermail/openwrt-devel/2010-March/006344.html [2] https://lists.openwrt.org/pipermail/openwrt-devel/2010-March/006316.html Signed-off-by: Janusz Krzysztofik <[email protected]> --- v1 -> v2 changes: - correct errorneous, C like syntax in "return", thanks to Bastian Bittorf. v2 -> v3 changes: - correct wrong variable name in "*) ifnames=;;" assignmnet, should be "*) ifaces=;;", sorry. --- 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 ret + 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;; + *) ifaces=;; + 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
