• 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 struct NetAllCapabilities : public Parcelable {
46     uint32_t linkUpBandwidthKbps_ = 0;
47     uint32_t linkDownBandwidthKbps_ = 0;
48     std::set<NetCap> netCaps_;
49     std::set<NetBearType> bearerTypes_;
50 
51     NetAllCapabilities() = default;
52     NetAllCapabilities(const NetAllCapabilities &cap);
53     NetAllCapabilities &operator=(const NetAllCapabilities &cap);
54 
55     bool CapsIsValid() const;
56     bool CapsIsNull() const;
57     virtual bool Marshalling(Parcel &parcel) const override;
58     bool Unmarshalling(Parcel &parcel);
59     std::string ToString(const std::string &tab) const;
60 
61 private:
62     void ToStrNetCaps(const std::set<NetCap> &netCaps, std::string &str) const;
63     void ToStrNetBearTypes(const std::set<NetBearType> &bearerTypes, std::string &str) const;
64 };
65 } // namespace NetManagerStandard
66 } // namespace OHOS
67 #endif // NET_ALL_CAPABILITIES_H
68