Matter SDK Coverage Report
Current view: top level - lib/dnssd - ResolverProxy.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 60.9 % 23 14
Test Date: 2025-01-17 19:00:11 Functions: 50.0 % 6 3

            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           23 : void ResolverProxy::Shutdown()
      37              : {
      38           23 :     VerifyOrReturn(mContext != nullptr);
      39            3 :     mContext->SetDiscoveryDelegate(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.StartDiscovery(DiscoveryType::kCommissionableNode, 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.StartDiscovery(DiscoveryType::kCommissionerNode, filter, *mContext);
      56              : }
      57              : 
      58            0 : CHIP_ERROR ResolverProxy::DiscoverOperationalNodes(DiscoveryFilter filter)
      59              : {
      60            0 :     VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE);
      61              : 
      62            0 :     return mResolver.StartDiscovery(DiscoveryType::kOperational, filter, *mContext);
      63              : }
      64              : 
      65            0 : CHIP_ERROR ResolverProxy::StopDiscovery()
      66              : {
      67            0 :     VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE);
      68              : 
      69            0 :     return mResolver.StopDiscovery(*mContext);
      70              : }
      71              : 
      72              : } // namespace Dnssd
      73              : } // namespace chip
        

Generated by: LCOV version 2.0-1