Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
someip_message.h
1#ifndef SOMEIP_MESSAGE_H
2#define SOMEIP_MESSAGE_H
3
4#include <stdint.h>
5#include <stdexcept>
6#include <vector>
7#include <limits>
8#include "../helper/payload_helper.h"
9
10namespace ara
11{
12 namespace com
13 {
14 namespace someip
15 {
17 enum class SomeIpMessageType : uint8_t
18 {
19 Request = 0x00,
20 RequestNoReturn = 0x01,
21 Notification = 0x02,
22 Response = 0x80,
23 Error = 0x81,
24 TpRequest = 0x20,
25 TpRequestNoReturn = 0x21,
26 TpNotification = 0x22,
27 TpResponse = 0xa0,
28 TpError = 0xa1
29 };
30
32 enum class SomeIpReturnCode : uint8_t
33 {
34 eOK,
35 eNotOk,
36 eUnknownService,
37 eUnknownMethod,
38 eNotReady,
39 eNotReachable,
40 eTimeout,
41 eWrongProtocolVersion,
42 eWrongInterfaceVersion,
43 eMalformedMessage,
44 eWrongMessageType,
45 eE2eRepeated,
46 eE2eWrongSequnece,
47 eE2e,
48 eE2eNotAvailable,
49 eE2eNoNewData
50 };
51
54 {
55 private:
56 uint32_t mMessageId;
57 uint16_t mClientId;
58 uint16_t mSessionId;
59 uint8_t mProtocolVersion;
60 uint8_t mInterfaceVersion;
61 SomeIpMessageType mMessageType;
62 SomeIpReturnCode mReturnCode;
63
64 SomeIpMessage(uint32_t messageId,
65 uint16_t clientId,
66 uint16_t sessionId,
67 uint8_t protocolVersion,
68 uint8_t interfaceVersion,
69 SomeIpMessageType messageType,
70 SomeIpReturnCode returnCode) noexcept;
71
72 protected:
80 SomeIpMessage(uint32_t messageId,
81 uint16_t clientId,
82 uint8_t protocolVersion,
83 uint8_t interfaceVersion,
84 SomeIpMessageType messageType,
85 uint16_t sessionId = 1);
86
95 SomeIpMessage(uint32_t messageId,
96 uint16_t clientId,
97 uint8_t protocolVersion,
98 uint8_t interfaceVersion,
99 SomeIpMessageType messageType,
100 SomeIpReturnCode returnCode,
101 uint16_t sessionId = 1);
102
106 static void Deserialize(
107 SomeIpMessage *message,
108 const std::vector<uint8_t> &payload);
109
110 public:
111 SomeIpMessage(SomeIpMessage&& other) noexcept;
112 virtual ~SomeIpMessage() noexcept = default;
113
114 SomeIpMessage& operator=(SomeIpMessage&& other);
115
118 uint32_t MessageId() const noexcept;
119
122 virtual uint32_t Length() const noexcept = 0;
123
126 uint16_t ClientId() const noexcept;
127
130 uint16_t SessionId() const noexcept;
131
134 virtual void SetSessionId(uint16_t sessionId);
135
139 virtual bool IncrementSessionId() noexcept;
140
143 uint8_t ProtocolVersion() const noexcept;
144
147 uint8_t InterfaceVersion() const noexcept;
148
151 SomeIpMessageType MessageType() const noexcept;
152
155 SomeIpReturnCode ReturnCode() const noexcept;
156
159 virtual std::vector<uint8_t> Payload() const;
160 };
161 }
162 }
163}
164
165#endif
SOME/IP Abstract Message.
Definition: someip_message.h:54
uint16_t ClientId() const noexcept
Get client ID.
Definition: someip_message.cpp:126
virtual uint32_t Length() const noexcept=0
Get message length.
SomeIpReturnCode ReturnCode() const noexcept
Get return code.
Definition: someip_message.cpp:173
virtual void SetSessionId(uint16_t sessionId)
Set a new session ID.
Definition: someip_message.cpp:136
SomeIpMessageType MessageType() const noexcept
Get message type.
Definition: someip_message.cpp:168
uint8_t InterfaceVersion() const noexcept
Get interface version.
Definition: someip_message.cpp:163
virtual bool IncrementSessionId() noexcept
Increment the session ID by one.
Definition: someip_message.cpp:141
uint32_t MessageId() const noexcept
Get message ID.
Definition: someip_message.cpp:121
static void Deserialize(SomeIpMessage *message, const std::vector< uint8_t > &payload)
Deserialize a SOME/IP message payload.
Definition: someip_message.cpp:99
virtual std::vector< uint8_t > Payload() const
Get message payload.
Definition: someip_message.cpp:178
uint8_t ProtocolVersion() const noexcept
Get protocol version.
Definition: someip_message.cpp:158
uint16_t SessionId() const noexcept
Get session ID.
Definition: someip_message.cpp:131