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/ISomeIpSerializable.h"
14 : #include "someip/RpcClosure.h"
15 : #include "someip/SomeIpConstants.h"
16 :
17 : #include <async/Types.h>
18 :
19 : #include <etl/expected.h>
20 : #include <etl/intrusive_links.h>
21 : #include <cstdint>
22 :
23 : namespace ip
24 : {
25 : class IPEndpoint;
26 : } /* namespace ip */
27 :
28 : namespace someip
29 : {
30 : class IRpcChannel : public ::etl::forward_link<0>
31 : {
32 : public:
33 23 : IRpcChannel() = default;
34 :
35 : IRpcChannel(IRpcChannel const&) = delete;
36 : IRpcChannel& operator=(IRpcChannel const&) = delete;
37 :
38 : /**
39 : * Pure virtual function that returns service ID.
40 : */
41 : virtual service_id::type getServiceId() const = 0;
42 :
43 : /**
44 : * Pure virtual function that returns client ID.
45 : */
46 : virtual uint16_t getClientId() const = 0;
47 :
48 : /**
49 : * Pure virtual function that returns session ID.
50 : */
51 : virtual uint16_t getSessionId() const = 0;
52 :
53 : /**
54 : * Pure virtual function that sets session ID.
55 : */
56 : virtual void setSessionId(uint16_t sessionId) = 0;
57 :
58 : /**
59 : * Pure virtual function that returns remoteEndpoint.
60 : */
61 : virtual ::ip::IPEndpoint const& getRemoteIp() const = 0;
62 :
63 : /**
64 : * Pure virtual function that returns local port.
65 : */
66 : virtual ::etl::expected<uint16_t, PortError> getLocalPort() const = 0;
67 :
68 : /**
69 : * Pure virtual function that returns protocol version.
70 : */
71 : virtual uint8_t getProto() const = 0;
72 :
73 : /**
74 : * Pure virtual function that cancels the internal timeout.
75 : */
76 : virtual void cancelTimeout() = 0;
77 :
78 : /**
79 : * Pure virtual function that sets the internal timeout.
80 : */
81 : virtual void setTimeout(::async::ContextType const context, uint32_t timeout) = 0;
82 :
83 : /**
84 : * Pure virtual function that handles calling of specified method
85 : * within given timeout if possible. CallDoneClosure is used for storing
86 : * possible response data.
87 : */
88 : virtual ServiceResultCode callMethod(
89 : uint16_t methodId,
90 : ISomeIpSerializable const* pRequest,
91 : uint8_t interfaceVersion,
92 : ISomeIpSerializable* pResponse,
93 : CallDoneClosure& done,
94 : uint32_t timeout)
95 : = 0;
96 :
97 : /**
98 : * Pure virtual function that handles fire and forget method calling.
99 : */
100 : virtual ServiceResultCode callFireAndForgetMethod(
101 : uint16_t methodId, ISomeIpSerializable const* pRequest, uint8_t interfaceVersion)
102 : = 0;
103 :
104 : /**
105 : * Pure virtual function that returns response if available.
106 : */
107 : virtual ISomeIpSerializable* getResponse() = 0;
108 :
109 : /**
110 : * Pure virtual function that can be used for processing of response result.
111 : */
112 : virtual void responseReceived(ServiceResultCode result) = 0;
113 :
114 : protected:
115 : ~IRpcChannel() = default;
116 : };
117 :
118 : } // namespace someip
|