• 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 INCLUDE_NMD_NETWORK_H__
17 #define INCLUDE_NMD_NETWORK_H__
18 
19 #include <set>
20 #include <string>
21 
22 namespace OHOS {
23 namespace nmd {
24 enum NetworkPermission : int {
25     PERMISSION_NONE = 0x0,
26     PERMISSION_NETWORK = 0x1,
27     PERMISSION_SYSTEM = 0x3,
28 };
29 
30 class NmdNetwork {
31 public:
32     NmdNetwork(uint16_t netId, NetworkPermission permission);
33     virtual ~NmdNetwork();
34 
35     void AddDefault();
36     void RemoveDefault();
37 
38     int AddInterface(std::string &interfaceName);
39     int RemoveInterface(std::string &interfaceName);
40     int ClearInterfaces();
41     bool ExistInterface(std::string &interfaceName);
42 
GetAllInterface()43     std::set<std::string> GetAllInterface()
44     {
45         return this->interfaces;
46     }
47 
GetNetId()48     uint16_t GetNetId()
49     {
50         return this->netId;
51     }
52 
GetPermission()53     NetworkPermission GetPermission()
54     {
55         return this->permission;
56     }
57 
58 private:
59     uint16_t netId;
60     bool isDefault = false;
61     NetworkPermission permission;
62     std::set<std::string> interfaces;
63 };
64 } // namespace nmd
65 } // namespace OHOS
66 #endif // !INCLUDE_NMD_NETWORK_H__
67