Last change
on this file since 380 was 352, checked in by coas-nagasima, 6 years ago |
arm向けASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
509 bytes
|
Line | |
---|
1 | #define _GNU_SOURCE
|
---|
2 | #include <net/if.h>
|
---|
3 | #include <sys/socket.h>
|
---|
4 | #include <sys/ioctl.h>
|
---|
5 | #include <string.h>
|
---|
6 | #include <errno.h>
|
---|
7 | #include "syscall.h"
|
---|
8 |
|
---|
9 | char *if_indextoname(unsigned index, char *name)
|
---|
10 | {
|
---|
11 | struct ifreq ifr;
|
---|
12 | int fd, r;
|
---|
13 |
|
---|
14 | if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
|
---|
15 | ifr.ifr_ifindex = index;
|
---|
16 | r = ioctl(fd, SIOCGIFNAME, &ifr);
|
---|
17 | __syscall(SYS_close, fd);
|
---|
18 | if (r < 0) {
|
---|
19 | if (errno == ENODEV) errno = ENXIO;
|
---|
20 | return 0;
|
---|
21 | }
|
---|
22 | return strncpy(name, ifr.ifr_name, IF_NAMESIZE);
|
---|
23 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.