blob: e654fe3925853e0522be8513ad320991ac3bccaf [file] [log] [blame]
Zhi Huang942bc2e2017-11-13 13:26:07 -08001/*
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
11#include "rtc_base/nethelper.h"
12
13#include "rtc_base/checks.h"
14#include "rtc_base/ipaddress.h"
15
16namespace cricket {
17
18const char UDP_PROTOCOL_NAME[] = "udp";
19const char TCP_PROTOCOL_NAME[] = "tcp";
20const char SSLTCP_PROTOCOL_NAME[] = "ssltcp";
21const char TLS_PROTOCOL_NAME[] = "tls";
22
23int GetIpOverhead(int addr_family) {
24 switch (addr_family) {
25 case AF_INET: // IPv4
26 return 20;
27 case AF_INET6: // IPv6
28 return 40;
29 default:
30 RTC_NOTREACHED() << "Invaild address family.";
31 return 0;
32 }
33}
34
35int GetProtocolOverhead(const std::string& protocol) {
36 if (protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME) {
37 return 20;
38 }
39 return 8;
40}
41
42} // namespace cricket