Matter SDK Coverage Report
Current view: top level - lib/dnssd - MinimalMdnsServer.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 100.0 % 15 15
Test Date: 2025-01-17 19:00:11 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              : 
      21              : #ifndef CHIP_MINMDNS_DEFAULT_POLICY
      22              : #define CHIP_MINMDNS_DEFAULT_POLICY 0
      23              : #endif
      24              : 
      25              : #ifndef CHIP_MINMDNS_LIBNL_POLICY
      26              : #define CHIP_MINMDNS_LIBNL_POLICY 0
      27              : #endif
      28              : 
      29              : #if CHIP_MINMDNS_DEFAULT_POLICY
      30              : #include <lib/dnssd/minimal_mdns/AddressPolicy_DefaultImpl.h> // nogncheck
      31              : #endif
      32              : 
      33              : #if CHIP_MINMDNS_LIBNL_POLICY
      34              : #include <lib/dnssd/minimal_mdns/AddressPolicy_LibNlImpl.h> // nogncheck
      35              : #endif
      36              : 
      37              : namespace chip {
      38              : namespace Dnssd {
      39              : 
      40              : using namespace mdns::Minimal;
      41              : using chip::Platform::UniquePtr;
      42              : 
      43           64 : GlobalMinimalMdnsServer::GlobalMinimalMdnsServer()
      44              : {
      45           64 :     mServer.SetDelegate(this);
      46              : 
      47              : #if CHIP_MINMDNS_DEFAULT_POLICY
      48           64 :     mdns::Minimal::SetDefaultAddressPolicy();
      49              : #endif
      50              : 
      51              : #if CHIP_MINMDNS_LIBNL_POLICY
      52              :     mdns::Minimal::LibNl::SetAddressPolicy();
      53              : #endif
      54           64 : }
      55              : 
      56          234 : GlobalMinimalMdnsServer & GlobalMinimalMdnsServer::Instance()
      57              : {
      58          234 :     static GlobalMinimalMdnsServer _instance;
      59          234 :     return _instance;
      60              : }
      61              : 
      62           14 : CHIP_ERROR GlobalMinimalMdnsServer::StartServer(chip::Inet::EndPointManager<chip::Inet::UDPEndPoint> * udpEndPointManager,
      63              :                                                 uint16_t port)
      64              : {
      65           14 :     GlobalMinimalMdnsServer::Server().ShutdownEndpoints();
      66              : 
      67           14 :     UniquePtr<ListenIterator> endpoints = GetAddressPolicy()->GetListenEndpoints();
      68              : 
      69           14 :     return GlobalMinimalMdnsServer::Server().Listen(udpEndPointManager, endpoints.get(), port);
      70           14 : }
      71              : 
      72            1 : void GlobalMinimalMdnsServer::ShutdownServer()
      73              : {
      74            1 :     GlobalMinimalMdnsServer::Server().Shutdown();
      75            1 : }
      76              : 
      77              : } // namespace Dnssd
      78              : } // namespace chip
        

Generated by: LCOV version 2.0-1