summaryrefslogtreecommitdiffstats
path: root/src/lib/link.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2010-11-11 21:26:11 (GMT)
committerThomas Graf <tgraf@suug.ch>2010-11-11 21:26:11 (GMT)
commit7ff4deeb56300a83a1bee091d3664fd588ac7837 (patch)
treedda1f357ef9b91e9fe1bef82229f1aeb3215579a /src/lib/link.c
parent2847cf081b88678a2bb780c59a2678131d47c11d (diff)
downloadlibnl-7ff4deeb56300a83a1bee091d3664fd588ac7837.zip
libnl-7ff4deeb56300a83a1bee091d3664fd588ac7837.tar.gz
libnl-7ff4deeb56300a83a1bee091d3664fd588ac7837.tar.bz2
Extend rtnl_link_alloc_cache() to support address families
Adds a family argument which allows to request link dumps for a certain address family. This allows to f.e. dump ipv6 specific statistics and data. nl-link-list --family inet6
Diffstat (limited to 'src/lib/link.c')
-rw-r--r--src/lib/link.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/link.c b/src/lib/link.c
index 88cea55..db90558 100644
--- a/src/lib/link.c
+++ b/src/lib/link.c
@@ -31,11 +31,30 @@ struct rtnl_link *nl_cli_link_alloc(void)
return link;
}
+struct nl_cache *nl_cli_link_alloc_cache_family(struct nl_sock *sock, int family)
+{
+ struct nl_cache *cache;
+ int err;
+
+ if ((err = rtnl_link_alloc_cache(sock, family, &cache)) < 0)
+ nl_cli_fatal(err, "Unable to allocate link cache: %s",
+ nl_geterror(err));
+
+ nl_cache_mngt_provide(cache);
+
+ return cache;
+}
+
+struct nl_cache *nl_cli_link_alloc_cache(struct nl_sock *sock)
+{
+ return nl_cli_link_alloc_cache_family(sock, AF_UNSPEC);
+}
+
void nl_cli_link_parse_family(struct rtnl_link *link, char *arg)
{
int family;
- if ((family = nl_str2af(arg)) == AF_UNSPEC)
+ if ((family = nl_str2af(arg)) < 0)
nl_cli_fatal(EINVAL,
"Unable to translate address family \"%s\"", arg);