diff options
Diffstat (limited to 'implementation/e2e_protection/include')
14 files changed, 174 insertions, 68 deletions
diff --git a/implementation/e2e_protection/include/buffer/buffer.hpp b/implementation/e2e_protection/include/buffer/buffer.hpp index 5ddcf2e..8583ede 100644 --- a/implementation/e2e_protection/include/buffer/buffer.hpp +++ b/implementation/e2e_protection/include/buffer/buffer.hpp @@ -3,15 +3,15 @@ // 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/. -#ifndef VSOMEIP_E2E_BUFFER_HPP -#define VSOMEIP_E2E_BUFFER_HPP +#ifndef VSOMEIP_V3_E2E_BUFFER_HPP +#define VSOMEIP_V3_E2E_BUFFER_HPP #include <stdexcept> #include <cstdint> #include <ostream> #include <vector> -namespace vsomeip { +namespace vsomeip_v3 { using e2e_buffer = std::vector<uint8_t>; @@ -43,6 +43,6 @@ private: std::ostream &operator<<(std::ostream &_os, const e2e_buffer &_buffer); -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_BUFFER_HPP +#endif // VSOMEIP_V3_E2E_BUFFER_HPP diff --git a/implementation/e2e_protection/include/crc/crc.hpp b/implementation/e2e_protection/include/crc/crc.hpp index 1a54312..6120d86 100644 --- a/implementation/e2e_protection/include/crc/crc.hpp +++ b/implementation/e2e_protection/include/crc/crc.hpp @@ -3,13 +3,13 @@ // 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/. -#ifndef VSOMEIP_E2E_CRC_HPP -#define VSOMEIP_E2E_CRC_HPP +#ifndef VSOMEIP_V3_E2E_CRC_HPP +#define VSOMEIP_V3_E2E_CRC_HPP #include <cstdint> #include "../buffer/buffer.hpp" -namespace vsomeip { +namespace vsomeip_v3 { class e2e_crc { public: @@ -27,6 +27,6 @@ class e2e_crc { }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_CRC_HPP +#endif // VSOMEIP_V3_E2E_CRC_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp b/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp new file mode 100644 index 0000000..aa45829 --- /dev/null +++ b/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2014-2017 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/. + +#ifndef VSOMEIP_V3_E2E_PROVIDER_HPP +#define VSOMEIP_V3_E2E_PROVIDER_HPP + +#include <string> +#include <memory> + +#include "../../buffer/buffer.hpp" +#include "../../e2exf/config.hpp" +#include "../../../../configuration/include/e2e.hpp" +#include "profile_interface/profile_interface.hpp" + +namespace vsomeip_v3 { +namespace e2e { + +class e2e_provider { +public: + virtual bool add_configuration(std::shared_ptr<cfg::e2e> config) = 0; + + virtual bool is_protected(e2exf::data_identifier_t id) const = 0; + virtual bool is_checked(e2exf::data_identifier_t id) const = 0; + + virtual void protect(e2exf::data_identifier_t id, e2e_buffer &_buffer) = 0; + virtual void check(e2exf::data_identifier_t id, const e2e_buffer &_buffer, + e2e::profile_interface::check_status_t &_generic_check_status) = 0; +}; + +} // namespace e2e +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_E2E_PROVIDER_HPP + diff --git a/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp b/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp new file mode 100644 index 0000000..b7d41a6 --- /dev/null +++ b/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp @@ -0,0 +1,67 @@ +// Copyright (C) 2014-2017 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/. + +#ifndef VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP +#define VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP + +#include <map> +#include <memory> + +#include "e2e_provider.hpp" +#include "profile_interface/checker.hpp" +#include "profile_interface/protector.hpp" + +#include "../../../../../interface/vsomeip/export.hpp" +#include "../../../../../interface/vsomeip/plugin.hpp" + +namespace vsomeip_v3 { +namespace e2e { + +class e2e_provider_impl : + public e2e_provider, + public plugin_impl<e2e_provider_impl>, + public std::enable_shared_from_this<e2e_provider_impl> { +public: + VSOMEIP_EXPORT e2e_provider_impl(); + VSOMEIP_EXPORT ~e2e_provider_impl(); + + VSOMEIP_EXPORT bool add_configuration(std::shared_ptr<cfg::e2e> config) override; + + VSOMEIP_EXPORT bool is_protected(e2exf::data_identifier_t id) const override; + VSOMEIP_EXPORT bool is_checked(e2exf::data_identifier_t id) const override; + + VSOMEIP_EXPORT void protect(e2exf::data_identifier_t id, e2e_buffer &_buffer) override; + VSOMEIP_EXPORT void check(e2exf::data_identifier_t id, const e2e_buffer &_buffer, + profile_interface::check_status_t &_generic_check_status) 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; + + template<typename config_t> + config_t make_e2e_profile_config(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); + + std::shared_ptr<e2e::profile_interface::checker> checker; + if ((config->variant == "checker") || (config->variant == "both")) { + custom_checkers[data_identifier] = std::make_shared<checker_t>(profile_config); + } + + std::shared_ptr<e2e::profile_interface::protector> protector; + if ((config->variant == "protector") || (config->variant == "both")) { + custom_protectors[data_identifier] = std::make_shared<protector_t>(profile_config); + } + } +}; + +} // namespace e2e +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP + diff --git a/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp index 5fa243a..3010949 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp @@ -3,13 +3,13 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE01_CHECKER_HPP -#define VSOMEIP_E2E_PROFILE01_CHECKER_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE01_CHECKER_HPP +#define VSOMEIP_V3_E2E_PROFILE01_CHECKER_HPP #include "../profile01/profile_01.hpp" #include "../profile_interface/checker.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile01 { @@ -23,7 +23,7 @@ class profile_01_checker final : public e2e::profile_interface::checker { config_(_config) {} virtual void check(const e2e_buffer &_buffer, - e2e::profile_interface::generic_check_status &_generic_check_status) override final; + e2e::profile_interface::check_status_t &_generic_check_status) override final; private: profile_config config_; @@ -33,6 +33,6 @@ private: } // namespace profile01 } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE01_CHECKER_HPP +#endif // VSOMEIP_V3_E2E_PROFILE01_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp b/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp index 810ec56..c6cd5cf 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp @@ -3,13 +3,13 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE01_PROFILE01_HPP -#define VSOMEIP_E2E_PROFILE01_PROFILE01_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP +#define VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP #include <cstdint> #include "../../../buffer/buffer.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile01 { @@ -51,6 +51,6 @@ struct profile_config { } // namespace profile01 } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE01_PROFILE01_HPP +#endif // VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp index 204c7a1..fe8b603 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp @@ -3,14 +3,14 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE01_PROTECTOR_HPP -#define VSOMEIP_E2E_PROFILE01_PROTECTOR_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE01_PROTECTOR_HPP +#define VSOMEIP_V3_E2E_PROFILE01_PROTECTOR_HPP #include <mutex> #include "../profile01/profile_01.hpp" #include "../profile_interface/protector.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile01 { @@ -41,6 +41,6 @@ class protector final : public e2e::profile_interface::protector { } // namespace profile01 } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE01_PROTECTOR_HPP +#endif // VSOMEIP_V3_E2E_PROFILE01_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp index 7080329..73f1bbb 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp @@ -3,27 +3,28 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE_CUSTOM_CHECKER_HPP -#define VSOMEIP_E2E_PROFILE_CUSTOM_CHECKER_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE_CUSTOM_CHECKER_HPP +#define VSOMEIP_V3_E2E_PROFILE_CUSTOM_CHECKER_HPP #include "../profile_custom/profile_custom.hpp" #include "../profile_interface/checker.hpp" #include <mutex> -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile_custom { -class profile_custom_checker final : public vsomeip::e2e::profile_interface::checker { +class profile_custom_checker final + : public e2e::profile_interface::checker { - public: +public: profile_custom_checker(void) = delete; - explicit profile_custom_checker(const vsomeip::e2e::profile_custom::profile_config &_config) : + explicit profile_custom_checker(const e2e::profile_custom::profile_config &_config) : config_(_config) {} virtual void check(const e2e_buffer &_buffer, - vsomeip::e2e::profile_interface::generic_check_status &_generic_check_status); + e2e::profile_interface::check_status_t &_generic_check_status); private: uint32_t read_crc(const e2e_buffer &_buffer) const; @@ -36,6 +37,6 @@ private: } // namespace profile_custom } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE_CUSTOM_CHECKER_HPP +#endif // VSOMEIP_V3_E2E_PROFILE_CUSTOM_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp b/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp index f41942c..1cabefa 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp @@ -3,13 +3,13 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP -#define VSOMEIP_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP +#define VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP #include <cstdint> #include "../../../buffer/buffer.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile_custom { @@ -36,6 +36,6 @@ struct profile_config { } // namespace profile_custom } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP +#endif // VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp index 4b6c3b4..31b976b 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp @@ -3,18 +3,18 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE_CUSTOM_PROTECTOR_HPP -#define VSOMEIP_E2E_PROFILE_CUSTOM_PROTECTOR_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROTECTOR_HPP +#define VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROTECTOR_HPP #include <mutex> #include "../profile_custom/profile_custom.hpp" #include "../profile_interface/protector.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile_custom { -class protector final : public vsomeip::e2e::profile_interface::protector { +class protector final : public e2e::profile_interface::protector { public: protector(void) = delete; @@ -33,6 +33,6 @@ class protector final : public vsomeip::e2e::profile_interface::protector { } // namespace profile_custom } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE_CUSTOM_PROTECTOR_HPP +#endif // VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp index c66d1b0..f160ea1 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp @@ -3,25 +3,25 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE_INTERFACE_CHECKER_HPP -#define VSOMEIP_E2E_PROFILE_INTERFACE_CHECKER_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_CHECKER_HPP +#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_CHECKER_HPP #include "../profile_interface/profile_interface.hpp" #include "../../../buffer/buffer.hpp" #include <mutex> -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile_interface { class checker : public profile_interface { public: virtual void check(const e2e_buffer &_buffer, - vsomeip::e2e::profile_interface::generic_check_status &_generic_check_status) = 0; + check_status_t &_generic_check_status) = 0; }; } // namespace profile_interface } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE_INTERFACE_CHECKER_HPP +#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp b/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp index 377bbee..dc72aac 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp @@ -3,16 +3,18 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP -#define VSOMEIP_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP +#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP #include <cstdint> -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile_interface { -enum class generic_check_status : uint8_t { E2E_OK, E2E_WRONG_CRC, E2E_ERROR}; +typedef uint8_t check_status_t; +enum generic_check_status : check_status_t { E2E_OK, E2E_WRONG_CRC, E2E_ERROR}; + class profile_interface { public: @@ -22,6 +24,6 @@ public: } // namespace profile_interface } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP +#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp index a031a9e..5bae188 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp @@ -3,13 +3,13 @@ // 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/. -#ifndef VSOMEIP_E2E_PROFILE_INTERFACE_PROTECTOR_HPP -#define VSOMEIP_E2E_PROFILE_INTERFACE_PROTECTOR_HPP +#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROTECTOR_HPP +#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROTECTOR_HPP #include "../../../buffer/buffer.hpp" #include "../profile_interface/profile_interface.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace e2e { namespace profile_interface { @@ -20,6 +20,6 @@ class protector : public profile_interface { } // namespace profile_interface } // namespace e2e -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2E_PROFILE_INTERFACE_PROTECTOR_HPP +#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2exf/config.hpp b/implementation/e2e_protection/include/e2exf/config.hpp index bf1fb50..a022d8c 100644 --- a/implementation/e2e_protection/include/e2exf/config.hpp +++ b/implementation/e2e_protection/include/e2exf/config.hpp @@ -3,8 +3,8 @@ // 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/. -#ifndef VSOMEIP_E2EXF_CONFIG_HPP -#define VSOMEIP_E2EXF_CONFIG_HPP +#ifndef VSOMEIP_V3_E2EXF_CONFIG_HPP +#define VSOMEIP_V3_E2EXF_CONFIG_HPP #include <vsomeip/primitive_types.hpp> #include "../e2e/profile/profile_interface/checker.hpp" @@ -13,7 +13,7 @@ #include <memory> #include <map> -namespace vsomeip { +namespace vsomeip_v3 { namespace e2exf { using data_identifier_t = std::pair<service_t, event_t>; @@ -21,6 +21,6 @@ using data_identifier_t = std::pair<service_t, event_t>; std::ostream &operator<<(std::ostream &_os, const e2exf::data_identifier_t &_data_identifier); } // namespace e2exf -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_E2EXF_CONFIG_HPP +#endif // VSOMEIP_V3_E2EXF_CONFIG_HPP |