1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NET_ALL_CAPABILITIES_H
17 #define NET_ALL_CAPABILITIES_H
18 
19 #include <set>
20 
21 #include "parcel.h"
22 
23 namespace OHOS {
24 namespace NetManagerStandard {
25 enum NetCap {
26     NET_CAPABILITY_MMS = 0,
27     NET_CAPABILITY_SUPL = 1,
28     NET_CAPABILITY_DUN = 2,
29     NET_CAPABILITY_IA = 3,
30     NET_CAPABILITY_XCAP = 4,
31     NET_CAPABILITY_NOT_METERED = 11,
32     NET_CAPABILITY_INTERNET = 12,
33     NET_CAPABILITY_NOT_VPN = 15,
34     NET_CAPABILITY_VALIDATED = 16,
35     NET_CAPABILITY_PORTAL = 17,
36     NET_CAPABILITY_INTERNAL_DEFAULT = 18, // for inner virtual interface if needed.
37     NET_CAPABILITY_CHECKING_CONNECTIVITY = 31,
38     NET_CAPABILITY_END = 32 // The maximum value is 32. Do not exceed the limit.
39 };
40 
41 enum NetBearType {
42     BEARER_CELLULAR = 0,
43     BEARER_WIFI = 1,
44     BEARER_BLUETOOTH = 2,
45     BEARER_ETHERNET = 3,
46     BEARER_VPN = 4,
47     BEARER_WIFI_AWARE = 5,
48     BEARER_DEFAULT  // 枚举最大值,无实际含义
49 };
50 
51 #define NET_SYMBOL_VISIBLE __attribute__ ((visibility("default")))
52 struct NET_SYMBOL_VISIBLE NetAllCapabilities final : public Parcelable {
53     uint32_t linkUpBandwidthKbps_ = 0;
54     uint32_t linkDownBandwidthKbps_ = 0;
55     std::set<NetCap> netCaps_;
56     std::set<NetBearType> bearerTypes_;
57 
58     NetAllCapabilities() = default;
59     NetAllCapabilities(const NetAllCapabilities &cap);
60     NetAllCapabilities &operator=(const NetAllCapabilities &cap);
61 
62     bool CapsIsValid() const;
63     bool CapsIsNull() const;
64     bool Marshalling(Parcel &parcel) const override;
65     bool Unmarshalling(Parcel &parcel);
66     std::string ToString(const std::string &tab) const;
67 
68 private:
69     void ToStrNetCaps(const std::set<NetCap> &netCaps, std::string &str) const;
70     void ToStrNetBearTypes(const std::set<NetBearType> &bearerTypes, std::string &str) const;
71 };
72 } // namespace NetManagerStandard
73 } // namespace OHOS
74 #endif // NET_ALL_CAPABILITIES_H
75