Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 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 | #ifndef RTC_BASE_NETWORK_CONSTANTS_H_ |
| 12 | #define RTC_BASE_NETWORK_CONSTANTS_H_ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
Jonas Oreland | 71fda36 | 2020-03-20 15:11:56 | [diff] [blame] | 16 | #include <string> |
| 17 | |
Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 18 | namespace rtc { |
| 19 | |
Jonas Oreland | 08d1806 | 2020-04-02 05:19:12 | [diff] [blame] | 20 | constexpr uint16_t kNetworkCostMax = 999; |
| 21 | constexpr uint16_t kNetworkCostCellular2G = 980; |
| 22 | constexpr uint16_t kNetworkCostCellular3G = 910; |
| 23 | constexpr uint16_t kNetworkCostCellular = 900; |
| 24 | constexpr uint16_t kNetworkCostCellular4G = 500; |
| 25 | constexpr uint16_t kNetworkCostCellular5G = 250; |
| 26 | constexpr uint16_t kNetworkCostUnknown = 50; |
| 27 | constexpr uint16_t kNetworkCostLow = 10; |
| 28 | constexpr uint16_t kNetworkCostMin = 0; |
| 29 | |
| 30 | // alias |
| 31 | constexpr uint16_t kNetworkCostHigh = kNetworkCostCellular; |
Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 32 | |
| 33 | enum AdapterType { |
| 34 | // This enum resembles the one in Chromium net::ConnectionType. |
| 35 | ADAPTER_TYPE_UNKNOWN = 0, |
| 36 | ADAPTER_TYPE_ETHERNET = 1 << 0, |
| 37 | ADAPTER_TYPE_WIFI = 1 << 1, |
Jonas Oreland | 08d1806 | 2020-04-02 05:19:12 | [diff] [blame] | 38 | ADAPTER_TYPE_CELLULAR = 1 << 2, // This is CELLULAR of unknown type. |
Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 39 | ADAPTER_TYPE_VPN = 1 << 3, |
Qingsi Wang | 9f1de69 | 2018-06-28 22:38:09 | [diff] [blame] | 40 | ADAPTER_TYPE_LOOPBACK = 1 << 4, |
| 41 | // ADAPTER_TYPE_ANY is used for a network, which only contains a single "any |
| 42 | // address" IP address (INADDR_ANY for IPv4 or in6addr_any for IPv6), and can |
| 43 | // use any/all network interfaces. Whereas ADAPTER_TYPE_UNKNOWN is used |
| 44 | // when the network uses a specific interface/IP, but its interface type can |
| 45 | // not be determined or not fit in this enum. |
| 46 | ADAPTER_TYPE_ANY = 1 << 5, |
Jonas Oreland | 08d1806 | 2020-04-02 05:19:12 | [diff] [blame] | 47 | ADAPTER_TYPE_CELLULAR_2G = 1 << 6, |
| 48 | ADAPTER_TYPE_CELLULAR_3G = 1 << 7, |
| 49 | ADAPTER_TYPE_CELLULAR_4G = 1 << 8, |
| 50 | ADAPTER_TYPE_CELLULAR_5G = 1 << 9 |
Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 51 | }; |
| 52 | |
Jonas Oreland | 71fda36 | 2020-03-20 15:11:56 | [diff] [blame] | 53 | std::string AdapterTypeToString(AdapterType type); |
| 54 | |
Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 55 | } // namespace rtc |
| 56 | |
| 57 | #endif // RTC_BASE_NETWORK_CONSTANTS_H_ |