MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / GetNetworkInterfaces

Method GetNetworkInterfaces

cpp/shared/network_util.cpp:37–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37set<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
62bool network_util::ResolveHostName(const string& host, sockaddr_in *addr)
63{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected