blob: 893b500d56a226f5bfce7ade20e0fc0cc866c065 [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
Zhi Huang942bc2e2017-11-13 13:26:07 -080013namespace cricket {
14
15const char UDP_PROTOCOL_NAME[] = "udp";
16const char TCP_PROTOCOL_NAME[] = "tcp";
17const char SSLTCP_PROTOCOL_NAME[] = "ssltcp";
18const char TLS_PROTOCOL_NAME[] = "tls";
19
Zhi Huang942bc2e2017-11-13 13:26:07 -080020int GetProtocolOverhead(const std::string& protocol) {
21 if (protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME) {
Sebastian Janssondb5d7e42020-03-02 11:32:23 +010022 return kTcpHeaderSize;
23 } else if (protocol == UDP_PROTOCOL_NAME) {
24 return kUdpHeaderSize;
25 } else {
26 // TODO(srte): We should crash on unexpected input and handle TLS correctly.
27 return 8;
Zhi Huang942bc2e2017-11-13 13:26:07 -080028 }
Zhi Huang942bc2e2017-11-13 13:26:07 -080029}
30
31} // namespace cricket