summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/lib/link.c21
-rw-r--r--src/nl-link-list.c6
2 files changed, 24 insertions, 3 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);
diff --git a/src/nl-link-list.c b/src/nl-link-list.c
index 5e1e3f6..b1f75ce 100644
--- a/src/nl-link-list.c
+++ b/src/nl-link-list.c
@@ -6,7 +6,7 @@
* License as published by the Free Software Foundation version 2.1
* of the License.
*
- * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch>
*/
#if 0
@@ -59,7 +59,6 @@ int main(int argc, char *argv[])
sock = nl_cli_alloc_socket();
nl_cli_connect(sock, NETLINK_ROUTE);
- link_cache = nl_cli_link_alloc_cache(sock);
link = nl_cli_link_alloc();
for (;;) {
@@ -100,6 +99,9 @@ int main(int argc, char *argv[])
}
}
+ link_cache = nl_cli_link_alloc_cache_family(sock,
+ rtnl_link_get_family(link));
+
nl_cache_dump_filter(link_cache, &params, OBJ_CAST(link));
return 0;