blob: 7dcb599933c26a2d42b683a3b05416903e1b02c7 [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
Steve Anton10542f22019-01-11 09:11:00 -080011#include "rtc_base/net_helper.h"
Zhi Huang942bc2e2017-11-13 13:26:07 -080012
13#include "rtc_base/checks.h"
Steve Anton10542f22019-01-11 09:11:00 -080014#include "rtc_base/ip_address.h"
Zhi Huang942bc2e2017-11-13 13:26:07 -080015
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