LCOV - code coverage report
Current view: top level - lib/dnssd - ResolverProxy.cpp (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 14 20 70.0 %
Date: 2024-02-15 08:20:41 Functions: 3 5 60.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2023 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             : #include "ResolverProxy.h"
      19             : 
      20             : #include <lib/support/CHIPMem.h>
      21             : 
      22             : namespace chip {
      23             : namespace Dnssd {
      24             : 
      25           4 : CHIP_ERROR ResolverProxy::Init(Inet::EndPointManager<Inet::UDPEndPoint> * udpEndPoint)
      26             : {
      27           4 :     VerifyOrReturnError(mContext == nullptr, CHIP_ERROR_INCORRECT_STATE);
      28             : 
      29           4 :     ReturnErrorOnFailure(mResolver.Init(udpEndPoint));
      30           3 :     mContext = Platform::New<DiscoveryContext>();
      31           3 :     VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_NO_MEMORY);
      32             : 
      33           3 :     return CHIP_NO_ERROR;
      34             : }
      35             : 
      36          14 : void ResolverProxy::Shutdown()
      37             : {
      38          14 :     VerifyOrReturn(mContext != nullptr);
      39           3 :     mContext->SetCommissioningDelegate(nullptr);
      40           3 :     mContext->Release();
      41           3 :     mContext = nullptr;
      42             : }
      43             : 
      44           0 : CHIP_ERROR ResolverProxy::DiscoverCommissionableNodes(DiscoveryFilter filter)
      45             : {
      46           0 :     VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE);
      47             : 
      48           0 :     return mResolver.DiscoverCommissionableNodes(filter, *mContext);
      49             : }
      50             : 
      51           3 : CHIP_ERROR ResolverProxy::DiscoverCommissioners(DiscoveryFilter filter)
      52             : {
      53           3 :     VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE);
      54             : 
      55           3 :     return mResolver.DiscoverCommissioners(filter, *mContext);
      56             : }
      57             : 
      58           0 : CHIP_ERROR ResolverProxy::StopDiscovery()
      59             : {
      60           0 :     VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE);
      61             : 
      62           0 :     return mResolver.StopDiscovery(*mContext);
      63             : }
      64             : 
      65             : } // namespace Dnssd
      66             : } // namespace chip

Generated by: LCOV version 1.14