1 /* 2 * Copyright (C) 2023 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 I_MDNS_SERVICE_H 17 #define I_MDNS_SERVICE_H 18 19 #include <string> 20 #include <vector> 21 22 #include "iremote_broker.h" 23 #include "iremote_object.h" 24 25 #include "i_mdns_event.h" 26 #include "mdns_ipc_interface_code.h" 27 #include "mdns_service_info.h" 28 29 namespace OHOS { 30 namespace NetManagerStandard { 31 32 class IMDnsService : public IRemoteBroker { 33 public: 34 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.IMDnsService"); 35 36 /** 37 * Register mDNS service instance 38 * read https://www.rfc-editor.org/rfc/rfc2782.html and http://www.dns-sd.org/ServiceTypes.html 39 * 40 * @param serviceInfo.name Service instance name 41 * @param serviceInfo.type Service instance type 42 * @param serviceInfo.port Service instance port 43 * @param cb callback object 44 * @return Return errorcode 45 */ 46 virtual int32_t RegisterService(const MDnsServiceInfo &serviceInfo, const sptr<IRegistrationCallback> &cb) = 0; 47 48 /** 49 * UnRegister mDNS service instance 50 * 51 * @param cb callback object used in RegisterService 52 * @return Return errorcode 53 */ 54 virtual int32_t UnRegisterService(const sptr<IRegistrationCallback> &cb) = 0; 55 56 /** 57 * Browse mDNS service instance by service type 58 * read http://www.dns-sd.org/ServiceTypes.html 59 * 60 * @param serviceType Service instance type 61 * @param cb callback object 62 * @return Return errorcode 63 */ 64 virtual int32_t StartDiscoverService(const std::string &serviceType, const sptr<IDiscoveryCallback> &cb) = 0; 65 66 /** 67 * Stop browse mDNS service instance by service type 68 * 69 * @param cb callback object used in StartDiscoverService 70 * @return Return errorcode 71 */ 72 virtual int32_t StopDiscoverService(const sptr<IDiscoveryCallback> &cb) = 0; 73 74 /** 75 * Resolve browse mDNS service instance by service type and name 76 * 77 * @param serviceInfo.name Service instance name 78 * @param serviceInfo.type Service instance type 79 * @param cb callback object 80 * @return Return errorcode 81 */ 82 virtual int32_t ResolveService(const MDnsServiceInfo &serviceInfo, const sptr<IResolveCallback> &cb) = 0; 83 }; 84 } // namespace NetManagerStandard 85 } // namespace OHOS 86 #endif // I_MDNS_SERVICE_H 87