Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lib / mdns / Resolver.h
1 /*
2  *
3  *    Copyright (c) 2021 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 #pragma once
19
20 #include <cstdint>
21
22 #include <core/CHIPError.h>
23 #include <inet/IPAddress.h>
24 #include <inet/InetInterface.h>
25
26 namespace chip {
27 namespace Mdns {
28
29 struct ResolvedNodeData
30 {
31     Inet::InterfaceId mInterfaceId;
32     Inet::IPAddress mAddress;
33     uint16_t mPort;
34 };
35
36 /// Groups callbacks for CHIP service resolution requests
37 class ResolverDelegate
38 {
39 public:
40     virtual ~ResolverDelegate() = default;
41
42     /// Called when a requested CHIP node ID has been successfully resolved
43     virtual void OnNodeIdResolved(uint64_t nodeId, const ResolvedNodeData & nodeData) = 0;
44
45     /// Called when a CHIP node ID resolution has failed
46     virtual void OnNodeIdResolutionFailed(uint64_t nodeId, CHIP_ERROR error) = 0;
47 };
48
49 /// Interface for resolving CHIP services
50 class Resolver
51 {
52 public:
53     virtual ~Resolver() {}
54
55     /// Registers a resolver delegate if none has been registered before
56     virtual CHIP_ERROR SetResolverDelegate(ResolverDelegate * delegate) = 0;
57
58     /// Requests resolution of a node ID to its address
59     virtual CHIP_ERROR ResolveNodeId(uint64_t nodeId, uint64_t fabricId, Inet::IPAddressType type) = 0;
60
61     /// Provides the system-wide implementation of the service resolver
62     static Resolver & Instance();
63 };
64
65 } // namespace Mdns
66 } // namespace chip