2 * src/nl-addr-dump.c Dump address attributes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
14 static void print_usage(void)
17 "Usage: nl-addr-dump <mode> [<filter>]\n"
18 " mode := { brief | detailed | stats | xml }\n"
19 " filter := [dev DEV] [label LABEL] [family FAMILY] [scope SCOPE]\n"
20 " [local ADDR] [peer ADDR] [broadcast ADDR] [anycast ADDR]\n"
21 " [multicast ADDR]\n");
27 int main(int argc, char *argv[])
29 struct nl_handle *nlh;
30 struct nl_cache *link_cache, *addr_cache;
31 struct rtnl_addr *addr;
32 struct nl_dump_params params = {
34 .dp_type = NL_DUMP_BRIEF
38 if (nltool_init(argc, argv) < 0)
41 nlh = nltool_alloc_handle();
45 addr = rtnl_addr_alloc();
49 if (argc < 2 || !strcmp(argv[1], "-h"))
52 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
55 link_cache = nltool_alloc_link_cache(nlh);
59 addr_cache = nltool_alloc_addr_cache(nlh);
61 goto errout_link_cache;
63 params.dp_type = nltool_parse_dumptype(argv[1]);
64 if (params.dp_type < 0)
65 goto errout_addr_cache;
66 get_filter(addr, argc, argv, 2, link_cache);
68 nl_cache_dump_filter(addr_cache, ¶ms, (struct nl_object *) addr);
73 nl_cache_free(addr_cache);
75 nl_cache_free(link_cache);