diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2019-07-22 14:05:36 +0200 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2019-07-22 14:05:36 +0200 |
commit | ee44d19e0a3773adcda3bace073c66e334a3e6a7 (patch) | |
tree | 8e7c2aae6afeaa7b3dc4af29d960012a625226ce /interface | |
parent | 9fb9beecadf52083599302fa8ddee7efbec64a39 (diff) | |
download | vSomeIP-ee44d19e0a3773adcda3bace073c66e334a3e6a7.tar.gz |
vsomeip 2.14.162.14.16
Diffstat (limited to 'interface')
-rw-r--r-- | interface/vsomeip/application.hpp | 141 | ||||
-rw-r--r-- | interface/vsomeip/constants.hpp | 2 | ||||
-rw-r--r-- | interface/vsomeip/defines.hpp | 1 | ||||
-rw-r--r-- | interface/vsomeip/enumeration_types.hpp | 7 | ||||
-rw-r--r-- | interface/vsomeip/handler.hpp | 39 | ||||
-rw-r--r-- | interface/vsomeip/primitive_types.hpp | 5 | ||||
-rw-r--r-- | interface/vsomeip/trace.hpp | 218 | ||||
-rw-r--r-- | interface/vsomeip/vsomeip.hpp | 1 |
8 files changed, 413 insertions, 1 deletions
diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp index 42bd534..a1296e8 100644 --- a/interface/vsomeip/application.hpp +++ b/interface/vsomeip/application.hpp @@ -23,6 +23,7 @@ namespace vsomeip { class configuration; class event; class payload; +struct policy; /** * \defgroup vsomeip @@ -944,7 +945,145 @@ public: * \param _handler Callback that shall be called. * */ - virtual void register_async_subscription_handler(service_t _service, instance_t _instance, eventgroup_t _eventgroup, async_subscription_handler_t _handler) = 0; + virtual void register_async_subscription_handler( + service_t _service, instance_t _instance, eventgroup_t _eventgroup, + async_subscription_handler_t _handler) = 0; + + /** + * \brief Enables or disables calling of registered offer acceptance + * handler for given IP address + * + * This method has only an effect when called on the application acting as + * routing manager + * + * \param _address IP address for which offer acceptance handler should be + * called + * \param _path Path which indicates need for offer acceptance + * \param _enable enable or disable calling of offer acceptance handler + */ + virtual void set_offer_acceptance_required(ip_address_t _address, + const std::string _path, + bool _enable) = 0; + + /** + * \brief Returns all configured IP addresses which require calling of + * registered offer acceptance handler + * + * This method has only an effect when called on the application acting as + * routing manager + * + * \return map with known IP addresses requiring offer acceptance handling + */ + typedef std::map<ip_address_t, std::string> offer_acceptance_map_type_t; + virtual offer_acceptance_map_type_t get_offer_acceptance_required() = 0; + + /** + * \brief Registers a handler which will be called upon reception of + * a remote offer with the offering ECU's IP address as parameter + * + * This method has only an effect when called on the application acting as + * routing manager + * + * \param _handler The handler to be called + */ + virtual void register_offer_acceptance_handler( + offer_acceptance_handler_t _handler) = 0; + + /** + * \brief Registers a handler which will be called upon detection of a + * reboot of a remote ECU with the remote ECU's IP address as a parameter + * + * This method has only an effect when called on the application acting as + * routing manager + * + * \param _handler The handler to be called + */ + virtual void register_reboot_notification_handler( + reboot_notification_handler_t _handler) = 0; + + /** + * \brief Registers a handler which will be called when the routing reached + * READY state. + * + * This method has only an effect when called on the application acting as + * routing manager + * + * \param _handler The handler to be called + */ + virtual void register_routing_ready_handler( + routing_ready_handler_t _handler) = 0; + + /** + * \brief Registers a handler which will be called when the routing state + * changes. + * + * This method has only an effect when called on the application acting as + * routing manager + * + * \param _handler The handler to be called + */ + virtual void register_routing_state_handler( + routing_state_handler_t _handler) = 0; + + /** + * \brief Update service configuration to offer a local service on the + * network as well + * + * This function is intended to take the necessary information to offer a + * service remotely if it was offered only locally beforehand. + * Precondition: The service must already be offered locally before + * calling this method. + * This function only has an effect if called on an application acting as + * routing manager. + * + * \param _service Service identifier + * \param _instance Instance identifier + * \param _port The port number on which the service should be offered + * \param _reliable Offer via TCP or UDP + * \param _magic_cookies_enabled Flag to enable magic cookies + * \param _offer Offer the service or stop offering it remotely + */ + virtual bool update_service_configuration(service_t _service, + instance_t _instance, + std::uint16_t _port, + bool _reliable, + bool _magic_cookies_enabled, + bool _offer) = 0; + + /** + * \brief Update security configuration of routing manager and all local clients + * The given handler gets called with "SU_SUCCESS" if the policy for UID + * and GID was updated or added successfully. If not all clients did confirm + * the update, SU_TIMEOUT is set. + * + * \param _uid UID of the policy + * \param _gid GID of the policy + * \param _policy The security policy to apply + * \param _payload serialized security policy object + * \param _handler handler which gets called after all clients have + * confirmed the policy update + */ + virtual void update_security_policy_configuration(uint32_t _uid, + uint32_t _gid, + std::shared_ptr<policy> _policy, + std::shared_ptr<payload> _payload, + security_update_handler_t _handler) = 0; + + /** + * \brief Remove a security configuration for routing manager and all local clients + * The given handler gets called with "SU_SUCCESS" if the policy for UID + * and GID was removed successfully. SU_UNKNOWN_USER_ID is set if the + * UID and GID was not found. If not all clients did confirm the removal, + * SU_TIMEOUT is set. + * + * \param _uid UID of the policy to remove + * \param _gid GID of the policy to remove + * \param _handler handler which gets called after all clients have + * confirmed the policy removal + */ + virtual void remove_security_policy_configuration(uint32_t _uid, + uint32_t _gid, + security_update_handler_t _handler) = 0; }; /** @} */ diff --git a/interface/vsomeip/constants.hpp b/interface/vsomeip/constants.hpp index d45f2c1..9dc33f0 100644 --- a/interface/vsomeip/constants.hpp +++ b/interface/vsomeip/constants.hpp @@ -37,6 +37,7 @@ const byte_t MAGIC_COOKIE_CLIENT_MESSAGE = 0x00; const byte_t MAGIC_COOKIE_SERVICE_MESSAGE = 0x80; const length_t MAGIC_COOKIE_SIZE = 0x00000008; const request_t MAGIC_COOKIE_REQUEST = 0xDEADBEEF; +const client_t MAGIC_COOKIE_NETWORK_BYTE_ORDER = 0xADDE; const protocol_version_t MAGIC_COOKIE_PROTOCOL_VERSION = 0x01; const interface_version_t MAGIC_COOKIE_INTERFACE_VERSION = 0x01; const message_type_e MAGIC_COOKIE_CLIENT_MESSAGE_TYPE = @@ -55,6 +56,7 @@ const event_t ANY_EVENT = 0xFFFF; const client_t ANY_CLIENT = 0xFFFF; const pending_subscription_id_t DEFAULT_SUBSCRIPTION = 0x0; +const pending_security_update_id_t DEFAULT_SECURITY_UPDATE_ID = 0x0; } // namespace vsomeip diff --git a/interface/vsomeip/defines.hpp b/interface/vsomeip/defines.hpp index 2a6af8b..0442fae 100644 --- a/interface/vsomeip/defines.hpp +++ b/interface/vsomeip/defines.hpp @@ -18,6 +18,7 @@ #define VSOMEIP_SOMEIP_HEADER_SIZE 8 #define VSOMEIP_SOMEIP_MAGIC_COOKIE_SIZE 8 +#define VSOMEIP_FULL_HEADER_SIZE 16 #define VSOMEIP_SERVICE_POS_MIN 0 #define VSOMEIP_SERVICE_POS_MAX 1 diff --git a/interface/vsomeip/enumeration_types.hpp b/interface/vsomeip/enumeration_types.hpp index 1f83b81..71ff38a 100644 --- a/interface/vsomeip/enumeration_types.hpp +++ b/interface/vsomeip/enumeration_types.hpp @@ -69,6 +69,13 @@ enum class offer_type_e : uint8_t { OT_ALL = 0x02, }; +enum class security_update_state_e : uint8_t { + SU_SUCCESS = 0x00, + SU_NOT_ALLOWED = 0x01, + SU_UNKNOWN_USER_ID = 0x02, + SU_INVALID_FORMAT = 0x03 +}; + } // namespace vsomeip #endif // VSOMEIP_ENUMERATION_TYPES_HPP diff --git a/interface/vsomeip/handler.hpp b/interface/vsomeip/handler.hpp index bcb2aa8..2fa57a8 100644 --- a/interface/vsomeip/handler.hpp +++ b/interface/vsomeip/handler.hpp @@ -27,6 +27,45 @@ typedef std::function< void (client_t, bool, std::function< void (const bool) > typedef std::function< void (const std::vector<std::pair<service_t, instance_t>> &_services) > offered_services_handler_t; typedef std::function< void () > watchdog_handler_t; +struct ip_address_t { + union { + ipv4_address_t v4_; + ipv6_address_t v6_; + } address_; + bool is_v4_; + + bool operator<(const ip_address_t& _other) const { + if (is_v4_ && _other.is_v4_) { + return address_.v4_ < _other.address_.v4_; + } else if (!is_v4_ && !_other.is_v4_) { + return address_.v6_ < _other.address_.v6_; + } else if (is_v4_ && !_other.is_v4_) { + return true; + } else { + return false; + } + } + + bool operator==(const ip_address_t& _other) const { + if (is_v4_ && _other.is_v4_) { + return address_.v4_ == _other.address_.v4_; + } else if (!is_v4_ && !_other.is_v4_) { + return address_.v6_ == _other.address_.v6_; + } else { + return false; + } + } + + bool operator!=(const ip_address_t& _other) const { + return !(*this == _other); + } + +}; +typedef std::function<bool(const ip_address_t&)> offer_acceptance_handler_t; +typedef std::function<void(const ip_address_t&)> reboot_notification_handler_t; +typedef std::function<void()> routing_ready_handler_t; +typedef std::function<void(routing_state_e)> routing_state_handler_t; +typedef std::function<void(security_update_state_e)> security_update_handler_t; } // namespace vsomeip diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index 9f6c84a..95192eb 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -44,6 +44,11 @@ typedef std::string trace_channel_t; typedef std::string trace_filter_type_t; typedef std::uint16_t pending_subscription_id_t; + +typedef std::uint32_t pending_remote_offer_id_t; + +typedef std::uint32_t pending_security_update_id_t; + } // namespace vsomeip #endif // VSOMEIP_PRIMITIVE_TYPES_HPP diff --git a/interface/vsomeip/trace.hpp b/interface/vsomeip/trace.hpp new file mode 100644 index 0000000..85cfd30 --- /dev/null +++ b/interface/vsomeip/trace.hpp @@ -0,0 +1,218 @@ +// Copyright (C) 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_TRACE_HPP_ +#define VSOMEIP_TRACE_HPP_ + +#include <memory> +#include <vector> + +#include <vsomeip/constants.hpp> +#include <vsomeip/primitive_types.hpp> + +namespace vsomeip { +/** + * \defgroup vsomeip + * + * @{ + */ +namespace trace { + +/** + * \brief Unique identifier for trace filters. + */ +typedef uint32_t filter_id_t; + +/** + * \brief Error value. + */ +extern const filter_id_t FILTER_ID_ERROR; + +/** + * \brief The default channel id "TC". + */ +extern const char *VSOMEIP_TC_DEFAULT_CHANNEL_ID; + +/** + * \brief Filters contain at least one match that specified + * which messages are filtered. + */ +typedef std::tuple<service_t, instance_t, method_t> match_t; + +/** + * \brief Representation of a DLT trace channel. + * + * A trace channel contains one or more filters that specify the + * messages that are forwarded to the trace. + */ +class channel { +public: + virtual ~channel() {}; + + /** + * \brief Get the identifier of the channel. + * + * \return Channel identifier. + */ + virtual std::string get_id() const = 0; + + /** + * \brief Get the name of the channel. + * + * \return Channel name. + */ + virtual std::string get_name() const = 0; + + /** + * \brief Add a filter to the channel. + * + * Add a simple filter containing a single match. + * + * Note: The match is allowed to contain wildcards + * (ANY_INSTANCE, ANY_SERVICE, ANY_METHOD). + * + * \param _match The tuple specifying the matching messages. + * \param _is_positive True for positive filters, + * false for negative filters. Default value is true. + * + * \return Filter identifier of the added filter or + * FILTER_ID_ERROR if adding failed. + */ + virtual filter_id_t add_filter( + const match_t &_match, + bool _is_positive = true) = 0; + + /** + * \brief Add a filter to the channel. + * + * Add a filter containing a list of matches to the + * channel. The filter matches if at least on of the + * matches corresponds to a message. + * + * Note: The matches are allowed to contain wildcards + * (ANY_INSTANCE, ANY_SERVICE, ANY_METHOD). + * + * \param _matches List of tuples specifying the matching messages. + * \param _is_positive True for positive filters, + * false for negative filters. Default value is true. + * + * \return Filter identifier of the added filter or + * FILTER_ID_ERROR if adding failed. + */ + virtual filter_id_t add_filter( + const std::vector<match_t> &_matches, + bool _is_positive = true) = 0; + + /** + * \brief Add a filter to the channel. + * + * Add a filter containing a matches range to the + * channel. The filter matches if the message identifiers + * lie within the range specified by from and to. Thus, + * the messages service identifier is greater equal than + * the service identifier specified in from and less equal + * than the service identifier specified in to. + * + * Note: from and to must not contain wildcards + * (ANY_INSTANCE, ANY_SERVICE, ANY_METHOD). + * + * \param _from Tuples specifying the matching message with + * the smallest identifiers. + * \param _from Tuples specifying the matching message with + * the greatest identifiers. + * \param _is_positive True for positive filters, + * false for negative filters. Default value is true. + * + * \return Filter identifier of the added filter or + * FILTER_ID_ERROR if adding failed. + */ + virtual filter_id_t add_filter( + const match_t &_from, const match_t &_to, + bool _is_positive = true) = 0; + + /** + * \brief Remove a filter from the channel. + * + * Remove the filter with the given filter identifier + * from the channel. + * + * \param _id Filter identifier of the filter that shall + * be removed. + */ + virtual void remove_filter( + filter_id_t _id) = 0; +}; + +/** + * \brief Singleton class to connect to the DLT tracing. + * + * The main configuration class of the DLT tracing. It holds + * the trace channels which determine the messages that are + * forwarded to the trace. + */ +class connector { +public: + /** + * \brief Get access to the connector. + * + * \return Shared pointer to the singleton object. + */ + static std::shared_ptr<connector> get(); + + virtual ~connector() {}; + + /** + * \brief Add a trace channel to the connector. + * + * Creates a trace channel with the given identifier and name + * and adds it to the connector. + * + * \param _id Id of the trace channel. + * \param _name Name of the trace channel + * + * \return Shared pointer to the created trace channel or + * nullptr if the trace channel could not be created because + * another trace channel with the given identifier does + * already exist. + */ + virtual std::shared_ptr<channel> add_channel( + const std::string &_id, + const std::string &_name) = 0; + + /** + * \brief Remove a trace channel from the connector. + * + * Removes the trace channel with the given identifier from + * the connector. + * + * \param _id Identifier of a trace channel. + * + * \return True of the trace channel was removed, False if + * it could not be removed, because it is the default trace + * channel. + */ + virtual bool remove_channel( + const std::string &_id) = 0; + + /** + * \brief Get a trace channel from the connector. + * + * \param _id Identifier of the trace channel to be returned. + * Optional argument that is predefined with the identifier + * of the default trace channel. + * + * \return Shared pointer to the created trace channel or + * nullptr if the trace channel does not exist. + */ + virtual std::shared_ptr<channel> get_channel( + const std::string &_id = VSOMEIP_TC_DEFAULT_CHANNEL_ID) const = 0; +}; + +} // namespace trace + +/** @} */ + +} // namespace vsomeip + +#endif // VSOMEIP_CONSTANTS_HPP diff --git a/interface/vsomeip/vsomeip.hpp b/interface/vsomeip/vsomeip.hpp index 90940b2..1068b0b 100644 --- a/interface/vsomeip/vsomeip.hpp +++ b/interface/vsomeip/vsomeip.hpp @@ -16,5 +16,6 @@ #include <vsomeip/message.hpp> #include <vsomeip/payload.hpp> #include <vsomeip/runtime.hpp> +#include <vsomeip/trace.hpp> #endif // VSOMEIP_VSOMEIP_HPP |