| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "rtc_base/net_helpers.h" |
| 12 |
| 13 | #include <memory> |
| 14 | #include <string> |
| 15 |
| 16 | #include "absl/strings/string_view.h" |
| 17 |
| 18 | #if defined(WEBRTC_WIN) |
| 19 | #include <ws2spi.h> |
| 20 | #include <ws2tcpip.h> |
| 21 |
| 22 | #endif |
| 23 | #if defined(WEBRTC_POSIX) && !defined(__native_client__) |
| 24 | #include <arpa/inet.h> |
| 25 | #endif // defined(WEBRTC_POSIX) && !defined(__native_client__) |
| 26 |
| 27 | namespace rtc { |
| 28 |
| 29 | const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) { |
| 30 | #if defined(WEBRTC_WIN) |
| 31 | return win32_inet_ntop(af, src, dst, size); |
| 32 | #else |
| 33 | return ::inet_ntop(af, src, dst, size); |
| 34 | #endif |
| 35 | } |
| 36 |
| 37 | int inet_pton(int af, absl::string_view src, void* dst) { |
| 38 | std::string src_str(src); |
| 39 | #if defined(WEBRTC_WIN) |
| 40 | return win32_inet_pton(af, src_str.c_str(), dst); |
| 41 | #else |
| 42 | return ::inet_pton(af, src_str.c_str(), dst); |
| 43 | #endif |
| 44 | } |
| 45 | } // namespace rtc |
| 46 |