blob: 4afee7bfb04d7ae3f873cd9b208ff43d31c0e539 [file] [log] [blame]
Zhi Huang942bc2e2017-11-13 21:26:071/*
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 17:11:0011#include "rtc_base/net_helper.h"
Zhi Huang942bc2e2017-11-13 21:26:0712
Ali Tofigh7fa90572022-03-17 14:47:4913#include "absl/strings/string_view.h"
14
Zhi Huang942bc2e2017-11-13 21:26:0715namespace cricket {
16
17const char UDP_PROTOCOL_NAME[] = "udp";
18const char TCP_PROTOCOL_NAME[] = "tcp";
19const char SSLTCP_PROTOCOL_NAME[] = "ssltcp";
20const char TLS_PROTOCOL_NAME[] = "tls";
21
Ali Tofigh7fa90572022-03-17 14:47:4922int GetProtocolOverhead(absl::string_view protocol) {
Zhi Huang942bc2e2017-11-13 21:26:0723 if (protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME) {
Sebastian Janssondb5d7e42020-03-02 10:32:2324 return kTcpHeaderSize;
25 } else if (protocol == UDP_PROTOCOL_NAME) {
26 return kUdpHeaderSize;
27 } else {
28 // TODO(srte): We should crash on unexpected input and handle TLS correctly.
29 return 8;
Zhi Huang942bc2e2017-11-13 21:26:0730 }
Zhi Huang942bc2e2017-11-13 21:26:0731}
32
33} // namespace cricket