1 // Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 #ifndef VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP
7 #define VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP
8 
9 #include <cstdint>
10 
11 #include <vsomeip/defines.hpp>
12 
13 #include "../../../buffer/buffer.hpp"
14 
15 namespace vsomeip_v3 {
16 namespace e2e {
17 namespace profile01 {
18 
19 struct profile_config;
20 
21 class profile_01 {
22   public:
23     static uint8_t compute_crc(const profile_config &_config, const e2e_buffer &_buffer);
24 
25     static bool is_buffer_length_valid(const profile_config &_config, const e2e_buffer &_buffer);
26 };
27 
28 // [SWS_E2E_00200]
29 enum class p01_data_id_mode : uint8_t {E2E_P01_DATAID_BOTH, E2E_P01_DATAID_ALT, E2E_P01_DATAID_LOW, E2E_P01_DATAID_NIBBLE};
30 
31 struct profile_config {
32     profile_config() = delete;
33 
profile_configvsomeip_v3::e2e::profile01::profile_config34     profile_config(uint16_t _crc_offset, uint16_t _data_id,
35                    p01_data_id_mode _data_id_mode, uint16_t _data_length,
36                    uint16_t _counter_offset, uint16_t _data_id_nibble_offset)
37 
38         : crc_offset_(_crc_offset), data_id_(_data_id),
39           data_id_mode_(_data_id_mode), data_length_(_data_length),
40           counter_offset_(_counter_offset),
41           data_id_nibble_offset_(_data_id_nibble_offset),
42           base_(VSOMEIP_FULL_HEADER_SIZE) {
43     }
44     profile_config(const profile_config &_config) = default;
45     profile_config &operator=(const profile_config &_config) = default;
46 
47     // [SWS_E2E_00018]
48     uint16_t crc_offset_;
49     uint16_t data_id_;
50     p01_data_id_mode data_id_mode_;
51     uint16_t data_length_;
52     uint16_t counter_offset_;
53     uint16_t data_id_nibble_offset_;
54 
55     // SOME/IP base
56     size_t base_;
57 };
58 
59 } // namespace profile01
60 } // namespace e2e
61 } // namespace vsomeip_v3
62 
63 #endif // VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP
64