13 #ifndef __STOUT_WINDOWS_IP_HPP__ 14 #define __STOUT_WINDOWS_IP_HPP__ 29 const std::string&
name,
37 if (family != AF_INET) {
45 if (GetAdaptersInfo(
nullptr, &size) != ERROR_BUFFER_OVERFLOW) {
46 return WindowsError(
"Calling GetAdaptersInfo returned unexpected result");
49 std::vector<IP_ADAPTER_INFO> adapter_info(size /
sizeof(IP_ADAPTER_INFO));
50 result = GetAdaptersInfo(
51 static_cast<PIP_ADAPTER_INFO>(adapter_info.data()),
54 if (result != NO_ERROR) {
58 foreach(
const IP_ADAPTER_INFO& ip_adapter, adapter_info) {
59 if (!strcmp(ip_adapter.AdapterName, name.c_str())) {
64 if (ip_adapter.IpAddressList.IpMask.String[0] !=
'\0') {
78 int prefix = (family == AF_INET ? 32 : 64);
89 return Error(
"Cannot find the link device");
97 #endif // __STOUT_WINDOWS_IP_HPP__ IP address() const
Definition: ip.hpp:261
Definition: errorbase.hpp:36
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:130
T & get()&
Definition: try.hpp:80
Definition: error.hpp:108
static Try< IP > parse(const std::string &value, int family=AF_UNSPEC)
Definition: ip.hpp:417
IP netmask() const
Definition: ip.hpp:263
static Result< Network > fromLinkDevice(const std::string &name, int family)
Definition: ip.hpp:30
static Try error(const E &e)
Definition: try.hpp:43
static Try< Network > create(const IP &address, const IP &netmask)
Definition: ip.hpp:570
IP(const struct in_addr &_storage)
Definition: ip.hpp:92
bool isError() const
Definition: try.hpp:78
std::string stringify(int flags)
constexpr const char * name
Definition: shell.hpp:41
int prefix() const
Definition: ip.hpp:266