6#include <netlink/cli/utils.h> 
    7#include <netlink/cli/rule.h> 
    8#include <netlink/cli/link.h> 
   10#include <linux/netlink.h> 
   12static void print_usage(
void)
 
   15        "Usage: nl-rule-list [OPTION]... [ROUTE]\n" 
   18        " -c, --cache           List the contents of the route cache\n" 
   19        " -f, --format=TYPE     Output format { brief | details | stats }\n" 
   20        " -h, --help            Show this help\n" 
   21        " -v, --version         Show versioning information\n" 
   24        "     --family          Address family\n" 
   29int main(
int argc, 
char *argv[])
 
   32        struct rtnl_rule *rule;
 
   33        struct nl_cache *rule_cache;
 
   39        sock = nl_cli_alloc_socket();
 
   40        nl_cli_connect(sock, NETLINK_ROUTE);
 
   41        nl_cli_link_alloc_cache(sock);
 
   42        rule_cache = nl_cli_rule_alloc_cache(sock);
 
   43        rule = nl_cli_rule_alloc();
 
   50                static struct option long_opts[] = {
 
   51                        { 
"format", 1, 0, 
'f' },
 
   52                        { 
"help", 0, 0, 
'h' },
 
   53                        { 
"version", 0, 0, 
'v' },
 
   54                        { 
"family", 1, 0, ARG_FAMILY },
 
   58                c = getopt_long(argc, argv, 
"f:hv", long_opts, &optidx);
 
   63                case 'f': params.
dp_type = nl_cli_parse_dumptype(optarg); 
break;
 
   64                case 'h': print_usage(); 
break;
 
   65                case 'v': nl_cli_print_version(); 
break;
 
   66                case ARG_FAMILY: nl_cli_rule_parse_family(rule, optarg); 
break;
 
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).
 
@ NL_DUMP_LINE
Dump object briefly on one line.
 
enum nl_dump_type dp_type
Specifies the type of dump that is requested.
 
FILE * dp_fd
File descriptor the dumping output should go to.