Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 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 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #include "rtc_base/net_helper.h" |
Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 12 | |
Ali Tofigh | 7fa9057 | 2022-03-17 14:47:49 | [diff] [blame] | 13 | #include "absl/strings/string_view.h" |
| 14 | |
Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 15 | namespace cricket { |
| 16 | |
| 17 | const char UDP_PROTOCOL_NAME[] = "udp"; |
| 18 | const char TCP_PROTOCOL_NAME[] = "tcp"; |
| 19 | const char SSLTCP_PROTOCOL_NAME[] = "ssltcp"; |
| 20 | const char TLS_PROTOCOL_NAME[] = "tls"; |
| 21 | |
Ali Tofigh | 7fa9057 | 2022-03-17 14:47:49 | [diff] [blame] | 22 | int GetProtocolOverhead(absl::string_view protocol) { |
Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 23 | if (protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME) { |
Sebastian Jansson | db5d7e4 | 2020-03-02 10:32:23 | [diff] [blame] | 24 | 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 Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 30 | } |
Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | } // namespace cricket |