| 1 |
|
| #include <sys/types.h> |
| 2 |
|
| #include <sys/socket.h> |
| 3 |
|
| #include <sys/ioctl.h> |
| 4 |
|
| #include <net/if.h> |
| 5 |
|
| #include <linux/ethtool.h> |
| 6 |
|
| #include <linux/sockios.h> |
| 7 |
|
| |
| 8 |
0 |
| static int _do_ioctl(const char *dev, void *data) |
| 9 |
|
| { |
| 10 |
0 |
| int sock = socket(AF_INET, SOCK_DGRAM, 0); |
| 11 |
0 |
▶ | if(sock == -1) |
Branch: 1 branch
| Branch | True | False | Total |
| if(sock == -1) |
0 |
0 |
0 |
|
| 12 |
|
| { |
| 13 |
0 |
| return 0; |
| 14 |
|
| } |
| 15 |
|
| |
| 16 |
|
| struct ifreq ifr; |
| 17 |
0 |
| strcpy(ifr.ifr_name, dev); |
| 18 |
0 |
| ifr.ifr_data = data; |
| 19 |
|
| |
| 20 |
0 |
▶ | if(ioctl(sock, SIOCETHTOOL, &ifr) == -1) |
Branch: 1 branch
| Branch | True | False | Total |
| if(ioctl(sock, SIOCETHTOOL, &ifr) == -1) |
0 |
0 |
0 |
|
| 21 |
|
| { |
| 22 |
0 |
| close(sock); |
| 23 |
0 |
| return 0; |
| 24 |
|
| } |
| 25 |
|
| |
| 26 |
0 |
| close(sock); |
| 27 |
0 |
| return 1; |
| 28 |
|
| } |