• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BIP = 5,
32     NET_CAPABILITY_NOT_METERED = 11,
33     NET_CAPABILITY_INTERNET = 12,
34     NET_CAPABILITY_NOT_VPN = 15,
35     NET_CAPABILITY_VALIDATED = 16,
36     NET_CAPABILITY_PORTAL = 17,
37     NET_CAPABILITY_INTERNAL_DEFAULT = 18, // for inner virtual interface if needed.
38     NET_CAPABILITY_SNSSAI1 = 19,
39     NET_CAPABILITY_SNSSAI2 = 20,
40     NET_CAPABILITY_SNSSAI3 = 21,
41     NET_CAPABILITY_SNSSAI4 = 22,
42     NET_CAPABILITY_SNSSAI5 = 23,
43     NET_CAPABILITY_SNSSAI6 = 24,
44     NET_CAPABILITY_CHECKING_CONNECTIVITY = 31,
45     NET_CAPABILITY_END = 32 // The maximum value is 32. Do not exceed the limit.
46 };
47 
48 enum NetBearType {
49     BEARER_CELLULAR = 0,
50     BEARER_WIFI = 1,
51     BEARER_BLUETOOTH = 2,
52     BEARER_ETHERNET = 3,
53     BEARER_VPN = 4,
54     BEARER_WIFI_AWARE = 5,
55     BEARER_DEFAULT // The maximum value of NetBearType. Do not exceed the limit. No actual meaning.
56 };
57 
58 #define NET_SYMBOL_VISIBLE __attribute__ ((visibility("default")))
59 struct NET_SYMBOL_VISIBLE NetAllCapabilities final : public Parcelable {
60     uint32_t linkUpBandwidthKbps_ = 0;
61     uint32_t linkDownBandwidthKbps_ = 0;
62     std::set<NetCap> netCaps_;
63     std::set<NetBearType> bearerTypes_;
64 
65     NetAllCapabilities() = default;
66     NetAllCapabilities(const NetAllCapabilities &cap);
67     NetAllCapabilities &operator=(const NetAllCapabilities &cap);
68 
69     bool CapsIsValid() const;
70     bool CapsIsNull() const;
71     bool Marshalling(Parcel &parcel) const override;
72     bool Unmarshalling(Parcel &parcel);
73     std::string ToString(const std::string &tab) const;
74 
75 private:
76     void ToStrNetCaps(const std::set<NetCap> &netCaps, std::string &str) const;
77     void ToStrNetBearTypes(const std::set<NetBearType> &bearerTypes, std::string &str) const;
78 };
79 } // namespace NetManagerStandard
80 } // namespace OHOS
81 #endif // NET_ALL_CAPABILITIES_H
82