blob: 00cd434a580799bb7aafe3f37d62eb73a34eda78 [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:261/*
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
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
Steve Anton10542f22019-01-11 17:11:0011#include "rtc_base/net_helpers.h"
henrike@webrtc.orgf0488722014-05-13 18:00:2612
Mirko Bonadeie5f4c6b2021-01-15 09:41:0113#include <memory>
Ali Tofigh2ab914c2022-04-13 10:55:1514#include <string>
15
16#include "absl/strings/string_view.h"
Mirko Bonadeie5f4c6b2021-01-15 09:41:0117
henrike@webrtc.orgf0488722014-05-13 18:00:2618#if defined(WEBRTC_WIN)
19#include <ws2spi.h>
20#include <ws2tcpip.h>
Jonas Olssona4d87372019-07-05 17:08:3321
henrike@webrtc.orgf0488722014-05-13 18:00:2622#endif
Taylor Brandstetter2b3bf6b2016-05-19 21:57:3123#if defined(WEBRTC_POSIX) && !defined(__native_client__)
Mirko Bonadeie5f4c6b2021-01-15 09:41:0124#include <arpa/inet.h>
Taylor Brandstetter2b3bf6b2016-05-19 21:57:3125#endif // defined(WEBRTC_POSIX) && !defined(__native_client__)
henrike@webrtc.orgf0488722014-05-13 18:00:2626
henrike@webrtc.orgf0488722014-05-13 18:00:2627namespace rtc {
28
Yves Gerey665174f2018-06-19 13:03:0529const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) {
henrike@webrtc.orgf0488722014-05-13 18:00:2630#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
Ali Tofigh2ab914c2022-04-13 10:55:1537int inet_pton(int af, absl::string_view src, void* dst) {
Ali Tofigh98bfd992022-07-22 20:10:4938 std::string src_str(src);
henrike@webrtc.orgf0488722014-05-13 18:00:2639#if defined(WEBRTC_WIN)
Ali Tofigh2ab914c2022-04-13 10:55:1540 return win32_inet_pton(af, src_str.c_str(), dst);
henrike@webrtc.orgf0488722014-05-13 18:00:2641#else
Ali Tofigh2ab914c2022-04-13 10:55:1542 return ::inet_pton(af, src_str.c_str(), dst);
henrike@webrtc.orgf0488722014-05-13 18:00:2643#endif
44}
henrike@webrtc.orgf0488722014-05-13 18:00:2645} // namespace rtc