12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/rule.h>
14 #include <netlink/cli/link.h>
16 static void print_usage(
void)
19 "Usage: nl-rule-list [OPTION]... [ROUTE]\n"
22 " -c, --cache List the contents of the route cache\n"
23 " -f, --format=TYPE Output format { brief | details | stats }\n"
24 " -h, --help Show this help\n"
25 " -v, --version Show versioning information\n"
28 " --family Address family\n"
33 int main(
int argc,
char *argv[])
36 struct rtnl_rule *rule;
37 struct nl_cache *link_cache, *rule_cache;
43 sock = nl_cli_alloc_socket();
44 nl_cli_connect(sock, NETLINK_ROUTE);
45 link_cache = nl_cli_link_alloc_cache(sock);
46 rule_cache = nl_cli_rule_alloc_cache(sock);
47 rule = nl_cli_rule_alloc();
54 static struct option long_opts[] = {
55 {
"format", 1, 0,
'f' },
56 {
"help", 0, 0,
'h' },
57 {
"version", 0, 0,
'v' },
58 {
"family", 1, 0, ARG_FAMILY },
62 c = getopt_long(argc, argv,
"f:hv", long_opts, &optidx);
67 case 'f': params.
dp_type = nl_cli_parse_dumptype(optarg);
break;
68 case 'h': print_usage();
break;
69 case 'v': nl_cli_print_version();
break;
70 case ARG_FAMILY: nl_cli_rule_parse_family(rule, optarg);
break;