| 35 | } |
| 36 | |
| 37 | set<string, less<>> network_util::GetNetworkInterfaces() |
| 38 | { |
| 39 | set<string, less<>> network_interfaces; |
| 40 | |
| 41 | #ifdef __linux__ |
| 42 | ifaddrs *addrs; |
| 43 | getifaddrs(&addrs); |
| 44 | ifaddrs *tmp = addrs; |
| 45 | |
| 46 | while (tmp) { |
| 47 | if (const string name = tmp->ifa_name; tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && |
| 48 | name != "lo" && name != "piscsi_bridge" && !name.starts_with("dummy") && IsInterfaceUp(name)) { |
| 49 | // Only list interfaces that are up |
| 50 | network_interfaces.insert(name); |
| 51 | } |
| 52 | |
| 53 | tmp = tmp->ifa_next; |
| 54 | } |
| 55 | |
| 56 | freeifaddrs(addrs); |
| 57 | #endif |
| 58 | |
| 59 | return network_interfaces; |
| 60 | } |
| 61 | |
| 62 | bool network_util::ResolveHostName(const string& host, sockaddr_in *addr) |
| 63 | { |
nothing calls this directly
no outgoing calls
no test coverage detected