12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/link.h>
15 static void print_usage(
void)
18 "Usage: nl-link-list [OPTIONS]... \n"
21 " --details Show detailed information of each link\n"
22 " --stats Show statistics, implies --details\n"
23 " -h, --help Show this help text.\n"
24 " -v, --version Show versioning information.\n"
26 " -n, --name=NAME Name of link\n"
27 " -i, --index Interface index (unique identifier)\n"
28 " --family=NAME Link address family\n"
29 " --mtu=NUM MTU value\n"
30 " --txqlen=NUM TX queue length\n"
31 " --weight=NUM Weight\n"
36 int main(
int argc,
char *argv[])
39 struct nl_cache *link_cache;
46 sock = nl_cli_alloc_socket();
47 nl_cli_connect(sock, NETLINK_ROUTE);
48 link = nl_cli_link_alloc();
60 static struct option long_opts[] = {
61 {
"details", 0, 0, ARG_DETAILS },
62 {
"stats", 0, 0, ARG_STATS },
63 {
"help", 0, 0,
'h' },
64 {
"version", 0, 0,
'v' },
65 {
"name", 1, 0,
'n' },
66 {
"index", 1, 0,
'i' },
67 {
"family", 1, 0, ARG_FAMILY },
68 {
"mtu", 1, 0, ARG_MTU },
69 {
"txqlen", 1, 0, ARG_TXQLEN },
70 {
"weight", 1, 0, ARG_WEIGHT },
74 c = getopt_long(argc, argv,
"hvn:i:", long_opts, &optidx);
81 case 'h': print_usage();
break;
82 case 'v': nl_cli_print_version();
break;
83 case 'n': nl_cli_link_parse_name(link, optarg);
break;
84 case 'i': nl_cli_link_parse_ifindex(link, optarg);
break;
85 case ARG_FAMILY: nl_cli_link_parse_family(link, optarg);
break;
86 case ARG_MTU: nl_cli_link_parse_mtu(link, optarg);
break;
87 case ARG_TXQLEN: nl_cli_link_parse_txqlen(link, optarg);
break;
88 case ARG_WEIGHT: nl_cli_link_parse_weight(link, optarg);
break;
92 link_cache = nl_cli_link_alloc_cache_family(sock,