12 #include <netlink/cli/utils.h> 13 #include <netlink/cli/link.h> 15 #include <linux/netlink.h> 17 static void print_usage(
void)
19 printf(
"Usage: nl-link-ifindex2name <ifindex>\n");
23 int main(
int argc,
char *argv[])
26 struct nl_cache *link_cache;
33 sock = nl_cli_alloc_socket();
34 nl_cli_connect(sock, NETLINK_ROUTE);
35 link_cache = nl_cli_link_alloc_cache(sock);
40 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.