Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ libvsomeip_cfg_srcs = [
]

libvsomeip_e2e_srcs = [
"implementation/e2e_protection/src/*.cpp",
"implementation/e2e_protection/src/**/*.cpp",
]

libvsomeip_sd_srcs = [
Expand Down Expand Up @@ -83,6 +83,7 @@ cc_library_shared {
"-DVSOMEIP_COMPAT_VERSION=\"3.5.4\"",
"-DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\"",
"-DUSE_DLT",
"-DENABLE_E2E_FEATURE"
],

ldflags: [
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ if (ENABLE_SIGNAL_HANDLING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_SIGNAL_HANDLING")
endif ()

# Enable E2E feature
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_E2E_FEATURE")

# Event caching
if (ENABLE_DEFAULT_EVENT_CACHING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_DEFAULT_EVENT_CACHING")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class e2e_provider {
virtual void check(e2exf::data_identifier_t id,
const e2e_buffer &_buffer, instance_t _instance,
e2e::profile_interface::check_status_t &_generic_check_status) = 0;
virtual bool should_remove_e2e_header(e2exf::data_identifier_t id) = 0;
virtual bool get_header_offset_and_length(e2exf::data_identifier_t id,length_t& offset, length_t& length) = 0;
};

} // namespace e2e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "e2e_provider.hpp"
#include "profile_interface/checker.hpp"
#include "profile_interface/header_info.hpp"
#include "profile_interface/protector.hpp"

#include "../../../../../interface/vsomeip/export.hpp"
Expand Down Expand Up @@ -39,19 +40,22 @@ class e2e_provider_impl :
VSOMEIP_EXPORT void check(e2exf::data_identifier_t id,
const e2e_buffer &_buffer, instance_t _instance,
profile_interface::check_status_t &_generic_check_status) override;
VSOMEIP_EXPORT bool should_remove_e2e_header(e2exf::data_identifier_t id) override;
VSOMEIP_EXPORT bool get_header_offset_and_length(e2exf::data_identifier_t id,length_t& offset, length_t& length) override;

private:
std::map<e2exf::data_identifier_t, std::shared_ptr<profile_interface::protector>> custom_protectors_;
std::map<e2exf::data_identifier_t, std::shared_ptr<profile_interface::checker>> custom_checkers_;
std::map<e2exf::data_identifier_t, std::shared_ptr<profile_interface::profile_header_info>> header_infos_;
std::map<e2exf::data_identifier_t, std::size_t> custom_bases_;

template<typename config_t>
config_t make_e2e_profile_config(const std::shared_ptr<cfg::e2e>& config);
config_t make_e2e_profile_config(const e2exf::data_identifier_t data_identifier, const std::shared_ptr<cfg::e2e>& config);

template<typename config_t, typename checker_t, typename protector_t>
void process_e2e_profile(std::shared_ptr<cfg::e2e> config) {
const e2exf::data_identifier_t data_identifier = {config->service_id, config->event_id};
config_t profile_config = make_e2e_profile_config<config_t>(config);
config_t profile_config = make_e2e_profile_config<config_t>(data_identifier,config);

std::shared_ptr<e2e::profile_interface::checker> checker;
if ((config->variant == "checker") || (config->variant == "both")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (C) 2025-2026 Valeo
// 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/.

/*
** file header_info.hpp
** brief Implementation of header info interface to save header info for profile 04
*/

#ifndef VSOMEIP_V3_E2E_PROFILE04_HEADER_INFO_HPP
#define VSOMEIP_V3_E2E_PROFILE04_HEADER_INFO_HPP

#include <map>

#include "../profile04/profile_04.hpp"
#include "../profile_interface/header_info.hpp"

namespace vsomeip_v3 {
namespace e2e {
namespace profile04 {

class profile_04_header_info final : public e2e::profile_interface::profile_header_info {

public:
profile_04_header_info(void) = delete;

explicit profile_04_header_info(length_t _offet_);
length_t get_e2e_header_offset() override;
length_t get_e2e_header_length() override;
bool should_remove_header() override;

private:
length_t header_len_;
length_t crc_offset_;
};

} // namespace profile_04
} // namespace e2e
} // namespace vsomeip_v3

#endif // VSOMEIP_V3_E2E_PROFILE04_HEADER_INFO_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct profile_config {
max_delta_counter_(_max_delta_counter),
base_(VSOMEIP_SOMEIP_HEADER_SIZE) {
}

profile_config(const profile_config &_config) = default;
profile_config &operator=(const profile_config &_config) = default;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2025-2026 Valeo
// 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/.

/*
** file header_info.hpp
** brief Interface to retrive header info
*/

#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_HEADER_INFO_HPP
#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_HEADER_INFO_HPP

#include <cstdint>
#include <vsomeip/primitive_types.hpp>

namespace vsomeip_v3 {
namespace e2e {
namespace profile_interface {


class profile_header_info {
public:
virtual ~profile_header_info() {}
virtual length_t get_e2e_header_offset() = 0;
virtual length_t get_e2e_header_length() = 0;
virtual bool should_remove_header() = 0;
};

} // namespace profile_interface
} // namespace e2e
} // namespace vsomeip_v3

#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_HEADER_INFO_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <iomanip>
#include <memory>
#include <sstream>

#include <vsomeip/internal/logger.hpp>
Expand All @@ -17,6 +18,7 @@
#include "../../../../e2e_protection/include/e2e/profile/profile04/checker.hpp"
#include "../../../../e2e_protection/include/e2e/profile/profile04/profile_04.hpp"
#include "../../../../e2e_protection/include/e2e/profile/profile04/protector.hpp"
#include "../../../../e2e_protection/include/e2e/profile/profile04/header_info.hpp"

#include "../../../../e2e_protection/include/e2e/profile/profile05/checker.hpp"
#include "../../../../e2e_protection/include/e2e/profile/profile05/profile_05.hpp"
Expand Down Expand Up @@ -141,9 +143,30 @@ void e2e_provider_impl::check(e2exf::data_identifier_t id,
}
}

bool e2e_provider_impl::should_remove_e2e_header(e2exf::data_identifier_t id)
{
auto header_info = header_infos_.find(id);
if (header_info != header_infos_.end())
{
return header_info->second->should_remove_header();
}
return false;
}

bool e2e_provider_impl::get_header_offset_and_length(e2exf::data_identifier_t id,length_t& offset, length_t& length)
{
auto header_info = header_infos_.find(id);
if(header_info != header_infos_.end()) {
length= header_info->second->get_e2e_header_length();
offset= header_info->second->get_e2e_header_offset();
return true;
}
return false;
}

template<>
vsomeip_v3::e2e::profile01::profile_config
e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_config) {
e2e_provider_impl::make_e2e_profile_config(const e2exf::data_identifier_t, const std::shared_ptr<cfg::e2e> &_config) {
uint16_t data_id = read_value_from_config<uint16_t>(_config, "data_id");
uint16_t crc_offset = read_value_from_config<uint16_t>(_config, "crc_offset");
uint16_t data_length = read_value_from_config<uint16_t>(_config, "data_length");
Expand All @@ -164,7 +187,7 @@ e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_con

template<>
vsomeip_v3::e2e::profile04::profile_config
e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_config) {
e2e_provider_impl::make_e2e_profile_config(const e2exf::data_identifier_t data_identifier, const std::shared_ptr<cfg::e2e> &_config) {

uint32_t data_id = read_value_from_config<uint32_t>(_config, "data_id");

Expand All @@ -183,13 +206,16 @@ e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_con
uint16_t max_delta_counter = read_value_from_config<uint16_t>(_config,
"max_delta_counter", uint16_t(0xffff));

return e2e::profile04::profile_config(data_id, offset,
e2e::profile04::profile_config profile04_config = e2e::profile04::profile_config(data_id, offset,
min_data_length, max_data_length, max_delta_counter);
header_infos_[data_identifier] = std::make_shared<profile04::profile_04_header_info>(static_cast<length_t>(offset));

return profile04_config;
}

template<>
vsomeip_v3::e2e::profile05::profile_config
e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_config) {
e2e_provider_impl::make_e2e_profile_config(const e2exf::data_identifier_t, const std::shared_ptr<cfg::e2e> &_config) {

uint32_t data_id = read_value_from_config<uint32_t>(_config, "data_id");
uint16_t data_length = read_value_from_config<uint16_t>(_config, "data_length");
Expand All @@ -209,14 +235,14 @@ e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_con

template<>
e2e::profile_custom::profile_config
e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e>& config) {
e2e_provider_impl::make_e2e_profile_config(const e2exf::data_identifier_t, const std::shared_ptr<cfg::e2e>& config) {
uint16_t crc_offset = read_value_from_config<uint16_t>(config, "crc_offset");
return e2e::profile_custom::profile_config(crc_offset);
}

template<>
vsomeip_v3::e2e::profile07::profile_config
e2e_provider_impl::make_e2e_profile_config(const std::shared_ptr<cfg::e2e> &_config) {
e2e_provider_impl::make_e2e_profile_config(const e2exf::data_identifier_t, const std::shared_ptr<cfg::e2e> &_config) {

uint32_t data_id = read_value_from_config<uint32_t>(_config, "data_id");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void profile_04_checker::check(const e2e_buffer &_buffer, instance_t _instance,
VSOMEIP_ERROR << std::hex << "E2E P04 protection: CRC32 does not match: calculated CRC: "
<< its_crc << " received CRC: " << its_received_crc;
} else {
uint32_t its_data_id(uint32_t(_instance) << 24 | config_.data_id_);
uint32_t its_data_id(config_.data_id_);
if (its_received_data_id == its_data_id
&& static_cast<size_t>(its_received_length) == _buffer.size()
&& verify_counter(_instance, its_received_counter)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2025-2026 Valeo
// 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/.

/*
** file header_info.cpp
** brief Implementation of header info interface to save header info for profile 04
*/

#include <vsomeip/internal/logger.hpp>

#include "../../../../include/e2e/profile/profile04/header_info.hpp"

namespace vsomeip_v3 {
namespace e2e {
namespace profile04 {

constexpr int HEADER_LENGTH=12;

profile_04_header_info::profile_04_header_info(length_t _offet)
: header_len_(HEADER_LENGTH), crc_offset_(_offet) {}

length_t profile_04_header_info::get_e2e_header_offset() { return crc_offset_; }

length_t profile_04_header_info::get_e2e_header_length() { return header_len_; }

bool profile_04_header_info::should_remove_header() {
return true;
}

} // namespace profile04
} // namespace e2e
} // namespace vsomeip_v3
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protector::protect(e2e_buffer &_buffer, instance_t _instance) {
bithelper::write_uint16_be(get_counter(_instance), &_buffer[config_.offset_ + 2]);

/** @req [SWS_E2E_00366] */
uint32_t its_data_id(uint32_t(_instance) << 24 | config_.data_id_);
uint32_t its_data_id(config_.data_id_);
bithelper::write_uint32_be(its_data_id, &_buffer[config_.offset_ + 4]);

/** @req [SWS_E2E_00367] */
Expand Down
17 changes: 17 additions & 0 deletions implementation/routing/include/routing_manager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,23 @@ class routing_manager_impl: public routing_manager_base,
service_t _service, instance_t _instance,
const boost::asio::ip::address &_remote_address) const;

bool apply_e2e_protection(const byte_t **_data, length_t &_size,
service_t _service, method_t _method,
instance_t _instance, e2e_buffer& its_buffer);

/**
* remove bytes from a buffer starting at a specified index.
*
* @param buffer Pointer to the byte buffer.
* @param bufferSize Size of the byte buffer.
* @param startIndex Starting index from where bytes should be erased.
* @param length Number of bytes to erase from the buffer.
* @return true if the operation succeeds, false otherwise.
*/
bool erase_bytes(byte_t *buffer, size_t bufferSize, size_t startIndex, size_t length);

void reduce_msg_length(byte_t *buffer, length_t& bufferSize,length_t reduceBy);

#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING
bool has_subscribed_eventgroup(
service_t _service, instance_t _instance) const;
Expand Down
Loading