mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-19 05:04:04 +02:00
swconfig: support providing the switch device name in an option instead of the section name - necessary to support switches that contain characters such as "-"
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19208 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
5ab0ca0fd5
commit
65c8d28d39
@ -8,7 +8,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=swconfig
|
PKG_NAME:=swconfig
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
include $(INCLUDE_DIR)/kernel.mk
|
include $(INCLUDE_DIR)/kernel.mk
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
# Copyright (C) 2009 OpenWrt.org
|
# Copyright (C) 2009 OpenWrt.org
|
||||||
|
|
||||||
setup_switch_dev() {
|
setup_switch_dev() {
|
||||||
ifconfig "$1" 0.0.0.0
|
config_get name "$1" name
|
||||||
swconfig dev "$1" load network
|
name="${name:-$1}"
|
||||||
|
[ -d "/sys/class/net/$name" ] && ifconfig "$name" up
|
||||||
|
swconfig dev "$name" load network
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_switch() {
|
setup_switch() {
|
||||||
|
@ -107,6 +107,7 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
|
|||||||
struct uci_element *e;
|
struct uci_element *e;
|
||||||
struct uci_section *s;
|
struct uci_section *s;
|
||||||
struct uci_option *o;
|
struct uci_option *o;
|
||||||
|
struct uci_ptr ptr;
|
||||||
struct switch_val val;
|
struct switch_val val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -114,11 +115,28 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
|
|||||||
head = &settings;
|
head = &settings;
|
||||||
|
|
||||||
uci_foreach_element(&p->sections, e) {
|
uci_foreach_element(&p->sections, e) {
|
||||||
|
struct uci_element *n;
|
||||||
|
|
||||||
s = uci_to_section(e);
|
s = uci_to_section(e);
|
||||||
|
|
||||||
if (strcmp(s->type, "switch") != 0)
|
if (strcmp(s->type, "switch") != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
uci_foreach_element(&s->options, n) {
|
||||||
|
struct uci_option *o = uci_to_option(n);
|
||||||
|
|
||||||
|
if (strcmp(n->name, "name") != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (o->type != UCI_TYPE_STRING)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!strcmp(o->v.string, dev->dev_name))
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(e->name, dev->dev_name) != 0)
|
if (strcmp(e->name, dev->dev_name) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user