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/BufferedEventSender.h"
14 : #include "someip/EventTransceiver.h"
15 : #include "someip/Network.h"
16 : #include "someip/NetworkConfig.h"
17 : #include "someip/RpcHandler.h"
18 : #include "someip/RpcReceiver.h"
19 : #include "someip/RpcServiceRegistry.h"
20 : #include "someip/ServiceDescription.h"
21 : #include "someip/ServiceManager.h"
22 : #include "someip/ServiceTracker.h"
23 : #include "someip/SomeIpStack.h"
24 : #include "someip/SubscriptionManager.h"
25 : #include "someip/TpTransceiver.h"
26 :
27 : #include <async/Types.h>
28 :
29 : #include <ip/IPAddress.h>
30 :
31 : namespace someip
32 : {
33 : /**
34 : * The SOME/IP Stack with RPC only.
35 : */
36 : class RpcSomeIpStack : public SomeIpStack
37 : {
38 : public:
39 : /* CLIENT */
40 :
41 : bool addRemoteService(ServiceDescription const& service);
42 : void removeRemoteService(ServiceDescription const& service);
43 :
44 : /* SERVER */
45 :
46 : bool addSubscription(ServiceDescription const& service);
47 : void removeSubscription(ServiceDescription const& service);
48 :
49 : private:
50 : SubscriptionManager& _subscriptionManager;
51 : ServiceManager& _serviceManager;
52 : ServiceTracker& _serviceTracker;
53 : TpTransceiver& _tpTransceiver;
54 : BufferedEventSender& _eventSender;
55 : RpcReceiver& _rpcReceiver;
56 :
57 : protected:
58 : RpcServiceRegistry _serviceRegistry;
59 : RpcSomeIpStack(
60 : async::ContextType& ethernetContext,
61 : NetworkConfig& networkConfig,
62 : SubscriptionManager& subscriptionManager,
63 : ServiceManager& serviceManager,
64 : ServiceTracker& serviceTracker,
65 : TpTransceiver& tpTransceiver,
66 : BufferedEventSender& eventSender,
67 : RpcReceiver& rpcReceiver,
68 : EventTransceiver& eventTransceiver,
69 : IDiagnosticListener const* diagnosticListener = nullptr);
70 :
71 : bool doInit() override;
72 : bool doStart() override;
73 : void doStop() override;
74 : void doShutdown() override;
75 :
76 : Network _network;
77 : EventTransceiver& _eventTransceiver;
78 : RpcHandler _rpcHandler;
79 : };
80 :
81 : namespace declare
82 : {
83 :
84 : /**
85 : * Declares a SOME/IP Stack with RPC only.
86 : */
87 : template<
88 : uint16_t NumRemoteServices,
89 : uint16_t NumRemoteSubscriptions,
90 : uint16_t NumLocalServices,
91 : uint8_t NumSubscriptionEndpoints,
92 : uint8_t NumEventBuffers = 0,
93 : uint8_t NumMulticastReceptions = 0>
94 : class RpcSomeIpStack : public ::someip::RpcSomeIpStack
95 : {
96 : public:
97 : RpcSomeIpStack(async::ContextType& ethernetContext, NetworkConfig& networkConfig);
98 :
99 : private:
100 : ::someip::declare::SubscriptionManager<NumRemoteSubscriptions> _subscriptionManager;
101 : ::someip::declare::ServiceManager<NumLocalServices> _serviceManager;
102 : ::someip::declare::ServiceTracker<NumRemoteServices> _serviceTracker;
103 : TpTransceiver _tpTransceiver;
104 : ::someip::declare::BufferedEventSender<NumEventBuffers> _eventSender;
105 : ::someip::declare::RpcReceiver<NumMulticastReceptions> _rpcReceiver;
106 : ::someip::declare::EventTransceiver<NumSubscriptionEndpoints> _eventTransceiver;
107 : };
108 :
109 : template<
110 : uint16_t NumRemoteServices,
111 : uint16_t NumRemoteSubscriptions,
112 : uint16_t NumLocalServices,
113 : uint8_t NumSubscriptionEndpoints,
114 : uint8_t NumEventBuffers,
115 : uint8_t NumMulticastReceptions>
116 3 : inline RpcSomeIpStack<
117 : NumRemoteServices,
118 : NumRemoteSubscriptions,
119 : NumLocalServices,
120 : NumSubscriptionEndpoints,
121 : NumEventBuffers,
122 : NumMulticastReceptions>::
123 : RpcSomeIpStack(async::ContextType& ethernetContext, NetworkConfig& networkConfig)
124 : : ::someip::RpcSomeIpStack(
125 : ethernetContext,
126 : networkConfig,
127 : _subscriptionManager,
128 : _serviceManager,
129 : _serviceTracker,
130 3 : _tpTransceiver,
131 : _eventSender,
132 : _rpcReceiver,
133 : _eventTransceiver)
134 3 : , _subscriptionManager()
135 3 : , _serviceManager()
136 3 : , _serviceTracker()
137 3 : , _tpTransceiver(
138 3 : ethernetContext, networkConfig._tpConfig.tpSenders, networkConfig._tpConfig.tpReceivers)
139 3 : , _eventSender(_network, ethernetContext, _tpTransceiver)
140 3 : , _rpcReceiver(_network, _tpTransceiver, _eventTransceiver, _serviceRegistry, _rpcHandler, nullptr)
141 6 : , _eventTransceiver(_eventSender, _subscriptionManager)
142 3 : {}
143 :
144 : } // namespace declare
145 : } // namespace someip
|