Skip to content

Commit

Permalink
libc: Fix if_indextoname(), if_nametoindex()
Browse files Browse the repository at this point in the history
Use AF_INET instead of AF_UNIX

Signed-off-by: Charles Myers <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
cmyers-spirent authored and wkozaczuk committed Dec 11, 2019
1 parent f1cd48e commit d35c3dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libc/network/if_indextoname.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ char *if_indextoname(unsigned index, char *name)
struct ifreq ifr;
int fd, r;

if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) return 0;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 0;
ifr.ifr_ifindex = index;
r = ioctl(fd, SIOCGIFNAME, &ifr);
close(fd);
Expand Down
2 changes: 1 addition & 1 deletion libc/network/if_nametoindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ unsigned if_nametoindex(const char *name)
struct ifreq ifr;
int fd, r;

if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) return -1;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return -1;
strlcpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
r = ioctl(fd, SIOCGIFINDEX, &ifr);
close(fd);
Expand Down

0 comments on commit d35c3dd

Please sign in to comment.