Matter SDK Coverage Report
Current view: top level - inet - UDPEndPointImplSockets.h (source / functions) Coverage Total Hit
Test: SHA:4d2388ac7eed75b2fe5e05e20de377999c632502 Lines: 100.0 % 3 3
Test Date: 2025-07-26 07:12:52 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2020-2021 Project CHIP Authors
       4              :  *    Copyright (c) 2018 Google LLC
       5              :  *    Copyright (c) 2013-2017 Nest Labs, Inc.
       6              :  *
       7              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       8              :  *    you may not use this file except in compliance with the License.
       9              :  *    You may obtain a copy of the License at
      10              :  *
      11              :  *        http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  *    Unless required by applicable law or agreed to in writing, software
      14              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      15              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  *    See the License for the specific language governing permissions and
      17              :  *    limitations under the License.
      18              :  */
      19              : 
      20              : /**
      21              :  * This file declares an implementation of Inet::UDPEndPoint using sockets.
      22              :  */
      23              : 
      24              : #pragma once
      25              : 
      26              : #include <inet/EndPointStateSockets.h>
      27              : #include <inet/UDPEndPoint.h>
      28              : 
      29              : namespace chip {
      30              : namespace Inet {
      31              : 
      32              : class UDPEndPointImplSockets : public UDPEndPoint, public EndPointStateSockets
      33              : {
      34              : public:
      35           65 :     UDPEndPointImplSockets(EndPointManager<UDPEndPoint> & endPointManager) :
      36           65 :         UDPEndPoint(endPointManager), mBoundIntfId(InterfaceId::Null())
      37           65 :     {}
      38              : 
      39              :     // UDPEndPoint overrides.
      40              :     CHIP_ERROR SetMulticastLoopback(IPVersion aIPVersion, bool aLoopback) override;
      41              :     InterfaceId GetBoundInterface() const override;
      42              :     uint16_t GetBoundPort() const override;
      43              :     void Free() override;
      44              : 
      45              : private:
      46              :     // UDPEndPoint overrides.
      47              : #if INET_CONFIG_ENABLE_IPV4
      48              :     CHIP_ERROR IPv4JoinLeaveMulticastGroupImpl(InterfaceId aInterfaceId, const IPAddress & aAddress, bool join) override;
      49              : #endif // INET_CONFIG_ENABLE_IPV4
      50              :     CHIP_ERROR IPv6JoinLeaveMulticastGroupImpl(InterfaceId aInterfaceId, const IPAddress & aAddress, bool join) override;
      51              :     CHIP_ERROR BindImpl(IPAddressType addressType, const IPAddress & address, uint16_t port, InterfaceId interfaceId) override;
      52              :     CHIP_ERROR BindInterfaceImpl(IPAddressType addressType, InterfaceId interfaceId) override;
      53              :     CHIP_ERROR ListenImpl() override;
      54              :     CHIP_ERROR SendMsgImpl(const IPPacketInfo * pktInfo, chip::System::PacketBufferHandle && msg) override;
      55              :     void CloseImpl() override;
      56              : 
      57              :     CHIP_ERROR GetSocket(IPAddressType addressType);
      58              :     void HandlePendingIO(System::SocketEvents events);
      59              :     static void HandlePendingIO(System::SocketEvents events, intptr_t data);
      60              : 
      61              :     InterfaceId mBoundIntfId;
      62              :     uint16_t mBoundPort;
      63              : 
      64              : #if CHIP_SYSTEM_CONFIG_USE_PLATFORM_MULTICAST_API
      65              : public:
      66              :     enum class MulticastOperation
      67              :     {
      68              :         kJoin,
      69              :         kLeave
      70              :     };
      71              : 
      72              :     using MulticastGroupHandler = CHIP_ERROR (*)(InterfaceId, const IPAddress &, MulticastOperation operation);
      73              : 
      74              :     static void SetMulticastGroupHandler(MulticastGroupHandler handler) { sMulticastGroupHandler = handler; }
      75              : 
      76              : private:
      77              :     static MulticastGroupHandler sMulticastGroupHandler;
      78              : #endif // CHIP_SYSTEM_CONFIG_USE_PLATFORM_MULTICAST_API
      79              : };
      80              : 
      81              : using UDPEndPointImpl = UDPEndPointImplSockets;
      82              : 
      83              : } // namespace Inet
      84              : } // namespace chip
        

Generated by: LCOV version 2.0-1