| 43 | } |
| 44 | |
| 45 | void update_security_policy_command::deserialize(const std::vector<byte_t>& _buffer, error_e& _error) { |
| 46 | |
| 47 | if (COMMAND_HEADER_SIZE + sizeof(update_id_) > _buffer.size()) { |
| 48 | |
| 49 | _error = error_e::ERROR_NOT_ENOUGH_BYTES; |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | // deserialize header |
| 54 | command::deserialize(_buffer, _error); |
| 55 | if (_error != error_e::ERROR_OK) |
| 56 | return; |
| 57 | |
| 58 | // deserialize payload |
| 59 | std::memcpy(&update_id_, &_buffer[COMMAND_POSITION_PAYLOAD], sizeof(update_id_)); |
| 60 | policy_ = std::make_shared<policy>(); |
| 61 | const byte_t* its_policy_data = &_buffer[COMMAND_HEADER_SIZE + sizeof(update_id_)]; |
| 62 | uint32_t its_policy_size = uint32_t(_buffer.size() - COMMAND_HEADER_SIZE - sizeof(update_id_)); |
| 63 | |
| 64 | if (its_policy_size == 0 || !policy_->deserialize(its_policy_data, its_policy_size)) { |
| 65 | |
| 66 | _error = error_e::ERROR_UNKNOWN; |
| 67 | policy_.reset(); |
| 68 | return; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | uint32_t update_security_policy_command::get_update_id() const { |
| 73 |
nothing calls this directly
no test coverage detected