3 * Copyright (c) 2021 Project CHIP Authors
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <core/CHIPError.h>
23 #include <inet/IPAddress.h>
24 #include <inet/InetInterface.h>
29 struct ResolvedNodeData
31 Inet::InterfaceId mInterfaceId;
32 Inet::IPAddress mAddress;
36 /// Groups callbacks for CHIP service resolution requests
37 class ResolverDelegate
40 virtual ~ResolverDelegate() = default;
42 /// Called when a requested CHIP node ID has been successfully resolved
43 virtual void OnNodeIdResolved(uint64_t nodeId, const ResolvedNodeData & nodeData) = 0;
45 /// Called when a CHIP node ID resolution has failed
46 virtual void OnNodeIdResolutionFailed(uint64_t nodeId, CHIP_ERROR error) = 0;
49 /// Interface for resolving CHIP services
53 virtual ~Resolver() {}
55 /// Registers a resolver delegate if none has been registered before
56 virtual CHIP_ERROR SetResolverDelegate(ResolverDelegate * delegate) = 0;
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;
61 /// Provides the system-wide implementation of the service resolver
62 static Resolver & Instance();