Matter SDK Coverage Report
Current view: top level - lib/dnssd - MinimalMdnsServer.cpp (source / functions) Coverage Total Hit
Test: SHA:e98a48c2e59f85a25417956e1d105721433aa5d1 Lines: 100.0 % 15 15
Test Date: 2026-01-09 16:53:50 Functions: 100.0 % 4 4

            Line data    Source code
       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              : #include "MinimalMdnsServer.h"
      18              : 
      19              : #include <lib/dnssd/minimal_mdns/AddressPolicy.h>
      20              : #include <minmdns/MinMdnsConfig.h>
      21              : 
      22              : #ifndef CHIP_MINMDNS_DEFAULT_POLICY
      23              : #define CHIP_MINMDNS_DEFAULT_POLICY 0
      24              : #endif
      25              : 
      26              : #ifndef CHIP_MINMDNS_LIBNL_POLICY
      27              : #define CHIP_MINMDNS_LIBNL_POLICY 0
      28              : #endif
      29              : 
      30              : #if CHIP_MINMDNS_DEFAULT_POLICY
      31              : #include <lib/dnssd/minimal_mdns/AddressPolicy_DefaultImpl.h> // nogncheck
      32              : #endif
      33              : 
      34              : #if CHIP_MINMDNS_LIBNL_POLICY
      35              : #include <lib/dnssd/minimal_mdns/AddressPolicy_LibNlImpl.h> // nogncheck
      36              : #endif
      37              : 
      38              : namespace chip {
      39              : namespace Dnssd {
      40              : 
      41              : using namespace mdns::Minimal;
      42              : using chip::Platform::UniquePtr;
      43              : 
      44           97 : GlobalMinimalMdnsServer::GlobalMinimalMdnsServer()
      45              : {
      46           97 :     mServer.SetDelegate(this);
      47              : 
      48              : #if CHIP_MINMDNS_DEFAULT_POLICY
      49           97 :     mdns::Minimal::SetDefaultAddressPolicy();
      50              : #endif
      51              : 
      52              : #if CHIP_MINMDNS_LIBNL_POLICY
      53              :     mdns::Minimal::LibNl::SetAddressPolicy();
      54              : #endif
      55           97 : }
      56              : 
      57          354 : GlobalMinimalMdnsServer & GlobalMinimalMdnsServer::Instance()
      58              : {
      59          354 :     static GlobalMinimalMdnsServer _instance;
      60          354 :     return _instance;
      61              : }
      62              : 
      63           18 : CHIP_ERROR GlobalMinimalMdnsServer::StartServer(chip::Inet::EndPointManager<chip::Inet::UDPEndPoint> * udpEndPointManager,
      64              :                                                 uint16_t port)
      65              : {
      66           18 :     GlobalMinimalMdnsServer::Server().ShutdownEndpoints();
      67              : 
      68           18 :     UniquePtr<ListenIterator> endpoints = GetAddressPolicy()->GetListenEndpoints();
      69              : 
      70           18 :     return GlobalMinimalMdnsServer::Server().Listen(udpEndPointManager, endpoints.get(), port);
      71           18 : }
      72              : 
      73            1 : void GlobalMinimalMdnsServer::ShutdownServer()
      74              : {
      75            1 :     GlobalMinimalMdnsServer::Server().Shutdown();
      76            1 : }
      77              : 
      78              : } // namespace Dnssd
      79              : } // namespace chip
        

Generated by: LCOV version 2.0-1