LCOV - code coverage report
Current view: top level - transport - TransportMgrBase.cpp (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 17 28 60.7 %
Date: 2024-02-15 08:20:41 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2020-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             :  */
      16             : 
      17             : #include <transport/TransportMgrBase.h>
      18             : 
      19             : #include <lib/support/CodeUtils.h>
      20             : #include <platform/LockTracker.h>
      21             : #include <transport/TransportMgr.h>
      22             : #include <transport/raw/Base.h>
      23             : 
      24             : namespace chip {
      25             : 
      26        9619 : CHIP_ERROR TransportMgrBase::SendMessage(const Transport::PeerAddress & address, System::PacketBufferHandle && msgBuf)
      27             : {
      28        9619 :     return mTransport->SendMessage(address, std::move(msgBuf));
      29             : }
      30             : 
      31           0 : void TransportMgrBase::Disconnect(const Transport::PeerAddress & address)
      32             : {
      33           0 :     mTransport->Disconnect(address);
      34           0 : }
      35             : 
      36          40 : CHIP_ERROR TransportMgrBase::Init(Transport::Base * transport)
      37             : {
      38          40 :     if (mTransport != nullptr)
      39             :     {
      40           0 :         return CHIP_ERROR_INCORRECT_STATE;
      41             :     }
      42          40 :     mTransport = transport;
      43          40 :     mTransport->SetDelegate(this);
      44          40 :     ChipLogDetail(Inet, "TransportMgr initialized");
      45          40 :     return CHIP_NO_ERROR;
      46             : }
      47             : 
      48          35 : void TransportMgrBase::Close()
      49             : {
      50          35 :     mSessionManager = nullptr;
      51          35 :     mTransport      = nullptr;
      52          35 : }
      53             : 
      54           0 : CHIP_ERROR TransportMgrBase::MulticastGroupJoinLeave(const Transport::PeerAddress & address, bool join)
      55             : {
      56           0 :     return mTransport->MulticastGroupJoinLeave(address, join);
      57             : }
      58             : 
      59        9508 : void TransportMgrBase::HandleMessageReceived(const Transport::PeerAddress & peerAddress, System::PacketBufferHandle && msg)
      60             : {
      61             :     // This is the first point all incoming messages funnel through.  Ensure
      62             :     // that our message receipts are all synchronized correctly.
      63        9508 :     assertChipStackLockedByCurrentThread();
      64             : 
      65        9508 :     if (msg->HasChainedBuffer())
      66             :     {
      67             :         // Something in the lower levels messed up.
      68             :         char addrBuffer[Transport::PeerAddress::kMaxToStringSize];
      69           0 :         peerAddress.ToString(addrBuffer);
      70           0 :         ChipLogError(Inet, "message from %s dropped due to lower layers not ensuring a single packet buffer.", addrBuffer);
      71           0 :         return;
      72             :     }
      73             : 
      74        9508 :     if (mSessionManager != nullptr)
      75             :     {
      76        9508 :         mSessionManager->OnMessageReceived(peerAddress, std::move(msg));
      77             :     }
      78             :     else
      79             :     {
      80             :         char addrBuffer[Transport::PeerAddress::kMaxToStringSize];
      81           0 :         peerAddress.ToString(addrBuffer);
      82           0 :         ChipLogError(Inet, "message from %s is dropped since no corresponding handler is set in TransportMgr.", addrBuffer);
      83             :     }
      84             : }
      85             : 
      86             : } // namespace chip

Generated by: LCOV version 1.14