ifaddrs_converter.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  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. #ifndef RTC_BASE_IFADDRS_CONVERTER_H_
  11. #define RTC_BASE_IFADDRS_CONVERTER_H_
  12. #if defined(WEBRTC_ANDROID)
  13. #include "rtc_base/ifaddrs_android.h"
  14. #else
  15. #include <ifaddrs.h>
  16. #endif // WEBRTC_ANDROID
  17. #include "rtc_base/ip_address.h"
  18. namespace rtc {
  19. // This class converts native interface addresses to our internal IPAddress
  20. // class. Subclasses should override ConvertNativeToIPAttributes to implement
  21. // the different ways of retrieving IPv6 attributes for various POSIX platforms.
  22. class IfAddrsConverter {
  23. public:
  24. IfAddrsConverter();
  25. virtual ~IfAddrsConverter();
  26. virtual bool ConvertIfAddrsToIPAddress(const struct ifaddrs* interface,
  27. InterfaceAddress* ipaddress,
  28. IPAddress* mask);
  29. protected:
  30. virtual bool ConvertNativeAttributesToIPAttributes(
  31. const struct ifaddrs* interface,
  32. int* ip_attributes);
  33. };
  34. IfAddrsConverter* CreateIfAddrsConverter();
  35. } // namespace rtc
  36. #endif // RTC_BASE_IFADDRS_CONVERTER_H_