diff options
author | Diogo Pedrosa <48529452+DiogoPedrozza@users.noreply.github.com> | 2023-03-13 14:09:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-13 14:09:12 +0000 |
commit | 1b427801352b5dcfdc2277f6343166c01afe97d6 (patch) | |
tree | d4e984dd100f3257ce784c9e30aefb6e60a93ab5 /implementation/protocol/src/expire_command.cpp | |
parent | fc73f40fa1501dc53210c63cb7c0d7623d106370 (diff) | |
parent | 826ebb8d352245a36ecaec32b6af61e7abf4696e (diff) | |
download | vSomeIP-1b427801352b5dcfdc2277f6343166c01afe97d6.tar.gz |
Merge pull request #416 from COVESA/update_3.3.03.3.0
vsomeip 3.3.0
Diffstat (limited to 'implementation/protocol/src/expire_command.cpp')
-rw-r--r-- | implementation/protocol/src/expire_command.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/implementation/protocol/src/expire_command.cpp b/implementation/protocol/src/expire_command.cpp new file mode 100644 index 0000000..0611901 --- /dev/null +++ b/implementation/protocol/src/expire_command.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include <limits> + +#include <vsomeip/constants.hpp> + +#include "../include/expire_command.hpp" + +namespace vsomeip_v3 { +namespace protocol { + +expire_command::expire_command() + : subscribe_command_base(id_e::EXPIRE_ID) { +} + +void +expire_command::serialize(std::vector<byte_t> &_buffer, + error_e &_error) const { + + size_t its_size(COMMAND_HEADER_SIZE + + sizeof(service_) + sizeof(instance_) + + sizeof(eventgroup_) + sizeof(major_) + + sizeof(event_) + sizeof(pending_id_)); + + if (its_size > std::numeric_limits<command_size_t>::max()) { + + _error = error_e::ERROR_MAX_COMMAND_SIZE_EXCEEDED; + return; + } + + // resize buffer + _buffer.resize(its_size); + + // set size + size_ = static_cast<command_size_t>(its_size - COMMAND_HEADER_SIZE); + + // payload + subscribe_command_base::serialize(_buffer, _error); +} + +void +expire_command::deserialize(const std::vector<byte_t> &_buffer, + error_e &_error) { + + size_t its_size(COMMAND_HEADER_SIZE + + sizeof(service_) + sizeof(instance_) + + sizeof(eventgroup_) + sizeof(major_) + + sizeof(event_) + sizeof(pending_id_)); + + if (its_size > _buffer.size()) { + + _error = error_e::ERROR_NOT_ENOUGH_BYTES; + return; + } + + // deserialize header + subscribe_command_base::deserialize(_buffer, _error); +} + +} // namespace protocol +} // namespace vsomeip |