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 : #include "someip/RpcSomeIpStack.h"
12 :
13 : #include "someip/IDiagnosticListener.h"
14 : #include "someip/NetworkConfig.h"
15 :
16 : namespace someip
17 : {
18 : // 4127: These are not output parameters. We pass references to member variables
19 : // for initialization purposes.
20 3 : RpcSomeIpStack::RpcSomeIpStack(
21 : async::ContextType& ethernetContext,
22 : NetworkConfig& networkConfig,
23 : SubscriptionManager& subscriptionManager,
24 : ServiceManager& serviceManager,
25 : ServiceTracker& serviceTracker,
26 : TpTransceiver& tpTransceiver,
27 : BufferedEventSender& eventSender,
28 : RpcReceiver& rpcReceiver,
29 : EventTransceiver& eventTransceiver,
30 3 : IDiagnosticListener const* const /*diagnosticListener*/)
31 : : SomeIpStack(_network, _rpcHandler, eventTransceiver, eventTransceiver, _serviceRegistry)
32 3 : , _subscriptionManager(subscriptionManager)
33 3 : , _serviceManager(serviceManager)
34 3 : , _serviceTracker(serviceTracker)
35 3 : , _tpTransceiver(tpTransceiver)
36 3 : , _eventSender(eventSender)
37 3 : , _rpcReceiver(rpcReceiver)
38 3 : , _serviceRegistry(_serviceManager, _serviceTracker)
39 3 : , _network(networkConfig)
40 3 : , _eventTransceiver(eventTransceiver)
41 6 : , _rpcHandler(_network, ethernetContext, _tpTransceiver, _serviceManager, _serviceRegistry)
42 3 : {}
43 :
44 1 : bool RpcSomeIpStack::addRemoteService(ServiceDescription const& service)
45 : {
46 1 : return _serviceTracker.addService(service);
47 : }
48 :
49 1 : void RpcSomeIpStack::removeRemoteService(ServiceDescription const& service)
50 : {
51 1 : _serviceTracker.removeService(service);
52 1 : }
53 :
54 1 : bool RpcSomeIpStack::addSubscription(ServiceDescription const& service)
55 : {
56 : return (
57 : ISubscriptionManager::InternalSubscribeResult::INTERNAL_SUBSCRIBE_ERROR
58 2 : != _subscriptionManager.addSubscription(
59 1 : service.serviceId,
60 1 : service.majorVersion,
61 1 : service.instanceId,
62 1 : service.eventGroup,
63 1 : service.ttl,
64 1 : service.ipAddress,
65 1 : service.port));
66 : }
67 :
68 1 : void RpcSomeIpStack::removeSubscription(ServiceDescription const& service)
69 : {
70 1 : _subscriptionManager.removeSubscription(
71 1 : service.serviceId,
72 1 : service.majorVersion,
73 1 : service.instanceId,
74 1 : service.eventGroup,
75 1 : service.ipAddress,
76 1 : service.port);
77 1 : }
78 :
79 : // virtual
80 1 : bool RpcSomeIpStack::doInit()
81 : {
82 1 : _serviceRegistry.init();
83 1 : _rpcReceiver.init();
84 1 : _eventSender.init();
85 :
86 1 : return true;
87 : }
88 :
89 : // virtual
90 1 : void RpcSomeIpStack::doShutdown()
91 : {
92 1 : _eventSender.shutdown();
93 1 : _eventTransceiver.shutdown();
94 1 : _rpcReceiver.shutdown();
95 1 : }
96 :
97 : // virtual
98 1 : bool RpcSomeIpStack::doStart() { return _network.start(); }
99 :
100 : // virtual
101 1 : void RpcSomeIpStack::doStop()
102 : {
103 1 : _subscriptionManager.stop();
104 1 : _tpTransceiver.stop();
105 1 : _network.stop();
106 1 : }
107 :
108 : } // namespace someip
|