diff options
Diffstat (limited to 'Swiften/Network')
-rw-r--r-- | Swiften/Network/NATPMPInterface.h | 6 | ||||
-rw-r--r-- | Swiften/Network/WindowsNetworkEnvironment.cpp | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Swiften/Network/NATPMPInterface.h b/Swiften/Network/NATPMPInterface.h index 55f5b87..6e7fb73 100644 --- a/Swiften/Network/NATPMPInterface.h +++ b/Swiften/Network/NATPMPInterface.h @@ -7,11 +7,13 @@ #pragma once #include <boost/optional.hpp> -#include <natpmp.h> - #include <Swiften/Network/NATPortMapping.h> #include <Swiften/Network/NATTraversalInterface.h> +// This has to be included after the previous headers, because of WIN32 macro +// being defined somewhere. +#include <natpmp.h> + namespace Swift { class NATPMPInterface : public NATTraversalInterface { public: diff --git a/Swiften/Network/WindowsNetworkEnvironment.cpp b/Swiften/Network/WindowsNetworkEnvironment.cpp index a202015..20f559d 100644 --- a/Swiften/Network/WindowsNetworkEnvironment.cpp +++ b/Swiften/Network/WindowsNetworkEnvironment.cpp @@ -23,19 +23,19 @@ namespace Swift { std::vector<NetworkInterface> WindowsNetworkEnvironment::getNetworkInterfaces() const { std::vector<NetworkInterface> result; - std::vector<IP_ADAPTER_ADDRESSES> adapters; + ByteArray adapters; ULONG bufferSize = 0; ULONG ret; ULONG flags = GAA_FLAG_INCLUDE_ALL_INTERFACES | GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER; - while ((ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, vecptr(adapters), &bufferSize)) == ERROR_BUFFER_OVERFLOW) { - adapters.resize(bufferSize / sizeof(IP_ADAPTER_ADDRESSES)); + while ((ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, reinterpret_cast<IP_ADAPTER_ADDRESSES*>(vecptr(adapters)), &bufferSize)) == ERROR_BUFFER_OVERFLOW) { + adapters.resize(bufferSize); }; if (ret != ERROR_SUCCESS) { return result; } std::map<std::string,NetworkInterface> interfaces; - for (IP_ADAPTER_ADDRESSES* adapter = vecptr(adapters); adapter; adapter = adapter->Next) { + for (IP_ADAPTER_ADDRESSES* adapter = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(vecptr(adapters)); adapter; adapter = adapter->Next) { std::string name(adapter->AdapterName); if (adapter->OperStatus != IfOperStatusUp) { continue; |