1 /* 2 * Copyright (c) 2022 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_PHYSICAL_NETWORK_H 17 #define INCLUDE_PHYSICAL_NETWORK_H 18 19 #include <string> 20 21 #include "netsys_network.h" 22 #include "network_permission.h" 23 24 namespace OHOS { 25 namespace nmd { 26 class PhysicalNetwork : public NetsysNetwork { 27 public: 28 PhysicalNetwork(uint16_t netId, NetworkPermission permission); 29 virtual ~PhysicalNetwork() = default; 30 31 /** 32 * Call RouteManager's AddInterfaceToDefaultNetwork 33 * 34 */ 35 void AddDefault(); 36 37 /** 38 * Call RouteManager's RemoveInterfaceFromDefaultNetwork 39 * 40 */ 41 void RemoveDefault(); 42 43 /** 44 * Judge network type whether or not physical 45 * 46 * @return Returns true physical 47 */ IsPhysical()48 bool IsPhysical() override 49 { 50 return true; 51 } 52 53 /** 54 * Get Network permission 55 * 56 * @return Returns permission_ 57 */ GetPermission()58 NetworkPermission GetPermission() const 59 { 60 return permission_; 61 } 62 63 private: GetNetworkType()64 std::string GetNetworkType() const override 65 { 66 return "PHYSICAL"; 67 }; 68 int32_t AddInterface(std::string &interfaceName) override; 69 int32_t RemoveInterface(std::string &interfaceName) override; 70 bool isDefault_ = false; 71 NetworkPermission permission_; 72 }; 73 } // namespace nmd 74 } // namespace OHOS 75 #endif // INCLUDE_PHYSICAL_NETWORK_H 76