diff options
author | jogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2011-07-27 18:00:18 +0000 |
---|---|---|
committer | jogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2011-07-27 18:00:18 +0000 |
commit | 6c853478d6a9ef2ebf74d438fc343ae0b5f0e786 (patch) | |
tree | abee889c94a256789fdcbc913c8ed7b75bc3cc40 /package/swconfig/src/swlib.c | |
parent | 2ed51448ae64a1c4883ce7c76befce1f357b457e (diff) |
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/src/swlib.c')
-rw-r--r-- | package/swconfig/src/swlib.c | 8 |
1 files changed, 6 insertions, 2 deletions
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]) |