| Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [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 |  | 
 | 11 | #include "rtc_base/nethelper.h" | 
 | 12 |  | 
 | 13 | #include "rtc_base/checks.h" | 
 | 14 | #include "rtc_base/ipaddress.h" | 
 | 15 |  | 
 | 16 | namespace cricket { | 
 | 17 |  | 
 | 18 | const char UDP_PROTOCOL_NAME[] = "udp"; | 
 | 19 | const char TCP_PROTOCOL_NAME[] = "tcp"; | 
 | 20 | const char SSLTCP_PROTOCOL_NAME[] = "ssltcp"; | 
 | 21 | const char TLS_PROTOCOL_NAME[] = "tls"; | 
 | 22 |  | 
 | 23 | int 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 |  | 
 | 35 | int 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 |