Matter SDK Coverage Report
Current view: top level - transport - GroupSession.h (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 3.1 % 32 1
Test Date: 2025-01-17 19:00:11 Functions: 5.6 % 18 1

            Line data    Source code
       1              : /*
       2              :  *    Copyright (c) 2021 Project CHIP Authors
       3              :  *
       4              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       5              :  *    you may not use this file except in compliance with the License.
       6              :  *    You may obtain a copy of the License at
       7              :  *
       8              :  *        http://www.apache.org/licenses/LICENSE-2.0
       9              :  *
      10              :  *    Unless required by applicable law or agreed to in writing, software
      11              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      12              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              :  *    See the License for the specific language governing permissions and
      14              :  *    limitations under the License.
      15              :  */
      16              : 
      17              : #pragma once
      18              : 
      19              : #include <app/util/basic-types.h>
      20              : #include <lib/core/GroupId.h>
      21              : #include <lib/core/ReferenceCounted.h>
      22              : #include <lib/support/Pool.h>
      23              : #include <transport/Session.h>
      24              : 
      25              : namespace chip {
      26              : namespace Transport {
      27              : 
      28              : class IncomingGroupSession : public Session, public ReferenceCounted<IncomingGroupSession, NoopDeletor<IncomingGroupSession>, 0>
      29              : {
      30              : public:
      31            0 :     IncomingGroupSession(GroupId group, FabricIndex fabricIndex, NodeId peerNodeId) : mGroupId(group), mPeerNodeId(peerNodeId)
      32              :     {
      33            0 :         SetFabricIndex(fabricIndex);
      34            0 :     }
      35            0 :     ~IncomingGroupSession() override
      36            0 :     {
      37            0 :         NotifySessionReleased();
      38            0 :         VerifyOrDie(GetReferenceCount() == 0);
      39            0 :     }
      40              : 
      41            0 :     void Retain() override { ReferenceCounted<IncomingGroupSession, NoopDeletor<IncomingGroupSession>, 0>::Retain(); }
      42            0 :     void Release() override { ReferenceCounted<IncomingGroupSession, NoopDeletor<IncomingGroupSession>, 0>::Release(); }
      43              : 
      44            0 :     bool IsActiveSession() const override { return true; }
      45              : 
      46            0 :     Session::SessionType GetSessionType() const override { return Session::SessionType::kGroupIncoming; }
      47              : 
      48            0 :     ScopedNodeId GetPeer() const override { return ScopedNodeId(mPeerNodeId, GetFabricIndex()); }
      49            0 :     ScopedNodeId GetLocalScopedNodeId() const override { return ScopedNodeId(kUndefinedNodeId, GetFabricIndex()); }
      50              : 
      51            0 :     Access::SubjectDescriptor GetSubjectDescriptor() const override
      52              :     {
      53            0 :         Access::SubjectDescriptor subjectDescriptor;
      54            0 :         subjectDescriptor.authMode    = Access::AuthMode::kGroup;
      55            0 :         subjectDescriptor.subject     = NodeIdFromGroupId(mGroupId);
      56            0 :         subjectDescriptor.fabricIndex = GetFabricIndex();
      57            0 :         return subjectDescriptor;
      58              :     }
      59              : 
      60            0 :     bool AllowsMRP() const override { return false; }
      61            0 :     bool AllowsLargePayload() const override { return false; }
      62              : 
      63            0 :     const SessionParameters & GetRemoteSessionParameters() const override
      64              :     {
      65            0 :         static const SessionParameters cfg(GetDefaultMRPConfig());
      66            0 :         VerifyOrDie(false);
      67              :         return cfg;
      68              :     }
      69              : 
      70            0 :     System::Clock::Timestamp GetMRPBaseTimeout() const override { return System::Clock::kZero; }
      71              : 
      72            0 :     System::Clock::Milliseconds32 GetAckTimeout() const override
      73              :     {
      74            0 :         VerifyOrDie(false);
      75              :         return System::Clock::Timeout();
      76              :     }
      77              : 
      78            0 :     System::Clock::Milliseconds32 GetMessageReceiptTimeout(System::Clock::Timestamp ourLastActivity) const override
      79              :     {
      80              :         // There are no timeouts for group sessions.
      81            0 :         VerifyOrDie(false);
      82              :         return System::Clock::Timeout();
      83              :     }
      84              : 
      85            0 :     GroupId GetGroupId() const { return mGroupId; }
      86              : 
      87              : private:
      88              :     const GroupId mGroupId;
      89              :     const NodeId mPeerNodeId;
      90              : };
      91              : 
      92              : class OutgoingGroupSession : public Session, public ReferenceCounted<OutgoingGroupSession, NoopDeletor<OutgoingGroupSession>, 0>
      93              : {
      94              : public:
      95              :     OutgoingGroupSession(GroupId group, FabricIndex fabricIndex) : mGroupId(group) { SetFabricIndex(fabricIndex); }
      96              :     ~OutgoingGroupSession() override
      97              :     {
      98              :         NotifySessionReleased();
      99              :         VerifyOrDie(GetReferenceCount() == 0);
     100              :     }
     101              : 
     102              :     void Retain() override { ReferenceCounted<OutgoingGroupSession, NoopDeletor<OutgoingGroupSession>, 0>::Retain(); }
     103              :     void Release() override { ReferenceCounted<OutgoingGroupSession, NoopDeletor<OutgoingGroupSession>, 0>::Release(); }
     104              : 
     105              :     bool IsActiveSession() const override { return true; }
     106              : 
     107              :     Session::SessionType GetSessionType() const override { return Session::SessionType::kGroupOutgoing; }
     108              : 
     109              :     // Peer node ID is unused: users care about the group, not the node
     110              :     ScopedNodeId GetPeer() const override { return ScopedNodeId(); }
     111              :     // Local node ID is unused: users care about the group, not the node
     112              :     ScopedNodeId GetLocalScopedNodeId() const override { return ScopedNodeId(); }
     113              : 
     114              :     Access::SubjectDescriptor GetSubjectDescriptor() const override
     115              :     {
     116              :         return Access::SubjectDescriptor(); // no subject exists for outgoing group session.
     117              :     }
     118              : 
     119              :     bool AllowsMRP() const override { return false; }
     120              :     bool AllowsLargePayload() const override { return false; }
     121              : 
     122              :     const SessionParameters & GetRemoteSessionParameters() const override
     123              :     {
     124              :         static const SessionParameters cfg(GetDefaultMRPConfig());
     125              :         VerifyOrDie(false);
     126              :         return cfg;
     127              :     }
     128              : 
     129              :     System::Clock::Timestamp GetMRPBaseTimeout() const override { return System::Clock::kZero; }
     130              : 
     131              :     System::Clock::Milliseconds32 GetAckTimeout() const override
     132              :     {
     133              :         VerifyOrDie(false);
     134              :         return System::Clock::Timeout();
     135              :     }
     136              : 
     137              :     System::Clock::Milliseconds32 GetMessageReceiptTimeout(System::Clock::Timestamp ourLastActivity) const override
     138              :     {
     139              :         // There are no timeouts for group sessions.
     140              :         VerifyOrDie(false);
     141              :         return System::Clock::Timeout();
     142              :     }
     143              : 
     144            6 :     GroupId GetGroupId() const { return mGroupId; }
     145              : 
     146              : private:
     147              :     const GroupId mGroupId;
     148              : };
     149              : 
     150              : } // namespace Transport
     151              : } // namespace chip
        

Generated by: LCOV version 2.0-1