6#include <netlink/cli/utils.h> 
    7#include <netlink/cli/link.h> 
    9#include <linux/netlink.h> 
   11static void print_usage(
void)
 
   14"Usage: nl-link-list [OPTIONS]... \n" 
   17"     --details             Show detailed information of each link\n" 
   18"     --stats               Show statistics, implies --details\n" 
   19" -h, --help                Show this help text.\n" 
   20" -v, --version             Show versioning information.\n" 
   22" -n, --name=NAME           Name of link\n" 
   23" -i, --index               Interface index (unique identifier)\n" 
   24"     --family=NAME         Link address family\n" 
   25"     --mtu=NUM             MTU value\n" 
   26"     --txqlen=NUM          TX queue length\n" 
   27"     --weight=NUM          Weight\n" 
   32int main(
int argc, 
char *argv[])
 
   35        struct nl_cache *link_cache;
 
   42        sock = nl_cli_alloc_socket();
 
   43        nl_cli_connect(sock, NETLINK_ROUTE);
 
   44        link = nl_cli_link_alloc();
 
   56                static struct option long_opts[] = {
 
   57                        { 
"details", 0, 0, ARG_DETAILS },
 
   58                        { 
"stats", 0, 0, ARG_STATS },
 
   59                        { 
"help", 0, 0, 
'h' },
 
   60                        { 
"version", 0, 0, 
'v' },
 
   61                        { 
"name", 1, 0, 
'n' },
 
   62                        { 
"index", 1, 0, 
'i' },
 
   63                        { 
"family", 1, 0, ARG_FAMILY },
 
   64                        { 
"mtu", 1, 0, ARG_MTU },
 
   65                        { 
"txqlen", 1, 0, ARG_TXQLEN },
 
   66                        { 
"weight", 1, 0, ARG_WEIGHT },
 
   70                c = getopt_long(argc, argv, 
"hvn:i:", long_opts, &optidx);
 
   77                case 'h': print_usage(); 
break;
 
   78                case 'v': nl_cli_print_version(); 
break;
 
   79                case 'n': nl_cli_link_parse_name(link, optarg); 
break;
 
   80                case 'i': nl_cli_link_parse_ifindex(link, optarg); 
break;
 
   81                case ARG_FAMILY: nl_cli_link_parse_family(link, optarg); 
break;
 
   82                case ARG_MTU: nl_cli_link_parse_mtu(link, optarg); 
break;
 
   83                case ARG_TXQLEN: nl_cli_link_parse_txqlen(link, optarg); 
break;
 
   84                case ARG_WEIGHT: nl_cli_link_parse_weight(link, optarg); 
break;
 
   88        link_cache = nl_cli_link_alloc_cache_family(sock,
 
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).
 
int rtnl_link_get_family(struct rtnl_link *link)
Return address family of link object.
 
@ NL_DUMP_STATS
Dump all attributes including statistics.
 
@ NL_DUMP_LINE
Dump object briefly on one line.
 
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
 
enum nl_dump_type dp_type
Specifies the type of dump that is requested.