LCOV - code coverage report
Current view: top level - libs/bsw/cpp2someip/include/someip - RpcReceiver.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 3 3
Test Date: 2026-09-11 12:05:06 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /********************************************************************************
       2              :  * Copyright (c) 2026 Accenture
       3              :  *
       4              :  * This program and the accompanying materials are made available under the
       5              :  * terms of the Apache License Version 2.0 which is available at
       6              :  * https://www.apache.org/licenses/LICENSE-2.0
       7              :  *
       8              :  * SPDX-License-Identifier: Apache-2.0
       9              :  ********************************************************************************/
      10              : 
      11              : #pragma once
      12              : 
      13              : #include "someip/IDiagnosticListener.h"
      14              : #include "someip/INetwork.h"
      15              : #include "someip/INetworkListener.h"
      16              : #include "someip/IRpcHandler.h"
      17              : #include "someip/IRpcReceiver.h"
      18              : #include "someip/ITpListener.h"
      19              : #include "someip/ITpTransceiver.h"
      20              : #include "someip/SomeIpMessage.h"
      21              : 
      22              : #include <ip/IPAddress.h>
      23              : #include <ip/IPEndpoint.h>
      24              : 
      25              : #include <etl/flat_set.h>
      26              : #include <etl/vector.h>
      27              : #include <cstdint>
      28              : 
      29              : namespace common
      30              : {
      31              : class ITimeoutManager2;
      32              : }
      33              : 
      34              : namespace someip
      35              : {
      36              : 
      37              : namespace internal
      38              : {
      39              : struct NetworkChannelComparator
      40              : {
      41              :     bool operator()(
      42              :         ::etl::optional<NetworkChannel> const& lhs,
      43              :         ::etl::optional<NetworkChannel> const& rhs) const;
      44              : };
      45              : 
      46              : class FindNetworkChannelCondition
      47              : {
      48              : public:
      49              :     FindNetworkChannelCondition(::ip::IPAddress const& ipAddr, uint16_t port);
      50              :     bool operator()(::etl::optional<NetworkChannel> const& channel) const;
      51              : 
      52              : private:
      53              :     ::ip::IPAddress const& _ip;
      54              :     uint16_t const _port;
      55              : };
      56              : 
      57              : } // namespace internal
      58              : 
      59              : class ITpTransceiver;
      60              : class IServiceRegistry;
      61              : 
      62              : class RpcReceiver
      63              : : public INetworkListener
      64              : , public ITpListener
      65              : , public IRpcReceiver
      66              : {
      67              : public:
      68              :     using MulticastReceptionList
      69              :         = ::etl::iflat_set<::etl::optional<NetworkChannel>, internal::NetworkChannelComparator>;
      70              : 
      71              :     RpcReceiver(
      72              :         INetwork& network,
      73              :         ITpTransceiver& tpTransceiver,
      74              :         IEventReceiver& eventReceiver,
      75              :         IServiceRegistry& serviceRegistry,
      76              :         IRpcHandler& rpcHandler,
      77              :         MulticastReceptionList& multicastReceptionList,
      78              :         IDiagnosticListener* diagnosticListener);
      79              : 
      80              :     void init();
      81              :     void shutdown();
      82              : 
      83              :     /** \see INetworkListener::received */
      84              :     void received(NetworkChannel& channel, uint32_t length) override;
      85              : 
      86              :     /** \see ITpListener::receivedTpMessage */
      87              :     void receivedTpMessage(NetworkChannel& channel, SomeIpMessage const& message) override;
      88              : 
      89              :     /** \see IRpcReceiver::setPriorityRpcHandler() */
      90              :     void setPriorityRpcHandler(IRpcHandler& priorityRpcHandler) override;
      91              : 
      92              :     /** \see IRpcReceiver::removePriorityRpcHandler() */
      93              :     void removePriorityRpcHandler() override;
      94              : 
      95              :     /** \see IRpcReceiver::requestMulticastReception() */
      96              :     bool requestMulticastReception(::ip::IPEndpoint const& multicastEndpoint) override;
      97              : 
      98              :     /** \see IRpcReceiver::cancelMulticastReception() */
      99              :     void cancelMulticastReception(::ip::IPEndpoint const& multicastEndpoint) override;
     100              : 
     101              : private:
     102              :     static bool isMagicCookie(SomeIpMessage const& message);
     103              : 
     104              :     void handleMessage(NetworkChannel& channel, SomeIpMessage const& message);
     105              : 
     106              :     void sendError(
     107              :         NetworkChannel& channel,
     108              :         SomeIpMessage const& message,
     109              :         SomeIpMessage::ReturnCode returnCode);
     110              : 
     111              :     static SomeIpMessage::ReturnCode getSomeipErrorCode(IRpcHandler::ErrorCode error);
     112              : 
     113              :     INetwork& _network;
     114              :     ITpTransceiver& _tpTransceiver;
     115              :     IEventReceiver& _eventReceiver;
     116              :     IDiagnosticListener* _pDiagnosticListener;
     117              :     IServiceRegistry& _serviceRegistry;
     118              :     IRpcHandler& _rpcHandler;
     119              :     IRpcHandler* _pPriorityRpcHandler;
     120              : 
     121              :     MulticastReceptionList& _multicastReceptions;
     122              : };
     123              : 
     124              : namespace declare
     125              : {
     126              : 
     127              : template<uint8_t NUM_MULTICAST_RECEPTIONS>
     128              : class RpcReceiver : public ::someip::RpcReceiver
     129              : {
     130              : public:
     131              :     RpcReceiver(
     132              :         INetwork& network,
     133              :         ITpTransceiver& tpTransceiver,
     134              :         IEventReceiver& eventReceiver,
     135              :         IServiceRegistry& serviceRegistry,
     136              :         IRpcHandler& rpcHandler,
     137              :         IDiagnosticListener* diagnosticListener);
     138              : 
     139              : private:
     140              :     ::etl::flat_set<
     141              :         ::etl::optional<NetworkChannel>,
     142              :         (NUM_MULTICAST_RECEPTIONS > 0U ? NUM_MULTICAST_RECEPTIONS : 1U),
     143              :         internal::NetworkChannelComparator>
     144              :         _multicastReceptionList;
     145              : };
     146              : 
     147              : template<uint8_t NUM_MULTICAST_RECEPTIONS>
     148            6 : inline RpcReceiver<NUM_MULTICAST_RECEPTIONS>::RpcReceiver(
     149              :     INetwork& network,
     150              :     ITpTransceiver& tpTransceiver,
     151              :     IEventReceiver& eventReceiver,
     152              :     IServiceRegistry& serviceRegistry,
     153              :     IRpcHandler& rpcHandler,
     154              :     IDiagnosticListener* const diagnosticListener)
     155              : : ::someip::RpcReceiver(
     156              :     network,
     157              :     tpTransceiver,
     158              :     eventReceiver,
     159              :     serviceRegistry,
     160              :     rpcHandler,
     161              :     _multicastReceptionList,
     162              :     diagnosticListener)
     163            6 : , _multicastReceptionList()
     164            6 : {}
     165              : 
     166              : } // namespace declare
     167              : 
     168              : } // namespace someip
        

Generated by: LCOV version 2.0-1