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