6#include <netlink/cli/utils.h>
7#include <netlink/cli/link.h>
9#include <linux/netlink.h>
11static void print_usage(
void)
13 printf(
"Usage: nl-link-ifindex2name <ifindex>\n");
17int main(
int argc,
char *argv[])
20 struct nl_cache *link_cache;
27 sock = nl_cli_alloc_socket();
28 nl_cli_connect(sock, NETLINK_ROUTE);
29 link_cache = nl_cli_link_alloc_cache(sock);
34 nl_cli_fatal(ENOENT,
"Interface index %d does not exist",
void nl_cli_fatal(int err, const char *fmt,...)
Print error message and quit application.
uint32_t nl_cli_parse_u32(const char *arg)
Parse a text based 32 bit unsigned integer argument.
char * rtnl_link_i2name(struct nl_cache *cache, int ifindex, char *dst, size_t len)
Translate interface index to corresponding link name.