12 #include <netlink/cli/utils.h> 13 #include <netlink/cli/rule.h> 14 #include <netlink/cli/link.h> 16 #include <linux/netlink.h> 18 static void print_usage(
void)
21 "Usage: nl-rule-list [OPTION]... [ROUTE]\n" 24 " -c, --cache List the contents of the route cache\n" 25 " -f, --format=TYPE Output format { brief | details | stats }\n" 26 " -h, --help Show this help\n" 27 " -v, --version Show versioning information\n" 30 " --family Address family\n" 35 int main(
int argc,
char *argv[])
38 struct rtnl_rule *rule;
39 struct nl_cache *rule_cache;
45 sock = nl_cli_alloc_socket();
46 nl_cli_connect(sock, NETLINK_ROUTE);
47 nl_cli_link_alloc_cache(sock);
48 rule_cache = nl_cli_rule_alloc_cache(sock);
49 rule = nl_cli_rule_alloc();
56 static struct option long_opts[] = {
57 {
"format", 1, 0,
'f' },
58 {
"help", 0, 0,
'h' },
59 {
"version", 0, 0,
'v' },
60 {
"family", 1, 0, ARG_FAMILY },
64 c = getopt_long(argc, argv,
"f:hv", long_opts, &optidx);
69 case 'f': params.
dp_type = nl_cli_parse_dumptype(optarg);
break;
70 case 'h': print_usage();
break;
71 case 'v': nl_cli_print_version();
break;
72 case ARG_FAMILY: nl_cli_rule_parse_family(rule, optarg);
break;
Dump object briefly on one line.
FILE * dp_fd
File descriptor the dumping output should go to.
enum nl_dump_type dp_type
Specifies the type of dump that is requested.
void nl_cache_dump_filter(struct nl_cache *cache, struct nl_dump_params *params, struct nl_object *filter)
Dump all elements of a cache (filtered).