• 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_NOT_METERED = 11,
28     NET_CAPABILITY_INTERNET = 12,
29     NET_CAPABILITY_NOT_VPN = 15,
30     NET_CAPABILITY_VALIDATED = 16,
31     NET_CAPABILITY_CAPTIVE_PORTAL = 17,
32     NET_CAPABILITY_INTERNAL_DEFAULT
33 };
34 
35 enum NetBearType {
36     BEARER_CELLULAR = 0,
37     BEARER_WIFI = 1,
38     BEARER_BLUETOOTH = 2,
39     BEARER_ETHERNET = 3,
40     BEARER_VPN = 4,
41     BEARER_WIFI_AWARE = 5,
42     BEARER_DEFAULT
43 };
44 
45 #define NET_SYMBOL_VISIBLE __attribute__ ((visibility("default")))
46 struct NET_SYMBOL_VISIBLE NetAllCapabilities final : public Parcelable {
47     uint32_t linkUpBandwidthKbps_ = 0;
48     uint32_t linkDownBandwidthKbps_ = 0;
49     std::set<NetCap> netCaps_;
50     std::set<NetBearType> bearerTypes_;
51 
52     NetAllCapabilities() = default;
53     NetAllCapabilities(const NetAllCapabilities &cap);
54     NetAllCapabilities &operator=(const NetAllCapabilities &cap);
55 
56     bool CapsIsValid() const;
57     bool CapsIsNull() const;
58     bool Marshalling(Parcel &parcel) const override;
59     bool Unmarshalling(Parcel &parcel);
60     std::string ToString(const std::string &tab) const;
61 
62 private:
63     void ToStrNetCaps(const std::set<NetCap> &netCaps, std::string &str) const;
64     void ToStrNetBearTypes(const std::set<NetBearType> &bearerTypes, std::string &str) const;
65 };
66 } // namespace NetManagerStandard
67 } // namespace OHOS
68 #endif // NET_ALL_CAPABILITIES_H
69