You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2017 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. #include "rtc_base/net_helper.h"
  11. #include "rtc_base/checks.h"
  12. #include "rtc_base/ip_address.h"
  13. namespace cricket {
  14. const char UDP_PROTOCOL_NAME[] = "udp";
  15. const char TCP_PROTOCOL_NAME[] = "tcp";
  16. const char SSLTCP_PROTOCOL_NAME[] = "ssltcp";
  17. const char TLS_PROTOCOL_NAME[] = "tls";
  18. int GetIpOverhead(int addr_family) {
  19. switch (addr_family) {
  20. case AF_INET: // IPv4
  21. return 20;
  22. case AF_INET6: // IPv6
  23. return 40;
  24. default:
  25. RTC_NOTREACHED() << "Invaild address family.";
  26. return 0;
  27. }
  28. }
  29. int GetProtocolOverhead(const std::string& protocol) {
  30. if (protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME) {
  31. return 20;
  32. }
  33. return 8;
  34. }
  35. } // namespace cricket