• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_service_info.h"
27 
28 namespace OHOS {
29 namespace NetManagerStandard {
30 
31 class IMDnsService : public IRemoteBroker {
32 public:
33     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.IMDnsService");
34     enum {
35         CMD_DISCOVER,
36         CMD_STOP_DISCOVER,
37         CMD_REGISTER,
38         CMD_STOP_REGISTER,
39         CMD_RESOLVE
40     };
41 
42     /**
43      * Register mDNS service instance
44      * read https://www.rfc-editor.org/rfc/rfc2782.html and http://www.dns-sd.org/ServiceTypes.html
45      *
46      * @param serviceInfo.name Service instance name
47      * @param serviceInfo.type Service instance type
48      * @param serviceInfo.port Service instance port
49      * @param cb callback object
50      * @return Return errorcode
51      */
52     virtual int32_t RegisterService(const MDnsServiceInfo &serviceInfo, const sptr<IRegistrationCallback> &cb) = 0;
53 
54     /**
55      * UnRegister mDNS service instance
56      *
57      * @param cb callback object used in RegisterService
58      * @return Return errorcode
59      */
60     virtual int32_t UnRegisterService(const sptr<IRegistrationCallback> &cb) = 0;
61 
62     /**
63      * Browse mDNS service instance by service type
64      * read http://www.dns-sd.org/ServiceTypes.html
65      *
66      * @param serviceType Service instance type
67      * @param cb callback object
68      * @return Return errorcode
69      */
70     virtual int32_t StartDiscoverService(const std::string &serviceType, const sptr<IDiscoveryCallback> &cb) = 0;
71 
72     /**
73      * Stop browse mDNS service instance by service type
74      *
75      * @param cb callback object used in StartDiscoverService
76      * @return Return errorcode
77      */
78     virtual int32_t StopDiscoverService(const sptr<IDiscoveryCallback> &cb) = 0;
79 
80     /**
81      * Resolve browse mDNS service instance by service type and name
82      *
83      * @param serviceInfo.name Service instance name
84      * @param serviceInfo.type Service instance type
85      * @param cb callback object
86      * @return Return errorcode
87      */
88     virtual int32_t ResolveService(const MDnsServiceInfo &serviceInfo, const sptr<IResolveCallback> &cb) = 0;
89 };
90 } // namespace NetManagerStandard
91 } // namespace OHOS
92 #endif // I_MDNS_SERVICE_H
93