aboutsummaryrefslogtreecommitdiffstats
path: root/package/swconfig
diff options
context:
space:
mode:
authorJonas Gorski <jogo@openwrt.org>2011-07-27 18:00:18 +0000
committerJonas Gorski <jogo@openwrt.org>2011-07-27 18:00:18 +0000
commitc86f6a92354ee847ef8b06ce1061ff45989e9148 (patch)
treeabee889c94a256789fdcbc913c8ed7b75bc3cc40 /package/swconfig
parent667740bb3f3a221a6cc8adc9ebdd7f4ecab1c2f0 (diff)
downloadupstream-c86f6a92354ee847ef8b06ce1061ff45989e9148.tar.gz
upstream-c86f6a92354ee847ef8b06ce1061ff45989e9148.tar.bz2
upstream-c86f6a92354ee847ef8b06ce1061ff45989e9148.zip
swconfig: Add generic switch identifiers
Also make switches available under a generic name "switch<num>" for device name agnostic access. The old device name is used as an alias for backward compatibility. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27800 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/swconfig')
-rw-r--r--package/swconfig/Makefile2
-rw-r--r--package/swconfig/src/cli.c2
-rw-r--r--package/swconfig/src/swlib.c8
-rw-r--r--package/swconfig/src/swlib.h3
4 files changed, 10 insertions, 5 deletions
diff --git a/package/swconfig/Makefile b/package/swconfig/Makefile
index 363b3a01fd..58ae75f466 100644
--- a/package/swconfig/Makefile
+++ b/package/swconfig/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=swconfig
-PKG_RELEASE:=7
+PKG_RELEASE:=8
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
diff --git a/package/swconfig/src/cli.c b/package/swconfig/src/cli.c
index eea88d812f..eff34fb754 100644
--- a/package/swconfig/src/cli.c
+++ b/package/swconfig/src/cli.c
@@ -74,7 +74,7 @@ print_attrs(const struct switch_attr *attr)
static void
list_attributes(struct switch_dev *dev)
{
- printf("Switch %d: %s(%s), ports: %d (cpu @ %d), vlans: %d\n", dev->id, dev->dev_name, dev->name, dev->ports, dev->cpu_port, dev->vlans);
+ printf("%s: %s(%s), ports: %d (cpu @ %d), vlans: %d\n", dev->dev_name, dev->alias, dev->name, dev->ports, dev->cpu_port, dev->vlans);
printf(" --switch\n");
print_attrs(dev->ops);
printf(" --vlan\n");
diff --git a/package/swconfig/src/swlib.c b/package/swconfig/src/swlib.c
index 20e727eb53..531a23a1ab 100644
--- a/package/swconfig/src/swlib.c
+++ b/package/swconfig/src/swlib.c
@@ -580,6 +580,7 @@ add_switch(struct nl_msg *msg, void *arg)
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
struct switch_dev *dev;
const char *name;
+ const char *alias;
if (nla_parse(tb, SWITCH_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL) < 0)
goto done;
@@ -588,14 +589,17 @@ add_switch(struct nl_msg *msg, void *arg)
goto done;
name = nla_get_string(tb[SWITCH_ATTR_DEV_NAME]);
- if (sa->name && (strcmp(name, sa->name) != 0))
+ alias = nla_get_string(tb[SWITCH_ATTR_ALIAS]);
+
+ if (sa->name && (strcmp(name, sa->name) != 0) && (strcmp(alias, sa->name) != 0))
goto done;
dev = swlib_alloc(sizeof(struct switch_dev));
if (!dev)
goto done;
- dev->dev_name = strdup(name);
+ strncpy(dev->dev_name, name, IFNAMSIZ - 1);
+ dev->alias = strdup(alias);
if (tb[SWITCH_ATTR_ID])
dev->id = nla_get_u32(tb[SWITCH_ATTR_ID]);
if (tb[SWITCH_ATTR_NAME])
diff --git a/package/swconfig/src/swlib.h b/package/swconfig/src/swlib.h
index 2c2fccd394..ff73969c87 100644
--- a/package/swconfig/src/swlib.h
+++ b/package/swconfig/src/swlib.h
@@ -114,8 +114,9 @@ struct uci_package;
struct switch_dev {
int id;
+ char dev_name[IFNAMSIZ];
const char *name;
- const char *dev_name;
+ const char *alias;
int ports;
int vlans;
int cpu_port;