diff options
author | John Crispin <john@openwrt.org> | 2013-04-09 14:19:05 +0000 |
---|---|---|
committer | John Crispin <john@openwrt.org> | 2013-04-09 14:19:05 +0000 |
commit | f13ae9965cd593f42f18f2e7192a27cdce7441c4 (patch) | |
tree | b04f607109389c7ce45adda6f3d4782f3af0dbdb /package/network/config/swconfig/src/swlib.c | |
parent | f90f025f201ba08a01f6f8f6b03ddded44b082ac (diff) | |
download | upstream-f13ae9965cd593f42f18f2e7192a27cdce7441c4.tar.gz upstream-f13ae9965cd593f42f18f2e7192a27cdce7441c4.tar.bz2 upstream-f13ae9965cd593f42f18f2e7192a27cdce7441c4.zip |
add "swconfig list" support
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 36282
Diffstat (limited to 'package/network/config/swconfig/src/swlib.c')
-rw-r--r-- | package/network/config/swconfig/src/swlib.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/package/network/config/swconfig/src/swlib.c b/package/network/config/swconfig/src/swlib.c index de08717e33..a867d2e842 100644 --- a/package/network/config/swconfig/src/swlib.c +++ b/package/network/config/swconfig/src/swlib.c @@ -624,6 +624,36 @@ done: return NL_SKIP; } +static int +list_switch(struct nl_msg *msg, void *arg) +{ + struct swlib_scan_arg *sa = 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; + + if (!tb[SWITCH_ATTR_DEV_NAME] || !tb[SWITCH_ATTR_NAME]) + goto done; + + printf("Found: %s - %s\n", nla_get_string(tb[SWITCH_ATTR_DEV_NAME]), + nla_get_string(tb[SWITCH_ATTR_ALIAS])); + +done: + return NL_SKIP; +} + +void +swlib_list(void) +{ + if (swlib_priv_init() < 0) + return; + swlib_call(SWITCH_CMD_GET_SWITCH, list_switch, NULL, NULL); + swlib_priv_free(); +} struct switch_dev * swlib_connect(const char *name) |