blob: 35bef5b00480e69108aa09036843d200930d653f [file] [log] [blame]
Guo-wei Shieh9faf1542015-12-28 14:06:55 -08001/*
2 * Copyright 2015 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef RTC_BASE_IFADDRS_CONVERTER_H_
12#define RTC_BASE_IFADDRS_CONVERTER_H_
Guo-wei Shieh9faf1542015-12-28 14:06:55 -080013
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020014#if defined(WEBRTC_ANDROID)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "rtc_base/ifaddrs-android.h"
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020016#else
17#include <ifaddrs.h>
18#endif // WEBRTC_ANDROID
Guo-wei Shieh9faf1542015-12-28 14:06:55 -080019
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/ipaddress.h"
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020021
22namespace rtc {
23
24// This class converts native interface addresses to our internal IPAddress
25// class. Subclasses should override ConvertNativeToIPAttributes to implement
26// the different ways of retrieving IPv6 attributes for various POSIX platforms.
27class IfAddrsConverter {
28 public:
29 IfAddrsConverter();
30 virtual ~IfAddrsConverter();
31 virtual bool ConvertIfAddrsToIPAddress(const struct ifaddrs* interface,
32 InterfaceAddress* ipaddress,
33 IPAddress* mask);
34
35 protected:
36 virtual bool ConvertNativeAttributesToIPAttributes(
37 const struct ifaddrs* interface,
38 int* ip_attributes);
39};
40
41IfAddrsConverter* CreateIfAddrsConverter();
42
43} // namespace rtc
Guo-wei Shieh9faf1542015-12-28 14:06:55 -080044
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020045#endif // RTC_BASE_IFADDRS_CONVERTER_H_