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_PROVIDER_IMPL_HPP 7 #define VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP 8 9 #include <map> 10 #include <memory> 11 12 #include "e2e_provider.hpp" 13 #include "profile_interface/checker.hpp" 14 #include "profile_interface/protector.hpp" 15 16 #include "../../../../../interface/vsomeip/export.hpp" 17 #include "../../../../../interface/vsomeip/plugin.hpp" 18 19 namespace vsomeip_v3 { 20 namespace e2e { 21 22 class e2e_provider_impl : 23 public e2e_provider, 24 public plugin_impl<e2e_provider_impl>, 25 public std::enable_shared_from_this<e2e_provider_impl> { 26 public: 27 VSOMEIP_EXPORT e2e_provider_impl(); 28 VSOMEIP_EXPORT ~e2e_provider_impl(); 29 30 VSOMEIP_EXPORT bool add_configuration(std::shared_ptr<cfg::e2e> config) override; 31 32 VSOMEIP_EXPORT bool is_protected(e2exf::data_identifier_t id) const override; 33 VSOMEIP_EXPORT bool is_checked(e2exf::data_identifier_t id) const override; 34 35 VSOMEIP_EXPORT std::size_t get_protection_base(e2exf::data_identifier_t _id) const override; 36 37 VSOMEIP_EXPORT void protect(e2exf::data_identifier_t id, 38 e2e_buffer &_buffer, instance_t _instance) override; 39 VSOMEIP_EXPORT void check(e2exf::data_identifier_t id, 40 const e2e_buffer &_buffer, instance_t _instance, 41 profile_interface::check_status_t &_generic_check_status) override; 42 43 private: 44 std::map<e2exf::data_identifier_t, std::shared_ptr<profile_interface::protector>> custom_protectors_; 45 std::map<e2exf::data_identifier_t, std::shared_ptr<profile_interface::checker>> custom_checkers_; 46 std::map<e2exf::data_identifier_t, std::size_t> custom_bases_; 47 48 template<typename config_t> 49 config_t make_e2e_profile_config(const std::shared_ptr<cfg::e2e>& config); 50 51 template<typename config_t, typename checker_t, typename protector_t> process_e2e_profile(std::shared_ptr<cfg::e2e> config)52 void process_e2e_profile(std::shared_ptr<cfg::e2e> config) { 53 const e2exf::data_identifier_t data_identifier = {config->service_id, config->event_id}; 54 config_t profile_config = make_e2e_profile_config<config_t>(config); 55 56 std::shared_ptr<e2e::profile_interface::checker> checker; 57 if ((config->variant == "checker") || (config->variant == "both")) { 58 custom_checkers_[data_identifier] = std::make_shared<checker_t>(profile_config); 59 } 60 61 std::shared_ptr<e2e::profile_interface::protector> protector; 62 if ((config->variant == "protector") || (config->variant == "both")) { 63 custom_protectors_[data_identifier] = std::make_shared<protector_t>(profile_config); 64 } 65 66 custom_bases_[data_identifier] = profile_config.base_; 67 } 68 }; 69 70 } // namespace e2e 71 } // namespace vsomeip_v3 72 73 #endif // VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP 74 75