| 20 | using namespace std; |
| 21 | |
| 22 | bool network_util::IsInterfaceUp(const string& interface) |
| 23 | { |
| 24 | ifreq ifr = {}; |
| 25 | strncpy(ifr.ifr_name, interface.c_str(), IFNAMSIZ - 1); //NOSONAR Using strncpy is safe |
| 26 | const int fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP); |
| 27 | |
| 28 | if (!ioctl(fd, SIOCGIFFLAGS, &ifr) && (ifr.ifr_flags & IFF_UP)) { |
| 29 | close(fd); |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | close(fd); |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | set<string, less<>> network_util::GetNetworkInterfaces() |
| 38 | { |
nothing calls this directly
no outgoing calls
no test coverage detected