ADTF Device Toolbox SDK
Loading...
Searching...
No Matches
someip_types.h
Go to the documentation of this file.
1
16
17#pragma once
18
19#include <stdint.h>
20#include <stddef.h>
21#include <array>
22
26namespace adtf
27{
31namespace devicetb
32{
36namespace sdk
37{
41namespace someip
42{
46namespace brake
47{
48
52enum class tMessageType : uint8_t
53{
54 // Basic request, expect response with MT_RESPONSE
55 MT_REQUEST = 0x00,
56 // Fire&forget flag if MT_RESPONSE is not set, error flag if MT_RESPONSE is set
57 MT_REQUEST_NO_RETURN = 0x01,
58 // Notification flag, no response expected
59 MT_NOTIFICATION = 0x02,
60 // Response flag
61 MT_RESPONSE = 0x80,
62 // Error, indicated by combination of MT_RESPONSE and MT_REQUEST_NO_RETURN
63 MT_ERROR = 0x81,
64
65 // Ack flag, found on empty messages, may be combined with all other types
66 MT_REQUEST_ACK = 0x40,
67 MT_REQUEST_NO_RETURN_ACK = 0x41,
68 MT_NOTIFICATION_ACK = 0x42,
69 MT_RESPONSE_ACK = 0xC0,
70 MT_ERROR_ACK = 0xC1,
71
72 // Flag indicating message segmentation - may be combined with all other types
73 MT_TP_REQUEST = 0x20,
74 MT_TP_REQUEST_NO_RETURN = 0x21,
75 MT_TP_NOTIFICATION = 0x22,
76 MT_TP_RESPONSE0 = 0xA0,
77 MT_TP_ERROR = 0xA1,
78};
79
85enum class tReturnCode : uint8_t
86{
87 E_OK = 0x00,
88 E_NOT_OK = 0x01,
89 E_UNKNOWN_SERVICE = 0x02,
90 E_UNKNOWN_METHOD = 0x03,
91 E_NOT_READY = 0x04,
92 E_NOT_REACHABLE = 0x05,
93 E_TIMEOUT = 0x06,
94 E_WRONG_PROTOCOL_VERSION = 0x07,
95 E_WRONG_INTERFACE_VERSION = 0x08,
96 E_MALFORMED_MESSAGE = 0x09,
97 E_WRONG_MESSAGE_TYPE = 0x0a,
98 E_RESERVED_MIN = 0x0b,
99 E_RESERVED_MAX = 0x3f
100};
101
111#ifdef WIN32
112#pragma warning(disable:4200)
113#endif
114#pragma pack(push, 1)
116{
117 static_assert (sizeof(bool) == 1, "Unsupported Compiler: sizeof(bool) is greater than 1");
118 uint16_t nVLANId = 0;
119 bool bIsTCP = false;
120 bool bIsIPv6 = false;
121 uint16_t nMessageCount = 0;
122 std::array<uint8_t, 16> aSrcIP = { };
123 std::array<uint8_t, 16> aDstIP = { };
124 uint16_t nSrcPort = 0;
125 uint16_t nDstPort = 0;
126 uint32_t nMessageDataSize = 0;
127 uint8_t aMessageData[0] = { };
128};
129#pragma pack(pop)
130#ifdef WIN32
131#pragma warning(default:4200)
132#endif
133
134
135inline bool operator!=(const tSomeIpSampleHeader& lhs, const tSomeIpSampleHeader& rhs)
136{
137 return
138 lhs.nVLANId != rhs.nVLANId ||
139 lhs.bIsTCP != rhs.bIsTCP ||
140 lhs.bIsIPv6 != rhs.bIsIPv6 ||
141 lhs.nMessageCount != rhs.nMessageCount ||
142 lhs.aSrcIP != rhs.aSrcIP ||
143 lhs.aDstIP != rhs.aDstIP ||
144 lhs.nSrcPort != rhs.nSrcPort ||
145 lhs.nDstPort != rhs.nDstPort ||
146 lhs.nMessageDataSize != rhs.nMessageDataSize;
147}
148
149inline bool operator==(const tSomeIpSampleHeader& lhs, const tSomeIpSampleHeader& rhs)
150{
151 return !(lhs != rhs);
152}
153
154}
159
163namespace hood
164{
165#ifdef WIN32
166#pragma warning(disable:4200)
167#endif
168#pragma pack(push, 1)
169
176{
177 uint16_t nServiceId = 0;
178 // MSB is Flag for Event Id instead of Method Id
179 uint16_t nMethodId = 0;
180 // Number of payload bytes after this header, not including this header itself
181 uint32_t nLength = 0;
182
183 // Returns 32bit header ID in host-byte-order
184 uint32_t GetHeaderId() const {
185 const auto d = reinterpret_cast<const uint8_t*>(&nServiceId);
186 return (static_cast<uint32_t>(d[0]) << 24) + (static_cast<uint32_t>(d[1]) << 16) + (static_cast<uint32_t>(d[2]) << 8) + static_cast<uint32_t>(d[3]);
187 }
188
189 // Returns 32bit length in host-byte-order
190 uint32_t GetLength() const {
191 const auto d = reinterpret_cast<const uint8_t*>(&nLength);
192 return (static_cast<uint32_t>(d[0]) << 24) + (static_cast<uint32_t>(d[1]) << 16) + (static_cast<uint32_t>(d[2]) << 8) + static_cast<uint32_t>(d[3]);
193 }
194};
195
201{
202 static_assert (sizeof(bool) == 1, "Unsupported Compiler: sizeof(bool) is greater than 1");
203 uint16_t nVLANId = 0;
204 bool bIsTCP = false;
205 bool bIsIPv6 = false;
206 uint16_t nMessageCount = 0;
207 uint8_t aSrcIP[16] = { 0 };
208 uint8_t aDstIP[16] = { 0 };
209 uint16_t nSrcPort = 0;
210 uint16_t nDstPort = 0;
211 uint32_t nMessageDataSize = 0;
212};
213static_assert(sizeof(hood::tSomeIpSampleHeader) == sizeof(brake::tSomeIpSampleHeader), "Incompatible header layout");
214
221 uint16_t nClientId = 0;
222 uint16_t nSessionId = 0;
223 uint8_t nProtocolVersion = 0;
224 uint8_t nInterfaceVersion = 0;
225 tMessageType eMessageType = tMessageType::MT_REQUEST;
226 tReturnCode eReturnCode = tReturnCode::E_OK;
227
228 bool IsSegmented() const {
229 return (static_cast<uint8_t>(eMessageType) & static_cast<uint8_t>(tMessageType::MT_TP_REQUEST)) != 0;
230 }
231};
232
238 // Only MSB 28bit are valid, lower 4 bit are reseved for flags and must be treated as 0
239 uint32_t nOffset = 0;
240 // Returns 32bit offset in host-byte-order
241 uint32_t GetOffset() const {
242 const auto d = reinterpret_cast<const uint8_t*>(&nOffset);
243 return (static_cast<uint32_t>(d[0]) << 24) + (static_cast<uint32_t>(d[1]) << 16) + (static_cast<uint32_t>(d[2]) << 8) + static_cast<uint32_t>(d[3] & 0xf0);
244 }
245 bool HasMoreSegments() const {
246 const auto d = reinterpret_cast<const uint8_t*>(&nOffset);
247 return (d[3] & 0x01) != 0;
248 }
249};
250
255{
256 // For all eBasicSignalType::BST_NONE and eBasicSignalType::BST_UNSIGNED
257 uint64_t u;
258 // For all eBasicSignalType::BST_SIGNED
259 int64_t s;
260 // For eBasicSignalType::BST_FLOAT, length 4
261 float f;
262 // For eBasicSignalType::BST_FLOAT, length 8
263 double d;
264};
265
270{
271 // Default value if not present in serialized form
272 uLimitType nDefaultRawValue;
273 // Plausible value range
274 uLimitType nLowerRawLimit;
275 uLimitType nUpperRawLimit;
276};
277
282{
283 // Rule applies if ((raw & nMask) >= nLowerLimit && (raw & nMask) <= nUpperLimit)
284 // Multiple rules can overlap for text-table.
285 // At most a single numeric conversion rule must match at a time - if no numeric rule matches, physical value is invalid.
286 uLimitType nLowerLimit;
287 uLimitType nUpperLimit;
288
289 // Only applicable for eBasicSignalType::BST_NONE and eBasicSignalType::BST_UNSIGNED
290 uint64_t nMask;
291
293 {
294 struct tLinear
295 {
296 // Use for formula physical = nFactor * raw + nOffset
297 // nFactor may be 0, representing a constant
298 double nFactor;
299 double nOffset;
300 } oLinear;
301
303 {
304 // Use for all text-tables (enums, bitfields, error codes etc.)
305 const char* pText;
306 } oTextConstant;
307
308 } oCompuType;
309
310 enum eCompuScaleType : uint8_t
311 {
312 LINEAR = 0,
313 TEXTCONSTANT,
314 } oCompuScaleType;
315};
316
322{
323 // Name of deserialized element
324 const char* pStrElementName;
325 // Named type of deserialized element
326 const char* pStrTypeName;
327
328 // Alignment in serialized form, possibly enforces trailing padding bytes
329 uint8_t nAlignment = 1;
330
331 // Number of bytes used to encode the length field
332 // May be overriden by wrapping TLV!
333 // Length on wire is in bytes - length on on deserialized side has to be emitted as basic type field
334 uint8_t nLengthBytes;
335
336 // Number of direct children to this node, including deserialized-only fields
337 uint32_t nChildren;
338 // Offset to next sibling, 0 if no sibling exists
339 uint32_t nNextSiblingOffset;
340
341 // Adaptive extensions used by Autosar
343 {
344 // Element is prepended with tag in serialized form
345 // 16 bit TLV tag
346 // Wire type is in bit [1:3], data id in bit [4:15], bit [0] is reserved
347 // Wire type fragment of TLV may override child type (length of type, but not encoding!)
348 // TLV tagged element may only have other TLV tagged siblings!
349 // TLV tagged siblings may be reordered!
350 // TLV tags have no representation in deserialized form
351 bool bTlvCoded;
352
353 // True: If data ID is never matched, element may be assumed missing and is default-deserialized
354 // False: Data ID not being matched represents an invalid encoding
355 // Element can't be optional if not TLV coded!
356 // Optional coding is only legal within struct which allow optionals
357 bool bOptional;
358
359 // Data ID fragment of TLV tag
360 uint16_t nDataId;
361
362 enum eTLVWireType : uint8_t
363 {
364 WT_1_BYTE = 0,
365 WT_2_BYTE = 1,
366 WT_4_BYTE = 2,
367 WT_8_BYTE = 3,
368 WT_COMPLEX_DEFAULT_LENGTH = 4,
369 WT_COMPLEX_1_BYTE_LENGTH = 5,
370 WT_COMPLEX_2_BYTE_LENGTH = 6,
371 WT_COMPLEX_4_BYTE_LENGTH = 7
372 };
373 } oTLVProperties;
374
375 enum eSerializationType : uint8_t
376 {
377 ST_BASIC = 0,
378 ST_ARRAY,
379 ST_STRUCT,
380 ST_UNION,
381 ST_CLASSIC
382 };
383 eSerializationType oType = ST_BASIC;
384
386 {
388 {
389 enum eBasicSignalType : uint8_t
390 {
391 BST_NONE = 0,
392 BST_SIGNED,
393 BST_UNSIGNED,
394 BST_FLOAT,
395 BST_BOOLEAN
396 };
397
398 // Contained data type
399 eBasicSignalType nType;
400
401 // Length in bytes
402 // May be overriden if wrapped by TLV!
403 uint8_t nLength;
404
405 bool bByteOrderMotorola;
406
407 tDataConstraint oDataConstraint;
408
409 const tCompuScale* pCompuScales;
410 size_t nCountCompuScales;
411
412 const char* strUnit;
413 } oBasicType;
414
415 // Array type, wraps 1-3 children
416 // First defining deserialization-only basic type for length field, last defining array payload type
417 // Represented in serialized form by length in bytes followed by raw data
418 // Represented in derserialized form by struct containing size and payload[] members
420 {
421 enum eSomeIpArrayType : uint8_t
422 {
423 // Static size - no length field in deserialized form
424 AT_FIXED = 0,
425 // First child is length field in deserialized form
426 AT_LINEAR,
427 AT_SQUARED,
428 // First two children are length fields in deserialized form
429 AT_RECT,
430 // VSA_FULLY_FLEXIBLE is represented by nested AT_LINEAR
431 };
432
433 // Serialized data layout
434 eSomeIpArrayType nType;
435
436 // Max size in primary dimension
437 uint32_t nMaxSizeX;
438 // Max size in secondary dimension, always 1 for AT_FIXED / AT_LINEAR
439 // Equal to primary dimension for AT_SQUARED
440 uint32_t nMaxSizeY;
441 } oArrayType;
442
443 // Structure type, may contain an arbitrary number of children
445 {
446 // See SWS_SomeIpXf_00289, if set, first child exists in deserialized form only and is "availability bitfield"
447 // Only counting optional fields, presence is encoded in: (availabilityBitfield[(pos/8)] & (1<<(pos mod 8))) != 0
448 bool bContainsOptionals;
449 } oStructType;
450
451 // Union type, contains one type selector followed by nChildren possible variants
452 // First child is deserialiaztion only and contains type tag
453 // Remember that type tag is 1-based, and 0 indicates null-type
454 // Represented in serialized form by type tag followed by true union
455 // Represented in deserialized form by struct containing selector and serialized types
456 //
457 // See SWS_SomeIpXf_00285 / SWS_SomeIpXf_00226, semantic of length field differs based on whether TLV tag is also present
458 // With TLV tag present, length includes bytes of type selector
459 // Without TLV tag, length excludes bytes of type selector
461 {
462 } oUnionType;
463
464 // Classic Autosar bit-packed signal
465 // Only child is basic type aligned within this memory region
466 // Not legal if Some/IP transformer is part of transfomer chain
467 // Pure serialization detail, no deserialized equivalent
469 {
470 uint64_t nStartBit;
471 uint64_t nLengthInBit;
472
473 // -1 if not applicable
474 uint64_t nUpdateBitPosition;
475 } oClassicType;
476
477 // Place holder to ensure layout compatbility with future extensions
478 uint8_t _reserved[64];
479 } oDetail;
480 static_assert(sizeof(oDetail) == sizeof(uDetails::_reserved), "tSomeIpSerializationInfo is incompatible with original hood::tSomeIpSerializationInfo");
481 static_assert(alignof(uDetails) == 1, "tSomeIpSerializationInfo is incompatible with original hood::tSomeIpSerializationInfo");
482};
483
488{
489 enum eTransformationType : uint8_t
490 {
491 // Plain alias
492 TT_NONE = 0,
493 // Additional header containing authentification and freshness bits
494 TT_E2E,
495 // Reassembly of multiple messages required to reconstruct the playload
496 // Both input and output payloads follow standard SOME/IP header layout
497 // If referenced by tSomeIpMessageInfo, it must be last element of transformation chain
498 // @warning The referenced child PDU may be ambigous as all message types and interface revisions are wrapped in the same TP PDU.
499 // @warning After reassembly, re-resolve with the tMessageType::MT_TP_REQUEST bit cleared!
500 TT_SOME_IP_SEGMENT,
501 // Standard SOME/IP request header and signal layout
502 TT_SOME_IP_TRANSFORMER,
503 // Variable size service announcement list
504 TT_SOME_IP_SERVICE_DISCOVERY
505 };
506 eTransformationType nTransformationType = TT_NONE;
507
508 // Number of leading bits added by e.g. SOME/IP session header
509 // Should be divisible by 8 in all normal scenarios
510 uint16_t nHeaderBits = 0;
511 // Number of trailing bits added by e.g. E2E authentification header
512 // Should be divisible by 8 in all normal scenarios
513 uint16_t nTrailingBits = 0;
514
515 // If not zero, the transformed message at this step also corresponds to a different message
516 uint32_t nAliasedMessageId;
517
519 {
520 // Place holder to ensure layout compatbility with future extensions
521 uint8_t _reserved[64];
522 } oDetail;
523 static_assert(sizeof(oDetail) == sizeof(uDetails::_reserved), "tSomeIpTransformation is incompatible with original hood::tSomeIpSerializationInfo");
524 static_assert(alignof(uDetails) == 1, "tSomeIpTransformation is incompatible with original hood::tSomeIpSerializationInfo");
525};
526
527
534{
535 // Internal message ID
536 // See tSomeIpSocketMessageInfo instead for the identification of this PDU on a specific socket
537 uint32_t nMessageId = 0;
538
539 const char* pstrName = nullptr;
540 const char* pstrPath = nullptr;
541
542 // Optional fixed message size - if -1 then size is fully dynamic
543 // Actual message size should never exceed this size
544 uint64_t nMessageSizeInBit = 0;
545
546 // Default length bytes for unknown TLV tagged nodes
547 // Explicit specification in TLV wire type and tSomeIpSerializationInfo:::nLengthBytes have precendence
548 uint8_t nDefaultLengthBytes = 0;
549
550 // Transformation directives required to locate payload
551 const tSomeIpTransformation* pTransformationChain = nullptr;
552 size_t nTransformationChainLength = 0;
553
554 // Deserialization directives for the entire payload *after* transformation headers
555 const tSomeIpSerializationInfo* pMembers = nullptr;
556 size_t nMemberCount = 0;
557};
558
562{
563 // Internal ECU ID
564 uint32_t nEcuId = 0;
565
566 const char* pstrName = nullptr;
567 const char* pstrPath = nullptr;
568};
569
575{
576 // Reference to tSomeIpMessageInfo
577 uint32_t nMessageId;
578 // Header Id from ARXML -> SOME/IP Message Header
579 uint32_t nHeaderId;
580};
581
583{
584 uint8_t aIP[16] = { 0 };
585 uint16_t nPort = 0;
586};
587
595{
596 // Internal connection ID
597 uint32_t nConnectionId = 0;
598
599 // Source and desitnation - IP and/or port may be empty if dynamic
600 tSomeIpSocket oSource;
601 tSomeIpSocket oDestination;
602
603 bool bIsUdp = false;
604
605 const tSomeIpSocketMessageInfo* aSocketMessageInfos = nullptr;
606 size_t nSocketMessageInfoCount = 0;
607};
608
613{
614 // Internal channel ID
615 uint32_t nChannelId = 0;
616
617 const char* pstrName = nullptr;
618 const char* pstrPath = nullptr;
619 uint16_t nVLANId = 0;
620};
621
626{
627 // Internal cluster ID
628 uint32_t nClusterId = 0;
629
630 const char* pstrName = nullptr;
631 const char* pstrPath = nullptr;
632};
633#pragma pack(pop)
634#ifdef WIN32
635#pragma warning(default:4200)
636#endif
637
638
639inline bool operator!=(const tSomeIpSampleHeader& lhs, const tSomeIpSampleHeader& rhs)
640{
641 return
642 lhs.nVLANId != rhs.nVLANId ||
643 lhs.bIsTCP != rhs.bIsTCP ||
644 lhs.bIsIPv6 != rhs.bIsIPv6 ||
645 lhs.nMessageCount != rhs.nMessageCount ||
646 lhs.aSrcIP != rhs.aSrcIP ||
647 lhs.aDstIP != rhs.aDstIP ||
648 lhs.nSrcPort != rhs.nSrcPort ||
649 lhs.nDstPort != rhs.nDstPort ||
650 lhs.nMessageDataSize != rhs.nMessageDataSize;
651}
652
653inline bool operator==(const tSomeIpSampleHeader& lhs, const tSomeIpSampleHeader& rhs)
654{
655 return !(lhs != rhs);
656}
657
658inline bool operator!=(const tSomeIpSessionHeader& lhs, const tSomeIpSessionHeader& rhs)
659{
660 return
661 lhs.nClientId != rhs.nClientId ||
662 lhs.nSessionId != rhs.nSessionId ||
663 lhs.nProtocolVersion != rhs.nProtocolVersion ||
664 lhs.nInterfaceVersion != rhs.nInterfaceVersion ||
665 lhs.eMessageType != rhs.eMessageType ||
666 lhs.eReturnCode != rhs.eReturnCode;
667}
668
669inline bool operator==(const tSomeIpSessionHeader& lhs, const tSomeIpSessionHeader& rhs)
670{
671 return !(lhs != rhs);
672}
673
674}
696using hood::operator!=;
698using hood::operator==;
699}
700}
701}
702}
Namespace for functionality provided by V3.1.0.
Definition raw_ethernet_types.h:45
tMessageType
Definition someip_types.h:53
tReturnCode
Definition someip_types.h:86
Namespace for functionality provided by V3.7.0.
Definition someip_coder_intf.h:45
Namespace for SOME/IP in ADTF-Devicetoolbox.
Definition raw_ethernet_types.h:40
hood::tCompuScale tCompuScale
Definition someip_types.h:688
hood::tSomeIpMessageHeader tSomeIpMessageHeader
Definition someip_types.h:678
brake::tReturnCode tReturnCode
Definition someip_types.h:158
hood::tSomeIpSessionHeader tSomeIpSessionHeader
Definition someip_types.h:686
hood::tSomeIpSerializationInfo tSomeIpSerializationInfo
Definition someip_types.h:682
bool operator!=(const tSomeIpSampleHeader &lhs, const tSomeIpSampleHeader &rhs)
Definition someip_types.h:639
bool operator==(const tSomeIpSampleHeader &lhs, const tSomeIpSampleHeader &rhs)
Definition someip_types.h:653
hood::tClusterInfo tClusterInfo
Definition someip_types.h:694
hood::tDataConstraint tDataConstraint
Definition someip_types.h:690
hood::tSomeIpSampleHeader tSomeIpSampleHeader
Definition someip_types.h:676
hood::tSomeIpTpHeader tSomeIpTpHeader
Definition someip_types.h:680
hood::tSomeIpMessageInfo tSomeIpMessageInfo
Definition someip_types.h:692
hood::tSomeIpTransformation tSomeIpTransformation
Definition someip_types.h:684
brake::tMessageType tMessageType
Definition someip_types.h:156
Namespace for SDK of ADTF-Devicetoolbox.
Definition bus_database_intf.h:42
Devicetoolbox - Namespace.
Definition bus_database_intf.h:36
ADTF - Namespace.
Definition bus_database_intf.h:30
Definition someip_types.h:562