Skip to content

Instantly share code, notes, and snippets.

@haraldh
Created June 9, 2017 11:08
Show Gist options
  • Save haraldh/02ce31adf9aae8c020c43de7e9f5b6f7 to your computer and use it in GitHub Desktop.
Save haraldh/02ce31adf9aae8c020c43de7e9f5b6f7 to your computer and use it in GitHub Desktop.
#include <net/if.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char ifname[IF_NAMESIZE+1];
int ifindex = atoi(argv[1]);
if (if_indextoname( ifindex, ifname) != NULL)
puts(ifname);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment