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 NET_ADJ_SERVICE_H 17 #define NET_ADJ_SERVICE_H 18 19 #include "singleton.h" 20 #include "system_ability.h" 21 #include "net_adj_service_stub.h" 22 #include "net_adj_iface_info.h" 23 24 namespace OHOS { 25 namespace NetManagerStandard { 26 /** 27 * Network adjacency service is used to establish the adjacency of devices and 28 * mask physical layer differences between different devices through IP routing. 29 */ 30 class NetAdjService : public SystemAbility, public NetAdjServiceStub, std::enable_shared_from_this<NetAdjService> { 31 DECLARE_DELAYED_SINGLETON(NetAdjService); 32 DECLARE_SYSTEM_ABILITY(NetAdjService); 33 34 public: 35 /** 36 * Add a network adjacency interface. 37 * 38 * @param adjIface an instance of adjacency interface. 39 * @return ERR_NONE for operation success or errcode for failed. 40 */ 41 int32_t AddNetAdjIface(const sptr<NetAdjIfaceInfo> &adjIface) override; 42 43 /** 44 * Remove a network adjacency interface. 45 * 46 * @param ifaceName is the interface name 47 * @return ERR_NONE for operation success or errcode for failed. 48 */ 49 int32_t RemoveNetAdjIface(const std::string &ifaceName) override; 50 51 /** 52 * Register a listener for listening on adjacency network interfaces. 53 * 54 * @param callback calls when network adjacency interfaces added or removed. 55 * @return ERR_NONE for operation success or errcode for failed. 56 */ 57 int32_t RegisterAdjIfaceCallback(const sptr<INetAdjCallback> &callback) override; 58 59 /** 60 * Unregister the listener for listening on adjacency network interfaces. 61 * 62 * @param callback the callback object from function {@code NetAdjService::RegisterAdjIfaceCallback} 63 * @return ERR_NONE for operation success or errcode for failed. 64 */ 65 int32_t UnregisterAdjIfaceCallback(const sptr<INetAdjCallback> &callback) override; 66 67 int32_t UpdateNetAdjInfo(const std::string &iface, const sptr<NetAdjIfaceInfo> &adjIfaceINfo) override; 68 }; 69 } // namespace NetManagerStandard 70 } // namespace OHOS 71 72 #endif // NET_ADJ_SERVICE_H 73