diff options
Diffstat (limited to 'interface')
42 files changed, 3312 insertions, 796 deletions
diff --git a/interface/compat/vsomeip/application.hpp b/interface/compat/vsomeip/application.hpp new file mode 100644 index 0000000..0d4b671 --- /dev/null +++ b/interface/compat/vsomeip/application.hpp @@ -0,0 +1,1093 @@ +// 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_APPLICATION_HPP +#define VSOMEIP_APPLICATION_HPP + +#include <chrono> +#include <memory> +#include <set> +#include <map> +#include <vector> + +#include "../../compat/vsomeip/constants.hpp" +#include "../../compat/vsomeip/enumeration_types.hpp" +#include "../../compat/vsomeip/function_types.hpp" +#include "../../compat/vsomeip/handler.hpp" +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +class configuration; +class event; +class payload; +struct policy; + +/** + * \defgroup vsomeip + * + * @{ + */ + +/** + * + * \brief This class contains the public API of the vsomeip implementation. + * + * Due to its heavy resource footprint, it should exist once per client and can + * be instantiated using the API of @ref runtime. It manages the lifecycle of + * the vsomeip client and allocates all resources needed to communicate. + * + */ +class application { +public: + virtual ~application() {} + + /** + * + * \brief Returns the name of the application as given during creation + * + * The application name is used to identify the application. It is either + * set explicitely when the application object is created or configured by + * the environment variable VSOMEIP_APPLICATION_NAME. + * + * Note: A user application can use several vsomeip application objects in + * parallel. The application names must be set explicitly in this case + * because VSOMEIP_APPLICATION_NAME only allows to specify a single name. + * + * + * \return Application name + * + */ + virtual const std::string & get_name() const = 0; + + /** + * + * \brief Returns the client identifier that was assigned to the + * application object. + * + * Each request sent by and each response sent to the application contain + * the client identifier as part of the request identifier within the + * SOME/IP message header. The client identifier can either be configured + * by the configured as part of the application node within a vsomeip + * configuration file or is automatically set to an unused client + * identifier by vsomeip. If the client identifier is automatically set, + * its high byte will always match the diagnosis address of the device. + * + * \return Client ID of application + * + */ + virtual client_t get_client() const = 0; + + /** + * + * \brief Does nothing. + * + * This method exists for compatibility reasons only. It is a null + * operation and will be removed with the next major vsomeip version. + * + */ + virtual void set_configuration(const std::shared_ptr<configuration> _configuration) = 0; + + /** + * + * \brief Initializes the application. + * + * The init method must be called first after creating a vsomeip + * application and executes the following steps to initialize it: + * - Loading the configuration from a dynamic module + * - Loading the configuration from a .json file or + * - Loading the configuration from compiled data (not yet available) + * - Determining routing configuration and initialization of the routing + * itself + * - Installing signal handlers + * + */ + virtual bool init() = 0; + + /** + * + * \brief Starts message processing. + * + * This method must be called after init to start message processing. It + * will block until the message processing is terminated using the @ref + * stop method or by receiving signals. It processes messages received + * via the sockets and uses registered callbacks to pass them to the user + * application. + * + */ + virtual void start() = 0; + + /** + * + * \brief Stops message processing. + * + * This method stops message processing. Thus, @ref start will return + * after a call to stop. + * + */ + virtual void stop() = 0; + + /** + * + * \brief Offers a SOME/IP service instance. + * + * The user application must call this method for each service it offers + * to register it at the vsomeip routing component, which makes the + * service visible to interested clients. Dependent on the configuration + * the service is available internally only or internally and externally. + * To offer a service to the external network, the configuration must + * contain a port for the offered service instance. If no such port + * configuration is provided, the service is not visible outside the + * device. + * + * \param _service Service identifier of the offered service interface. + * \param _instance Instance identifier of the offered service instance. + * \param _major Major service version (Default: 0). + * \param _minor Minor service version (Default: 0). + * + */ + virtual void offer_service(service_t _service, instance_t _instance, + major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = + DEFAULT_MINOR) = 0; + + /** + * + * \brief Stops offering a SOME/IP service instance. + * + * The user application must call this method to withdraw a service offer. + * + * \param _service Service identifier of the offered service interface. + * \param _instance Instance identifer of the offered service instance. + * \param _major Major service version (Default: 0). + * \param _minor Minor service version (Default: 0). + * + */ + virtual void stop_offer_service(service_t _service, instance_t _instance, + major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = + DEFAULT_MINOR) = 0; + + /** + * + * \brief Offers a SOME/IP event or field. + * + * A user application must call this method for each event/field it wants + * to offer. The event is registered at the vsomeip routing component that + * enables other applications to subscribe to the event/field as well as + * to get and set the field value. + * + * \param _service Service identifier of the interface containing the + * event. + * \param _instance Instance identifier of the interface containing the + * event. + * \param _event Event identifier of the offered event. + * \param _eventgroups List of eventgroup identifiers of the eventgroups + * that contain the event. + * \param _is_field Selector for event or field. + * + */ + virtual void offer_event(service_t _service, + instance_t _instance, event_t _event, + const std::set<eventgroup_t> &_eventgroups, + bool _is_field) = 0; + + /** + * + * \brief Stops offering a SOME/IP event or field. + * + * A user application must call this method to withdraw the offer of an + * event or field. + * + * \param _service Service identifier of the interface that contains the + * event + * \param _instance Instance identifier of the interface that contains the + * event + * \param _event Event identifier of the offered event. + * + */ + virtual void stop_offer_event(service_t _service, + instance_t _instance, event_t _event) = 0; + + /** + * + * \brief Registers the application as client of a service instance. + * + * A user application must call this method for each service instance it + * wants to use. The request is stored within the routing component and the + * application is registered as client for the service as soon as the + * service instance becomes available. + * + * \param _service Service identifier of the requested service interface. + * \param _instance Instance identifier of the requested service instance. + * \param _major Major service version (Default: 0xFF). + * \param _minor Minor service version (Default: 0xFFFFFF). + * \param _use_exclusive_proxy Create an IP endpoint that is exclusively + * used for the communication of this application to the service instance. + * + */ + virtual void request_service(service_t _service, instance_t _instance, + major_version_t _major = ANY_MAJOR, + minor_version_t _minor = ANY_MINOR, + bool _use_exclusive_proxy = false) = 0; + + /** + * + * \brief Unregister the application as client of a service instance. + * + * A user application should call this method if it does not request to + * use the service instance any longer. The method unregisters the request + * a the routing component, which removes the service instance from the + * list of requested service instances if the call releases the last + * existing request for the service instance. This is important for + * external service instances, as the SOME/IP Service Discovery can avoid + * to send unnecessary Find messages. + * + * \param _service Service identifier of the offered service interface. + * \param _instance Instance identifier of the offered service instance. + * + */ + virtual void release_service(service_t _service, instance_t _instance) = 0; + + /** + * + * \brief Registers the application as user of an event or field. + * + * A user application must call this method before being able to receive + * event or field data. The method registers the event or field at the + * routing component. + * + * \param _service Service identifier of the interface that contains the + * event. + * \param _instance Instance identifier of the interface that contains the + * event. + * \param _event Event identifier of the event. + * \param _eventgroups List of Eventgroup identifiers of the eventgroups + * that contain the event. + * \param _is_field Pure event (false) or field (true). + * + */ + virtual void request_event(service_t _service, instance_t _instance, + event_t _event, const std::set<eventgroup_t> &_eventgroups, + bool _is_field) = 0; + /** + * + * \brief Unregister the application as user of an event or field. + * + * Unregister the application as user of an event or field and completely + * removes the event/field if the application is the last existing user. + * + * \param _service Service identifier of the interface that contains the + * event or field. + * \param _instance Instance identifier of the instance that contains the + * event or field. + * \param _event Event identifier of the event or field. + * . + */ + virtual void release_event(service_t _service, instance_t _instance, + event_t _event) = 0; + + /** + * + * \brief Subscribes to an eventgroup. + * + * A user application must call this function to subscribe to an eventgroup. + * Before calling subscribe it must register all events it interested in by + * calls to @ref request_event. The method additionally allows to specify + * a specific event. If a specific event is specified, all other events of + * the eventgroup are not received by the application. + * + * Note: For external services, providing a specific event does not change + * anything regarding the message routing. The specific event is only used + * to filter incoming events and to determine which initial events must be + * sent. + * + * \param _service Service identifier of the service that contains the + * eventgroup. + * \param _instance Instance identifier of the service that contains the + * eventgroup. + * \param _eventgroup Eventgroup identifier of the eventgroup. + * \param _major Major version number of the service. + * \param _subscription_type Specifies how the events shall be received. + * \param _event All (Default) or a specific event. + * + */ + virtual void subscribe(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, major_version_t _major = DEFAULT_MAJOR, + subscription_type_e _subscription_type = subscription_type_e::SU_RELIABLE_AND_UNRELIABLE, + event_t _event = ANY_EVENT) = 0; + + /** + * + * \brief Unsubscribes from an eventgroup. + * + * \param _service Service identifier of the service that contains the + * eventgroup. + * \param _instance Instance identifier of the service that contains the + * eventgroup. + * \param _eventgroup Eventgroup identifier of the eventgroup. + * + */ + virtual void unsubscribe(service_t _service, instance_t _instance, + eventgroup_t _eventgroup) = 0; + + /** + * + * \brief Retrieve for the availability of a service instance. + * + * If the version is also given, the result will only be true if the + * service instance is available in that specific version. + * + * \param _service Service identifier of the service instance. + * \param _instance Instance identifier of the service instance. + * \param _major Major interface version. Use ANY_MAJOR to ignore the + * major version. + * \param _minor Minor interface version. Use ANY_MINOR to ignore the + * minor version. + * + */ + virtual bool is_available(service_t _service, instance_t _instance, + major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) const = 0; + + /** + * + * \brief Sends a message. + * + * Serializes the specified message object, determines the taget and sends + * the message to the target. For requests, the request identifier is + * automatically built from the client identifier and the session + * identifier. + * + * \param _message Message object. + * \param _flush If set to true, the message is immediately sent. Otherwise + * the message might be deferred and sent together with other messages. + * + */ + virtual void send(std::shared_ptr<message> _message, bool _flush = true) = 0; + + /** + * + * \brief Fire an event or field notification. + * + * The specified event is updated with the specified payload data. + * Dependent on the type of the event, the payload is distributed to all + * notified clients (always for events, only if the payload has changed + * for fields). + * + * Note: Prior to using this method, @ref offer_event has to be called by + * the service provider. + * + * \param _service Service identifier of the service that contains the + * event. + * \param _instance Instance identifier of the service instance that + * holds the event. + * \param _event Event identifier of the event. + * \param _payload Serialized payload of the event. + * + */ + virtual void notify(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload) const = 0; + + /** + * + * \brief Fire an event to a specific client. + * + * The specified event is updated with the specified payload data. + * Dependent on the type of the event, the payload is distributed to all + * notified clients (always for events, only if the payload has changed + * for fields). + * + * Note: Prior to using this method, @ref offer_event has to be called by + * the service provider. + * + * \param _service Service identifier of the service that contains the + * event. + * \param _instance Instance identifier of the service instance that + * holds the event. + * \param _event Event identifier of the event. + * \param _payload Serialized payload of the event. + * \param _client Target client. + * + */ + virtual void notify_one(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + client_t _client) const = 0; + + /** + * + * \brief Register a state handler with the vsomeip runtime. + * + * The state handler tells if this client is successfully [de]registered + * at the central vsomeip routing component. This is called during the + * @ref start and @ref stop methods of this class to inform the user + * application about the registration state. + * + * \param _handler Handler function to be called on state change. + * + */ + virtual void register_state_handler(state_handler_t _handler) = 0; + + /** + * + * \brief Unregister the state handler. + * + */ + virtual void unregister_state_handler() = 0; + + /** + * + * \brief Registers a handler for the specified method or event. + * + * A user application must call this method to register callbacks for + * for messages that match the specified service, instance, method/event + * pattern. It is possible to specify wildcard values for all three + * identifiers arguments. + * + * Notes: + * - Only a single handler can be registered per service, instance, + * method/event combination. + * - A subsequent call will overwrite an existing registration. + * - Handler registrations containing wildcards can be active in parallel + * to handler registrations for specific service, instance, method/event + * combinations. + * + * \param _service Service identifier of the service that contains the + * method or event. Can be set to ANY_SERVICE to register a handler for + * a message independent from a specific service. + * \param _instance Instance identifier of the service instance that + * contains the method or event. Can be set to ANY_INSTANCE to register + * a handler for a message independent from a specific service. + * \param _method Method/Event identifier of the method/event that is + * to be handled. Can be set to ANY_METHOD to register a handler for + * all methods and events. + * \param _handler Callback that will be called if a message arrives + * that matches the specified service, instance and method/event + * parameters. + * + */ + virtual void register_message_handler(service_t _service, + instance_t _instance, method_t _method, + message_handler_t _handler) = 0; + /** + * + * \brief Unregisters the message handler for the specified service + * method/event notification. + * + * \param _service Service identifier of the service that contains the + * method or event. Can be set to ANY_SERVICE to unregister a handler for + * a message independent from a specific service. + * \param _instance Instance identifier of the service instance that + * contains the method or event. Can be set to ANY_INSTANCE to unregister + * a handler for a message independent from a specific service. + * \param _method Method/Event identifier of the method/event that is + * to be handled. Can be set to ANY_METHOD to unregister a handler for + * all methods and events. + */ + virtual void unregister_message_handler(service_t _service, + instance_t _instance, method_t _method) = 0; + + /** + * + * \brief Register a callback that is called when service instances + * availability changes. + * + * This method allows for the registration of callbacks that are called + * whenever a service appears or disappears. It is possible to specify + * wildcards for service, instance and/or version. Additionally, the + * version specification is optional and defaults to DEFAULT_MAJOR + * /DEFAULT_MINOR. + * + * \param _service Service identifier of the service instance whose + * availability shall be reported. Can be set to ANY_SERVICE. + * \param _instance Instance identifier of the service instance whose + * availability shall be reported. Can be set to ANY_INSTANCE. + * \param _handler Callback to be called if availability changes. + * \param _major Major service version. The parameter defaults to + * DEFAULT_MAJOR and can be set to ANY_MAJOR. + * \param _minor Minor service version. The parameter defaults to + * DEFAULT_MINOR and can be set to ANY_MINOR. + * + */ + virtual void register_availability_handler(service_t _service, + instance_t _instance, availability_handler_t _handler, + major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; + + /** + * + * \brief Unregister an availability callback. + * + * \param _service Service identifier of the service instance whose + * availability shall be reported. Can be set to ANY_SERVICE. + * \param _instance Instance identifier of the service instance whose + * availability shall be reported. Can be set to ANY_INSTANCE. + * \param _handler Callback to be called if availability changes. + * \param _major Major service version. The parameter defaults to + * DEFAULT_MAJOR and can be set to ANY_MAJOR. + * \param _minor Minor service version. The parameter defaults to + * DEFAULT_MINOR and can be set to ANY_MINOR. * + */ + virtual void unregister_availability_handler(service_t _service, + instance_t _instance, + major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; + + /** + * + * \brief Registers a subscription handler. + * + * A subscription handler is called whenever the subscription state of an + * eventgroup changes. The callback is called with the client identifier + * and a boolean that indicates whether the client subscribed or + * unsubscribed. + * + * \param _service Service identifier of service instance whose + * subscription state is to be monitored. + * \param _instance Instance identifier of service instance whose + * subscription state is to be monitored. + * \param _eventgroup Eventgroup identifier of eventgroup whose + * subscription state is to be monitored. + * \param _handler Callback that shall be called. + * + */ + virtual void register_subscription_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup, + subscription_handler_t _handler) = 0; + + /** + * + * \brief Unregister a subscription handler. + * + * \param _service Service identifier of service instance whose + * subscription state is to be monitored. + * \param _instance Instance identifier of service instance whose + * subscription state is to be monitored. + * \param _eventgroup Eventgroup identifier of eventgroup whose + * subscription state is to be monitored. + * + */ + virtual void unregister_subscription_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup) = 0; + + // [Un]Register handler for subscription errors + /** + * + * \brief Allows for the registration of a subscription error handler. + * + * This handler is called whenever a subscription request for an eventgroup + * was either accepted or rejected. The respective callback is called with + * ether OK (0x00) or REJECTED (0x07). + * + * \param _service Service identifier of service instance whose + * subscription error state is to be monitored. + * \param _instance Instance identifier of service instance whose + * subscription error state is to be monitored. + * \param _eventgroup Eventgroup identifier of eventgroup whose + * subscription error state is to be monitored. + * \param _handler Callback that shall be called. + * + */ + virtual void register_subscription_error_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup, + error_handler_t _handler) = 0; + + /** + * + * \brief Removes a registered subscription error callback. + * + * \param _service Service identifier of service instance whose + * error callback shall be removed. + * \param _instance Instance identifier of service instance whose + * error callback shall be removed. + * \param _eventgroup Eventgroup identifier of eventgroup whose + * error callback shall be removed. + * + */ + virtual void unregister_subscription_error_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup) = 0; + + /** + * + * \brief Unregister all registered handlers. + * + */ + virtual void clear_all_handler() = 0; + + /** + * + * \brief This method tells whether or not this application controls the + * message routing. + * + * The application that controls the routing hosts the routing manager + * and (optionally) loads the Service Discovery component. + * + * \return true, if this is the central routing instance, and false + * otherwise + * + */ + virtual bool is_routing() const = 0; + + /** + * + * \brief Offers a SOME/IP event or field. + * + * A user application must call this method for each event/field it wants + * to offer. The event is registered at the vsomeip routing component that + * enables other applications to subscribe to the event/field as well as + * to get and set the field value. + * + * This version of offer_event adds some additional functionalities: + * - It is possible to configure a cycle time. The notification message of + * this event is then resent cyclically. + * - The parameter _change_resets_cycle is available to control how event + * notification works in case the data is updated by the application. If + * set to true, an update of the data immediately leads to a + * notification. Otherwise, the updated data is sent only after the + * expiration of the cycle time. + * - It is possible to specify callback function that can be used to + * implement a predicate that determines whether or not two event values + * are considered different. Field notifications are only sent if the + * predicate evaluates to true (or if a notify method is called with the + * force flag being set). + * + * \param _service Service identifier of the interface containing the + * event. + * \param _instance Instance identifier of the interface containing the + * event. + * \param _event Event identifier of the offered event. + * \param _eventgroups List of eventgroup identifiers of the eventgroups + * that contain the event. + * \param _is_field Selector for event or field. + * \param _cycle Sets the cycle time of the event. If nonzero, data is + * resent cyclically after the cycle time expired. + * \param _change_resets_cycle Tells if a change immediately leads to + * a notification. + * \param _epsilon_change_func Predicate that determines if two given + * payloads are considered different. + * + * Note: The different versions of offer_event exist for compatibility + * reasons. They will be merged with the next major vsomeip version. + */ + virtual void offer_event(service_t _service, + instance_t _instance, event_t _event, + const std::set<eventgroup_t> &_eventgroups, + bool _is_field, + std::chrono::milliseconds _cycle, + bool _change_resets_cycle, + const epsilon_change_func_t &_epsilon_change_func) = 0; + + /** + * + * \brief Fire an event or field notification. + * + * The specified event is updated with the specified payload data. + * Dependent on the type of the event, the payload is distributed to all + * notified clients (always for events, only if the payload has changed + * for fields). + * + * Note: Prior to using this method, @ref offer_event has to be called by + * the service provider. + * + * \param _service Service identifier of the service that contains the + * event. + * \param _instance Instance identifier of the service instance that + * holds the event. + * \param _event Event identifier of the event. + * \param _payload Serialized payload of the event. + * \param _force Forces the notification to be sent (even if the event + * is a field and the value did not change). + * + * Note: The different versions of notify do exist for compatibility + * reasons. They will be merged with the next major vsomeip release. + */ + virtual void notify(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + bool _force) const = 0; + + /** + * + * \brief Fire an event or field notification. + * + * The specified event is updated with the specified payload data. + * Dependent on the type of the event, the payload is distributed to all + * notified clients (always for events, only if the payload has changed + * for fields). + * + * Note: Prior to using this method, @ref offer_event has to be called by + * the service provider. + * + * \param _service Service identifier of the service that contains the + * event. + * \param _instance Instance identifier of the service instance that + * holds the event. + * \param _event Event identifier of the event. + * \param _payload Serialized payload of the event. + * \param _client Target client. + * \param _force Forces the notification to be sent (even if the event + * is a field and the value did not change). + * + * Note: The different versions of notify_one do exist for compatibility + * reasons. They will be merged with the next major vsomeip release. + */ + virtual void notify_one(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + client_t _client, bool _force) const = 0; + + typedef std::map<service_t, std::map<instance_t, std::map<major_version_t, minor_version_t >>> available_t; + /** + * \brief Returns all available instances that match the given combination + * of service, instance and version. + * + * This method checks the availability of the service instances that + * match the specified combination of service, instance and version + * parameters. If at least one matching service instance is available, + * the method returns true, otherwise it returns false. All available + * service instances are returned to the caller by filling the + * _available parameter. + * + * \param _available Map that is filled with the available instances. + * \param _service Service identifier that specifies which service(s) + * are checked. + * \param _instance Instance identifier that specifies which instance(s) + * are checked. + * \param _major_version Major version(s) of the service instances that + * are checked + * \param _minor_version Minor version(s) of the service instance that + * are checked + */ + virtual bool are_available(available_t &_available, + service_t _service = ANY_SERVICE, instance_t _instance = ANY_INSTANCE, + major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; + + /** + * + * \brief Fire an event or field notification. + * + * The specified event is updated with the specified payload data. + * Dependent on the type of the event, the payload is distributed to all + * notified clients (always for events, only if the payload has changed + * for fields). + * + * Note: Prior to using this method, @ref offer_event has to be called by + * the service provider. + * + * \param _service Service identifier of the service that contains the + * event. + * \param _instance Instance identifier of the service instance that + * holds the event. + * \param _event Event identifier of the event. + * \param _payload Serialized payload of the event. + * \param _force Forces the notification to be sent (even if the event + * is a field and the value did not change). + * \param _flush Must be set to ensure the event is immediately fired. + * + * Note: The different versions of notify do exist for compatibility + * reasons. They will be merged with the next major vsomeip release. + */ + virtual void notify(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + bool _force, bool _flush) const = 0; + + /** + * + * \brief Fire an event or field notification. + * + * The specified event is updated with the specified payload data. + * Dependent on the type of the event, the payload is distributed to all + * notified clients (always for events, only if the payload has changed + * for fields). + * + * Note: Prior to using this method, @ref offer_event has to be called by + * the service provider. + * + * \param _service Service identifier of the service that contains the + * event. + * \param _instance Instance identifier of the service instance that + * holds the event. + * \param _event Event identifier of the event. + * \param _payload Serialized payload of the event. + * \param _client Target client. + * \param _force Forces the notification to be sent (even if the event + * is a field and the value did not change). + * \param _flush Must be set to ensure the event is immediately fired. + * + * Note: The different versions of notify_one do exist for compatibility + * reasons. They will be merged with the next major vsomeip release. + */ + virtual void notify_one(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + client_t _client, bool _force, bool _flush) const = 0; + + /** + * \brief Set the current routing state. + * + * The routing state impacts the behavior of the SOME/IP Service Discovery component. It + * can be set to RUNNING, SUSPENDED, RESUMED, SHUTDOWN or UNKNOWN. Applications only need + * to set the routing state if they are responsible for controlling the routing manager. + * In most environments the vsomeip daemon is controlling the routing manager. + * + * \param _routing_state the current routing state + */ + virtual void set_routing_state(routing_state_e _routing_state) = 0; + + /** + * + * \brief Unsubscribes from an eventgroup. + * + * \param _service Service identifier of the service that contains the + * eventgroup. + * \param _instance Instance identifier of the service that contains the + * eventgroup. + * \param _eventgroup Eventgroup identifier of the eventgroup. + * \param _event Event to unsubscribe (pass ANY_EVENT for all events of the eventgroup) + */ + virtual void unsubscribe(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, event_t _event) = 0; + + + /** + * + * \brief Registers a subscription status listener. + * + * When registered such a handler it will be called for + * every application::subscribe call. + * + * This method is intended to replace the application:: + * register_subscription_error_handler call in future releases. + * + * \param _service Service identifier of the service that is subscribed to. + * \param _instance Instance identifier of the service that is subscribed to. + * \param _eventgroup Eventgroup identifier of the eventgroup is subscribed to. + * \param _event Event indentifier of the event is subscribed to. + * \param _handler A subscription status handler which will be called by vSomeIP + * as a follow of application::subscribe. + */ + virtual void register_subscription_status_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event, + subscription_status_handler_t _handler) = 0; + + /** + * + * \brief Registers a subscription status listener. + * + * When registered such a handler it will be called for + * every application::subscribe call. + * + * This method is intended to replace the application:: + * register_subscription_error_handler call in future releases. + * + * \param _service Service identifier of the service that is subscribed to. + * \param _instance Instance identifier of the service that is subscribed to. + * \param _eventgroup Eventgroup identifier of the eventgroup is subscribed to. + * \param _event Event indentifier of the event is subscribed to. + * \param _handler A subscription status handler which will be called by vSomeIP + * as a follow of application::subscribe. + * \param _is_selective Flag to enable calling the provided handler if the + * subscription is answered with a SUBSCRIBE_NACK. + */ + virtual void register_subscription_status_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event, + subscription_status_handler_t _handler, bool _is_selective) = 0; + + /** + * + * \brief Returns all registered services / instances on this node in an async callback. + * + * When called with a handler of type offered_services_handler_t, + * all at the routing manager registered services on this node get returned in a vector of + * service / instance pairs depending on the given _offer_type. + * + * \param _offer_type type of offered services to be returned (OT_LOCAL = 0x00, OT_REMOTE = 0x01, OT_ALL = 0x02) + * \param offered_services_handler_t handler which gets called with a vector of service instance pairs that are currently offered + */ + virtual void get_offered_services_async(offer_type_e _offer_type, offered_services_handler_t _handler) = 0; + + /** + * + * \brief Sets a handler to be called cyclically for watchdog monitoring. + * + * The handler shall be called in the given interval, but not before start() + * has been called, and not after call to stop() returned. + * + * In case the application is running, i.e. start() succeeded, but the + * handler will not be invoke within the (approximate) interval it may + * be assumed that I/O or internal dispatcher threads are non-functional. + * + * \remark Accuracy of call interval is limited by clock/timer granularity + * or scheduling effects, thus it may underrun or overrun by small + * amount. + * + * \note Only one handler can be active at the time, thus last handler set + * by calling this function will be invoked. + * + * \note To disable calling an active handler, invoke this method again, + * passing nullptr as _handler and/or std::chrono::seconds::zero() + * as _interval. + * + * \param _handler A watchdog handler, pass nullptr to deactivate. + * \param _interval Call interval in seconds, pass std::chrono::seconds::zero() to deactivate. + */ + virtual void set_watchdog_handler(watchdog_handler_t _handler, std::chrono::seconds _interval) = 0; + + /** + * + * \brief Registers a subscription handler. + * + * A subscription handler is called whenever the subscription state of an + * eventgroup changes. The callback is called with the client identifier + * and a boolean that indicates whether the client subscribed or + * unsubscribed. + * + * \param _service Service identifier of service instance whose + * subscription state is to be monitored. + * \param _instance Instance identifier of service instance whose + * subscription state is to be monitored. + * \param _eventgroup Eventgroup identifier of eventgroup whose + * subscription state is to be monitored. + * \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; + + /** + * \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; +}; + +/** @} */ + +} // namespace vsomeip + +#endif // VSOMEIP_APPLICATION_HPP diff --git a/interface/compat/vsomeip/constants.hpp b/interface/compat/vsomeip/constants.hpp new file mode 100644 index 0000000..2d14920 --- /dev/null +++ b/interface/compat/vsomeip/constants.hpp @@ -0,0 +1,63 @@ +// 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_CONSTANTS_HPP +#define VSOMEIP_CONSTANTS_HPP + +#include <string> + +#include "../../compat/vsomeip/enumeration_types.hpp" +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +const major_version_t DEFAULT_MAJOR = 0x00; +const minor_version_t DEFAULT_MINOR = 0x00000000; +const ttl_t DEFAULT_TTL = 0xFFFFFF; // "until next reboot" + +const std::string DEFAULT_MULTICAST = "224.0.0.0"; +const uint16_t DEFAULT_PORT = 30500; +const uint16_t ILLEGAL_PORT = 0xFFFF; + +const uint16_t NO_TRACE_FILTER_EXPRESSION = 0x0000; + +const service_t ANY_SERVICE = 0xFFFF; +const instance_t ANY_INSTANCE = 0xFFFF; +const method_t ANY_METHOD = 0xFFFF; +const major_version_t ANY_MAJOR = 0xFF; +const minor_version_t ANY_MINOR = 0xFFFFFFFF; + +const eventgroup_t DEFAULT_EVENTGROUP = 0x0001; + +const client_t ILLEGAL_CLIENT = 0x0000; + +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 = + message_type_e::MT_REQUEST_NO_RETURN; +const message_type_e MAGIC_COOKIE_SERVICE_MESSAGE_TYPE = + message_type_e::MT_NOTIFICATION; +const return_code_e MAGIC_COOKIE_RETURN_CODE = return_code_e::E_OK; + +const byte_t CLIENT_COOKIE[] = { 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x01, 0x01, 0x00 }; + +const byte_t SERVICE_COOKIE[] = { 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x08, 0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x01, 0x02, 0x00 }; + +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 + +#endif // VSOMEIP_CONSTANTS_HPP diff --git a/interface/compat/vsomeip/defines.hpp b/interface/compat/vsomeip/defines.hpp new file mode 100644 index 0000000..0442fae --- /dev/null +++ b/interface/compat/vsomeip/defines.hpp @@ -0,0 +1,41 @@ +// 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_DEFINES_HPP +#define VSOMEIP_DEFINES_HPP + +#define VSOMEIP_PROTOCOL_VERSION 0x1 + +// 0 = unlimited, if not specified otherwise via configuration file +#define VSOMEIP_MAX_LOCAL_MESSAGE_SIZE 0 +// 0 = unlimited, if not specified otherwise via configuration file +#define VSOMEIP_MAX_TCP_MESSAGE_SIZE 0 +#define VSOMEIP_MAX_UDP_MESSAGE_SIZE 1416 + +#define VSOMEIP_PACKET_SIZE VSOMEIP_MAX_UDP_MESSAGE_SIZE + +#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 +#define VSOMEIP_METHOD_POS_MIN 2 +#define VSOMEIP_METHOD_POS_MAX 3 +#define VSOMEIP_EVENT_POS_MIN 2 +#define VSOMEIP_EVENT_POS_MAX 3 +#define VSOMEIP_LENGTH_POS_MIN 4 +#define VSOMEIP_LENGTH_POS_MAX 7 +#define VSOMEIP_CLIENT_POS_MIN 8 +#define VSOMEIP_CLIENT_POS_MAX 9 +#define VSOMEIP_SESSION_POS_MIN 10 +#define VSOMEIP_SESSION_POS_MAX 11 +#define VSOMEIP_PROTOCOL_VERSION_POS 12 +#define VSOMEIP_INTERFACE_VERSION_POS 13 +#define VSOMEIP_MESSAGE_TYPE_POS 14 +#define VSOMEIP_RETURN_CODE_POS 15 +#define VSOMEIP_PAYLOAD_POS 16 + +#endif // VSOMEIP_DEFINES_HPP diff --git a/interface/compat/vsomeip/enumeration_types.hpp b/interface/compat/vsomeip/enumeration_types.hpp new file mode 100644 index 0000000..71ff38a --- /dev/null +++ b/interface/compat/vsomeip/enumeration_types.hpp @@ -0,0 +1,81 @@ +// 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_ENUMERATION_TYPES_HPP +#define VSOMEIP_ENUMERATION_TYPES_HPP + +#include <cstdint> + +namespace vsomeip { + +enum class state_type_e : uint8_t { + ST_REGISTERED = 0x0, + ST_DEREGISTERED = 0x1 +}; + +// SIP_RPC_684 +enum class message_type_e : uint8_t { + MT_REQUEST = 0x00, + MT_REQUEST_NO_RETURN = 0x01, + MT_NOTIFICATION = 0x02, + MT_REQUEST_ACK = 0x40, + MT_REQUEST_NO_RETURN_ACK = 0x41, + MT_NOTIFICATION_ACK = 0x42, + MT_RESPONSE = 0x80, + MT_ERROR = 0x81, + MT_RESPONSE_ACK = 0xC0, + MT_ERROR_ACK = 0xC1, + MT_UNKNOWN = 0xFF +}; + +// SIP_RPC_371 +enum class return_code_e : uint8_t { + E_OK = 0x00, + E_NOT_OK = 0x01, + E_UNKNOWN_SERVICE = 0x02, + E_UNKNOWN_METHOD = 0x03, + E_NOT_READY = 0x04, + E_NOT_REACHABLE = 0x05, + E_TIMEOUT = 0x06, + E_WRONG_PROTOCOL_VERSION = 0x07, + E_WRONG_INTERFACE_VERSION = 0x08, + E_MALFORMED_MESSAGE = 0x09, + E_WRONG_MESSAGE_TYPE = 0xA, + E_UNKNOWN = 0xFF +}; + +enum class subscription_type_e : uint8_t { + SU_RELIABLE_AND_UNRELIABLE = 0x00, + SU_PREFER_UNRELIABLE = 0x01, + SU_PREFER_RELIABLE = 0x02, + SU_UNRELIABLE = 0x03, + SU_RELIABLE = 0x04, +}; + +enum class routing_state_e : uint8_t { + RS_RUNNING = 0x00, + RS_SUSPENDED = 0x01, + RS_RESUMED = 0x02, + RS_SHUTDOWN = 0x03, + RS_DIAGNOSIS = 0x04, + RS_UNKNOWN = 0xFF +}; + +enum class offer_type_e : uint8_t { + OT_LOCAL = 0x00, + OT_REMOTE = 0x01, + 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/compat/vsomeip/error.hpp b/interface/compat/vsomeip/error.hpp new file mode 100644 index 0000000..175f265 --- /dev/null +++ b/interface/compat/vsomeip/error.hpp @@ -0,0 +1,26 @@ +// 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_ERROR_HPP +#define VSOMEIP_ERROR_HPP + +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +enum class error_code_e : uint8_t { + CONFIGURATION_MISSING, + PORT_CONFIGURATION_MISSING, + CLIENT_ENDPOINT_CREATION_FAILED, + SERVER_ENDPOINT_CREATION_FAILED, + SERVICE_PROPERTY_MISMATCH +}; + +extern const char *ERROR_INFO[]; + +} // namespace vsomeip + +#endif // VSOMEIP_ERROR_HPP + diff --git a/interface/compat/vsomeip/export.hpp b/interface/compat/vsomeip/export.hpp new file mode 100644 index 0000000..a8577ee --- /dev/null +++ b/interface/compat/vsomeip/export.hpp @@ -0,0 +1,30 @@ +// 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 __EXPORT__HPP__ +#define __EXPORT__HPP__ + +#if _WIN32 + #define VSOMEIP_EXPORT __declspec(dllexport) + #define VSOMEIP_EXPORT_CLASS_EXPLICIT + + #if VSOMEIP_DLL_COMPILATION + #define VSOMEIP_IMPORT_EXPORT __declspec(dllexport) + #else + #define VSOMEIP_IMPORT_EXPORT __declspec(dllimport) + #endif + + #if VSOMEIP_DLL_COMPILATION_CONFIG + #define VSOMEIP_IMPORT_EXPORT_CONFIG __declspec(dllexport) + #else + #define VSOMEIP_IMPORT_EXPORT_CONFIG __declspec(dllimport) + #endif +#else + #define VSOMEIP_EXPORT + #define VSOMEIP_IMPORT_EXPORT + #define VSOMEIP_IMPORT_EXPORT_CONFIG +#endif + +#endif diff --git a/interface/compat/vsomeip/function_types.hpp b/interface/compat/vsomeip/function_types.hpp new file mode 100644 index 0000000..aa086dd --- /dev/null +++ b/interface/compat/vsomeip/function_types.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2016-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_FUNCTION_TYPES_HPP +#define VSOMEIP_FUNCTION_TYPES_HPP + +#include <functional> +#include <memory> + +namespace vsomeip { + +class payload; + +typedef std::function< + bool (const std::shared_ptr<payload> &, + const std::shared_ptr<payload> &) > epsilon_change_func_t; + +} // namespace vsomeip + +#endif // VSOMEIP_FUNCTION_TYPES_HPP diff --git a/interface/compat/vsomeip/handler.hpp b/interface/compat/vsomeip/handler.hpp new file mode 100644 index 0000000..4c74255 --- /dev/null +++ b/interface/compat/vsomeip/handler.hpp @@ -0,0 +1,72 @@ +// 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_HANDLER_HPP +#define VSOMEIP_HANDLER_HPP + +#include <functional> +#include <memory> + +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +class message; + +typedef std::function< void (state_type_e) > state_handler_t; +typedef std::function< void (const std::shared_ptr< message > &) > message_handler_t; +typedef std::function< void (service_t, instance_t, bool) > availability_handler_t; +typedef std::function< bool (client_t, bool) > subscription_handler_t; +typedef std::function< void (const uint16_t) > error_handler_t; +typedef std::function< void (const service_t, const instance_t, const eventgroup_t, + const event_t, const uint16_t) > subscription_status_handler_t; +typedef std::function< void (client_t, bool, std::function< void (const bool) > )> async_subscription_handler_t; + +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 + +#endif // VSOMEIP_HANDLER_HPP diff --git a/interface/compat/vsomeip/internal/deserializable.hpp b/interface/compat/vsomeip/internal/deserializable.hpp new file mode 100644 index 0000000..10ead19 --- /dev/null +++ b/interface/compat/vsomeip/internal/deserializable.hpp @@ -0,0 +1,24 @@ +// 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_DESERIALIZABLE_HPP +#define VSOMEIP_DESERIALIZABLE_HPP + +#include "../../../compat/vsomeip/export.hpp" + +namespace vsomeip { + +class deserializer; + +class deserializable { +public: + VSOMEIP_EXPORT virtual ~deserializable() { + } + VSOMEIP_EXPORT virtual bool deserialize(deserializer *_from) = 0; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_SERIALIZABLE_HPP diff --git a/interface/compat/vsomeip/internal/serializable.hpp b/interface/compat/vsomeip/internal/serializable.hpp new file mode 100644 index 0000000..8363f4b --- /dev/null +++ b/interface/compat/vsomeip/internal/serializable.hpp @@ -0,0 +1,30 @@ +// 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_SERIALIZABLE_HPP +#define VSOMEIP_SERIALIZABLE_HPP + +#include "../../../compat/vsomeip/export.hpp" + +namespace vsomeip { + +class serializer; + +/** + * Abstract base class for element that can be serialized. + */ +class serializable { +public: + VSOMEIP_EXPORT virtual ~serializable() {} + + /** + * \brief serialize the content of the object + */ + VSOMEIP_EXPORT virtual bool serialize(serializer *_to) const = 0; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_SERIALIZABLE_HPP diff --git a/interface/compat/vsomeip/message.hpp b/interface/compat/vsomeip/message.hpp new file mode 100644 index 0000000..b7049ee --- /dev/null +++ b/interface/compat/vsomeip/message.hpp @@ -0,0 +1,52 @@ +// 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_MESSAGE_HPP +#define VSOMEIP_MESSAGE_HPP + +#include <memory> + +#include "../../compat/vsomeip/message_base.hpp" + +namespace vsomeip { + +class payload; + +/** + * + * \defgroup vsomeip + * + * @{ + * + */ + +/** + * \brief Implements regular SOME/IP messages. + * + * This class extends @ref message_base by an unstructured payload. Except + * SOME/IP Service Discovery messages, all SOME/IP messages within vsomeip + * are represented by message objects. + */ + +class message: virtual public message_base { +public: + virtual ~message() {} + + /** + * \brief Returns a pointer to the message payload. + */ + virtual std::shared_ptr<payload> get_payload() const = 0; + + /** + * \brief Set the message payload. + */ + virtual void set_payload(std::shared_ptr<payload> _payload) = 0; +}; + +/** @} */ + +} // namespace vsomeip + +#endif // VSOMEIP_MESSAGE_HPP diff --git a/interface/compat/vsomeip/message_base.hpp b/interface/compat/vsomeip/message_base.hpp new file mode 100644 index 0000000..ffc81fb --- /dev/null +++ b/interface/compat/vsomeip/message_base.hpp @@ -0,0 +1,211 @@ +// 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_MESSAGE_BASE_HPP +#define VSOMEIP_MESSAGE_BASE_HPP + +#include "../../compat/vsomeip/enumeration_types.hpp" +#include "../../compat/vsomeip/export.hpp" +#include "../../compat/vsomeip/internal/deserializable.hpp" +#include "../../compat/vsomeip/internal/serializable.hpp" +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +/** + * + * \defgroup vsomeip + * + * @{ + * + */ + +/** + * \brief Base class to implement SOME/IP messages. + * + * This class implements the SOME/IP message header and connects to the + * serialzing/deserializing functionalities. The class is inherited by + * the message classes within ::vsomeip and vsomeip::sd that add the + * payload representations for regular and Service Discovery messages. + */ +class message_base + : public serializable, + public deserializable { +public: + VSOMEIP_EXPORT virtual ~message_base() {}; + + /** + * \brief Returns the message identifier. + * + * The method returns the message identifier that consists of + * service identifier and method identifier. + */ + VSOMEIP_EXPORT virtual message_t get_message() const = 0; + /** + * \brief Set the message identifier. + * + * The methods sets service identifier and method identifier in + * a single call. + * + * \param _message The new message identifier. + */ + VSOMEIP_EXPORT virtual void set_message(message_t _message) = 0; + + /** + * \brief Returns the service identifier from the message header. + */ + VSOMEIP_EXPORT virtual service_t get_service() const = 0; + + /** + * \brief Set the service identifier in the message header. + */ + VSOMEIP_EXPORT virtual void set_service(service_t _service) = 0; + + /** + * \brief Returns the instance identifier. + * + * The instance identifier is _not_ part of the SOME/IP header. It is + * either derived from the incoming message (local) or from the port + * that was used to send a message (external). + */ + VSOMEIP_EXPORT virtual instance_t get_instance() const = 0; + + /** + * \brief Set the instance identifier in the message header. + * + * To address the correct service instance, vsomeip uses the instance + * identifier. For external services it is mapped to a IP address and port + * combination before the message is sent. For internal messages is + * transferred as additional data appended to the SOME/IP messages. + * Therefore, before sending a message, a user application must set the + * instance identifier. + */ + VSOMEIP_EXPORT virtual void set_instance(instance_t _instance) = 0; + + /** + * \brief Get the method/event identifier from the message header. + */ + VSOMEIP_EXPORT virtual method_t get_method() const = 0; + + /** + * \brief Set the method/event identifier in the message header. + */ + VSOMEIP_EXPORT virtual void set_method(method_t _method) = 0; + + /** + * \brief Get the payload length from the message header. + */ + VSOMEIP_EXPORT virtual length_t get_length() const = 0; + + /** + * \brief Get the request identifier from the message header. + * + * The request identifier consists of the client identifier and the + * session identifier. As it does really make sense to set it as + * a whole, setting is not supported. + */ + VSOMEIP_EXPORT virtual request_t get_request() const = 0; + + /** + * \brief Set the client identifier in the message header. + */ + VSOMEIP_EXPORT virtual client_t get_client() const = 0; + + /** + * \brief Set the client identifier in the message header. + * + * For requests this is automatically done by @ref application::send. + * For notications this is not needed. + */ + VSOMEIP_EXPORT virtual void set_client(client_t _client) = 0; + + /** + * \brief Get the session identifier from the message header. + */ + VSOMEIP_EXPORT virtual session_t get_session() const = 0; + + /** + * \brief Set the session identifier in the message header. + * + * For requests this is automatically done by @ref application::send + * For notifications it is not needed to set the session identifier. + */ + VSOMEIP_EXPORT virtual void set_session(session_t _session) = 0; + + /** + * \brief Get the protocol version from the message header. + * + * As the protocol version is a fixed value for a vsomeip implementation, + * it cannot be set. + */ + VSOMEIP_EXPORT virtual protocol_version_t get_protocol_version() const = 0; + + /** + * \brief Get the interface version from the message header. + */ + VSOMEIP_EXPORT virtual interface_version_t get_interface_version() const = 0; + + /** + * \brief Set the interface version in the message header. + */ + VSOMEIP_EXPORT virtual void set_interface_version(interface_version_t _version) = 0; + + /** + * \brief Get the message type from the message header. + */ + VSOMEIP_EXPORT virtual message_type_e get_message_type() const = 0; + + /** + * \brief Set the message type in the message header. + */ + VSOMEIP_EXPORT virtual void set_message_type(message_type_e _type) = 0; + + /** + * \brief Get the return code from the message header. + */ + VSOMEIP_EXPORT virtual return_code_e get_return_code() const = 0; + + /** + * \brief Set the return code in the message header. + */ + VSOMEIP_EXPORT virtual void set_return_code(return_code_e _code) = 0; + + /** + * \brief Return the transport mode that was/will be used to send the message. + */ + VSOMEIP_EXPORT virtual bool is_reliable() const = 0; + + /** + * \brief Set the transport mode that will be used to send the message. + */ + VSOMEIP_EXPORT virtual void set_reliable(bool _is_reliable) = 0; + + /** + * \brief Return whether or not the message is an initial event. + */ + VSOMEIP_EXPORT virtual bool is_initial() const = 0; + + /** + * \brief Set whether or not the message is an initial event. + */ + VSOMEIP_EXPORT virtual void set_initial(bool _is_initial) = 0; + + /** + * \brief Return whether or not the CRC value received is valid. + */ + VSOMEIP_EXPORT virtual bool is_valid_crc() const = 0; + + /** + * \brief Set whether or not the CRC value received is valid. + */ + VSOMEIP_EXPORT virtual void set_is_valid_crc(bool _is_valid_crc) = 0; + +}; + +/** @} */ + +} // namespace vsomeip + +#endif // VSOMEIP_MESSAGE_BASE_HPP diff --git a/interface/compat/vsomeip/payload.hpp b/interface/compat/vsomeip/payload.hpp new file mode 100644 index 0000000..e604a3d --- /dev/null +++ b/interface/compat/vsomeip/payload.hpp @@ -0,0 +1,105 @@ +// 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_PAYLOAD_HPP +#define VSOMEIP_PAYLOAD_HPP + +#include <vector> + +#include "../../compat/vsomeip/export.hpp" +#include "../../compat/vsomeip/internal/deserializable.hpp" +#include "../../compat/vsomeip/internal/serializable.hpp" +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +/** + * + * \defgroup vsomeip + * + * @{ + * + */ + +/** + * + * \brief This class implements an array of bytes to be used as + * payload for SOME/IP messages. + * +*/ +class payload: public serializable, public deserializable { +public: + VSOMEIP_EXPORT virtual ~payload() {} + + /** + * \brief Returns true if the given payload is equal to this one. + * + * \param _other Payload that shall be compared to this payload. + */ + VSOMEIP_EXPORT virtual bool operator ==(const payload &_other) = 0; + + /** + * \brief Returns pointer to the payload content + */ + VSOMEIP_EXPORT virtual byte_t * get_data() = 0; + + /** + * \brief Returns constant pointer to the payload content + */ + VSOMEIP_EXPORT virtual const byte_t * get_data() const = 0; + + /** + * \brief Copies the given data array to the payload object. + * + * The current payload content is replaced by the data provided. + * The given buffer remains untouched. + * + * \param _data Pointer to a data buffer. + * \param _length Length of the data buffer. + */ + VSOMEIP_EXPORT virtual void set_data(const byte_t *_data, + length_t _length) = 0; + + /** + * \brief Copies the given data array to the payload object. + * + * The current payload content is replaced by the data provided. + * The given buffer remains untouched. + * + * \param _data Vector containing the data + */ + VSOMEIP_EXPORT virtual void set_data( + const std::vector<byte_t> &_data) = 0; + + /** + * \brief Returns the length of the payload content. + */ + VSOMEIP_EXPORT virtual length_t get_length() const = 0; + + /** + * \brief Set the maximum length of the payload content. + * + * This function must be called before directly copying data using the + * pointer to the internal buffer. + */ + VSOMEIP_EXPORT virtual void set_capacity(length_t _length) = 0; + + /** + * \brief Moves the given data array to the payload object. + * + * The current payload content is replaced by the data provided. + * The given buffer is owned by the payload object afterwards. + * + * \param _data Vector containing the data + */ + VSOMEIP_EXPORT virtual void set_data( + std::vector<byte_t> &&_data) = 0; +}; + +/** @} */ + +} // namespace vsomeip + +#endif // VSOMEIP_PAYLOAD_HPP diff --git a/interface/compat/vsomeip/plugin.hpp b/interface/compat/vsomeip/plugin.hpp new file mode 100644 index 0000000..4d608f1 --- /dev/null +++ b/interface/compat/vsomeip/plugin.hpp @@ -0,0 +1,89 @@ +// Copyright (C) 2016-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_PLUGIN_HPP +#define VSOMEIP_PLUGIN_HPP + +#include <memory> + +#if WIN32 + #if VSOMEIP_DLL_COMPILATION_PLUGIN + #define VSOMEIP_IMPORT_EXPORT_PLUGIN __declspec(dllexport) + #else + #define VSOMEIP_IMPORT_EXPORT_PLUGIN __declspec(dllimport) + #endif +#else + #define VSOMEIP_IMPORT_EXPORT_PLUGIN +#endif + +#define VSOMEIP_PLUGIN_INIT_SYMBOL "vsomeip_plugin_init" + +namespace vsomeip { + +enum class plugin_type_e : uint8_t { + APPLICATION_PLUGIN, + PRE_CONFIGURATION_PLUGIN, + CONFIGURATION_PLUGIN, + SD_RUNTIME_PLUGIN +}; + +class plugin; +typedef std::shared_ptr<plugin> (*create_plugin_func)(); +typedef create_plugin_func (*plugin_init_func)(); + +/** + * Base class for all plug-ins + */ +class VSOMEIP_IMPORT_EXPORT_PLUGIN plugin { +public: + virtual ~plugin() {} + + virtual uint32_t get_plugin_version() const = 0; + virtual const std::string &get_plugin_name() const = 0; + virtual plugin_type_e get_plugin_type() const = 0; +}; + +template<class Plugin_> +class plugin_impl : public plugin { +public: + static std::shared_ptr<plugin> get_plugin() { + return std::make_shared<Plugin_>(); + } + + plugin_impl(const std::string &_name, uint32_t _version, + plugin_type_e _type) { + name_ = _name; + version_ = _version; + type_ = _type; + } + + const std::string &get_plugin_name() const { + return name_; + } + + uint32_t get_plugin_version() const { + return version_; + } + + plugin_type_e get_plugin_type() const { + return type_; + } + +private: + uint32_t version_; + std::string name_; + plugin_type_e type_; +}; + +#define VSOMEIP_PLUGIN(class_name) \ + extern "C" { \ + VSOMEIP_EXPORT vsomeip::create_plugin_func vsomeip_plugin_init() { \ + return class_name::get_plugin; \ + } \ + } + +} // namespace vsomeip + +#endif // VSOMEIP_PLUGIN_HPP diff --git a/interface/compat/vsomeip/plugins/application_plugin.hpp b/interface/compat/vsomeip/plugins/application_plugin.hpp new file mode 100644 index 0000000..7f0bb4a --- /dev/null +++ b/interface/compat/vsomeip/plugins/application_plugin.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016-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_APPLICATION_PLUGIN_HPP +#define VSOMEIP_APPLICATION_PLUGIN_HPP + +#include <string> +#include <memory> + +#include "../../../compat/vsomeip/export.hpp" + +// Version should be incremented on breaking API change +#define VSOMEIP_APPLICATION_PLUGIN_VERSION 1 + +namespace vsomeip { + +enum class application_plugin_state_e : uint8_t { + STATE_INITIALIZED, + STATE_STARTED, + STATE_STOPPED +}; + +/** + * The application plug-in can be used to extend application behavior + * via an module/plug-in. + */ +class application_plugin { +public: + virtual ~application_plugin() {} + + // Called by vSomeIP to inform an application plug-in about its actual state + // Call should not be blocked from plug-in as there is no threading. + // The caller thread of "application::init/::start/::stop" will inform the plug-in. + virtual void on_application_state_change(const std::string _application_name, + const application_plugin_state_e _app_state) = 0; +}; + +} + +#endif // VSOMEIP_APPLICATION_PLUGIN_HPP diff --git a/interface/compat/vsomeip/plugins/pre_configuration_plugin.hpp b/interface/compat/vsomeip/plugins/pre_configuration_plugin.hpp new file mode 100644 index 0000000..bce60b0 --- /dev/null +++ b/interface/compat/vsomeip/plugins/pre_configuration_plugin.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2016-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_PRE_CONFIGURATION_PLUGIN_HPP +#define VSOMEIP_PRE_CONFIGURATION_PLUGIN_HPP + +#include "../../../compat/vsomeip/export.hpp" + +// Version should be incremented on breaking API change +#define VSOMEIP_PRE_CONFIGURATION_PLUGIN_VERSION 1 + +namespace vsomeip { +/** + * The pre configuration plug-in can be used to extend configuration load behavior + * via an module/plug-in. + */ +class pre_configuration_plugin { +public: + virtual ~pre_configuration_plugin() {} + + // Plug-In should return a valid path to a vSomeIP configuration. + // vSomeIP will use this path for config loading if such a plug-in is availablel. + virtual std::string get_configuration_path() = 0; +}; +} + +#endif // VSOMEIP_PRE_CONFIGURATION_PLUGIN_HPP diff --git a/interface/compat/vsomeip/primitive_types.hpp b/interface/compat/vsomeip/primitive_types.hpp new file mode 100644 index 0000000..93c9960 --- /dev/null +++ b/interface/compat/vsomeip/primitive_types.hpp @@ -0,0 +1,66 @@ +// 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_PRIMITIVE_TYPES_HPP +#define VSOMEIP_PRIMITIVE_TYPES_HPP + +#include <array> +#include <cstdint> + +#ifndef _WIN32 +#include <sys/types.h> +#endif + +namespace vsomeip { + +typedef uint32_t message_t; +typedef uint16_t service_t; +typedef uint16_t method_t; +typedef uint16_t event_t; + +typedef uint16_t instance_t; +typedef uint16_t eventgroup_t; + +typedef uint8_t major_version_t; +typedef uint32_t minor_version_t; + +typedef uint32_t ttl_t; + +typedef uint32_t request_t; +typedef uint16_t client_t; +typedef uint16_t session_t; + +typedef uint32_t length_t; + +typedef uint8_t protocol_version_t; +typedef uint8_t interface_version_t; + +typedef uint8_t byte_t; + +// Addresses +typedef std::array<byte_t, 4> ipv4_address_t; +typedef std::array<byte_t, 16> ipv6_address_t; + +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; + +#ifdef _WIN32 + typedef std::uint32_t uid_t; + typedef std::uint32_t gid_t; +#else + typedef ::uid_t uid_t; + typedef ::uid_t gid_t; +#endif + +} // namespace vsomeip + +#endif // VSOMEIP_PRIMITIVE_TYPES_HPP diff --git a/interface/compat/vsomeip/runtime.hpp b/interface/compat/vsomeip/runtime.hpp new file mode 100644 index 0000000..a3cb0d3 --- /dev/null +++ b/interface/compat/vsomeip/runtime.hpp @@ -0,0 +1,216 @@ +// 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_RUNTIME_HPP +#define VSOMEIP_RUNTIME_HPP + +#include <memory> +#include <string> +#include <vector> + +#include "../../compat/vsomeip/export.hpp" +#include "../../compat/vsomeip/primitive_types.hpp" + +namespace vsomeip { + +class application; +class message; +class payload; + +/** + * + * \defgroup vsomeip + * + * The vsomeip module contains all elements a user applications needs to: + * + * - offer SOME/IP service instances + * - request SOME/IP service instances + * - offer SOME/IP eventgroups + * - subscribe to SOME/IP eventgroups + * - send and receive SOME/IP messages (request/response) + * - implement SOME/IP events and fields + * + * @{ + * + */ + +/** + * + * \brief Singleton class containing all public resource management + * facilities of vsomeip. + * + * The methods of this class shall be used to create instances of all the + * classes needed to facilitate SOME/IP communication. In particular, it is + * the entry point to create instances of the @ref application class that + * contains the main public API of vsomeip. + * + */ +class VSOMEIP_IMPORT_EXPORT runtime { +public: + + static std::string get_property(const std::string &_name); + static void set_property(const std::string &_name, const std::string &_value); + + static std::shared_ptr<runtime> get(); + + virtual ~runtime() { + } + + /** + * + * \brief Creates a vsomeip application object. + * + * An application object manages service offers and requests as well as + * event subscriptions. It allows to register user application functions + * as callbacks that are called on specific events during runtime, e.g + * to react on incoming SOME/IP messages. + * An application object is identified by a unique name that is also used + * in (and therefore has to match) the configuration files of vsomeip. If + * the name is left empty, the application name is taken from the + * environment variable "VSOMEIP_APPLICATION_NAME" + * + * \param _name Name of the application on the system. + * + */ + virtual std::shared_ptr<application> create_application( + const std::string &_name = "") = 0; + + /** + * + * \brief Constructs an empty message object. + * + * The message can then be used to call @application::send to send a + * SOME/IP message. The user application is responsible for setting + * the message type, the service instance and the message payload + * after this call and before calling @application::send. + * + * \param _reliable Determines whether this message shall be sent + * over a reliable connection (TCP) or not (UDP). + * + */ + virtual std::shared_ptr<message> create_message( + bool _reliable = false) const = 0; + /** + * + * \brief Constructs an empty request message. + * + * The message can then be used to call @ref application::send to send a + * SOME/IP message. The message type is set to REQUEST after the + * call and the request identifier is automatically set during the + * @ref application::send call. + * + * The user application is responsible for setting the service instance + * and the payload. + * + * \param _reliable Determines whether this message shall be sent + * over a reliable connection (TCP) or not (UDP). + * + */ + virtual std::shared_ptr<message> create_request( + bool _reliable = false) const = 0; + + /* + * \brief Constructs an empty response message from a given request + * message. + * + * The message can then be used to call @ref application::send to send a + * SOME/IP message. The message type is set to RESPONSE after the + * call and the request identifier is automatically set from the + * request message. + * + * The user application is responsible for setting the service instance + * and the payload. + * + * \param _request The request message that shall be answered by + * the response message. + * + */ + virtual std::shared_ptr<message> create_response( + const std::shared_ptr<message> &_request) const = 0; + + /** + * + * \brief Creates an empty notification message. + * + * The message can then be used to call @ref application::send to send a + * SOME/IP message. The message type is set to NOTIFICATION after the + * call. + * + * The user application is responsible for setting the service instance + * and the payload. + * + * \param _reliable Determines whether this message shall be sent + * over a reliable connection (TCP) or not (UDP). + * + * Note: Creating notification messages and sending them using + * @ref application::send is possible but not the standard way of sending + * notification with vsomeip. The standard way is calling + * @ref application::offer_event and setting the value using the + * @ref application::notify / @ref application::notify_one methods. + * + */ + virtual std::shared_ptr<message> create_notification( + bool _reliable = false) const = 0; + + /** + * + * \brief Creates an empty payload object. + * + */ + virtual std::shared_ptr<payload> create_payload() const = 0; + + /** + * + * \brief Creates a payload object filled with the given data. + * + * \param _data Bytes to be copied into the payload object. + * \param _size Number of bytes to be copied into the payload object. + * + */ + virtual std::shared_ptr<payload> create_payload( + const byte_t *_data, uint32_t _size) const = 0; + + /** + * + * \brief Creates a payload object filled with the given data. + * + * \param _data Bytes to be copied into the payload object. + * + */ + virtual std::shared_ptr<payload> create_payload( + const std::vector<byte_t> &_data) const = 0; + + /** + * + * \brief Retrieves the application object for the application with the + * given name. + * + * If no such application is found, an empty shared_ptr is returned + * (nullptr). + * + * \param _name Name of the application to be found. + * + */ + virtual std::shared_ptr<application> get_application( + const std::string &_name) const = 0; + + /** + * + * \brief Removes the application object for the application with the + * given name. + * + * If no such application is found, this is a null operation. + * + * \param _name Name of the application to be removed. + * + */ + virtual void remove_application( const std::string &_name) = 0; +}; + +/** @} */ + +} // namespace vsomeip + +#endif // VSOMEIP_RUNTIME_HPP diff --git a/interface/compat/vsomeip/trace.hpp b/interface/compat/vsomeip/trace.hpp new file mode 100644 index 0000000..ebdd418 --- /dev/null +++ b/interface/compat/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 "../../compat/vsomeip/constants.hpp" +#include "../../compat/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/compat/vsomeip/vsomeip.hpp b/interface/compat/vsomeip/vsomeip.hpp new file mode 100644 index 0000000..101e136 --- /dev/null +++ b/interface/compat/vsomeip/vsomeip.hpp @@ -0,0 +1,21 @@ +// 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_VSOMEIP_HPP +#define VSOMEIP_VSOMEIP_HPP + +/** + * \brief The central vsomeip header. Include this to use vsomeip. + */ + +#include "../../compat/vsomeip/application.hpp" +#include "../../compat/vsomeip/constants.hpp" +#include "../../compat/vsomeip/defines.hpp" +#include "../../compat/vsomeip/message.hpp" +#include "../../compat/vsomeip/payload.hpp" +#include "../../compat/vsomeip/runtime.hpp" +#include "../../compat/vsomeip/trace.hpp" + +#endif // VSOMEIP_VSOMEIP_HPP diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp index a1296e8..a67368f 100644 --- a/interface/vsomeip/application.hpp +++ b/interface/vsomeip/application.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_APPLICATION_HPP -#define VSOMEIP_APPLICATION_HPP +#ifndef VSOMEIP_V3_APPLICATION_HPP_ +#define VSOMEIP_V3_APPLICATION_HPP_ #include <chrono> #include <memory> @@ -18,9 +18,9 @@ #include <vsomeip/constants.hpp> #include <vsomeip/handler.hpp> -namespace vsomeip { +namespace vsomeip_v3 { -class configuration; +class configuration_public; class event; class payload; struct policy; @@ -81,14 +81,11 @@ public: virtual client_t get_client() const = 0; /** + * \brief Get the diagnosis address * - * \brief Does nothing. - * - * This method exists for compatibility reasons only. It is a null - * operation and will be removed with the next major vsomeip version. - * + * \return diagnosis address */ - virtual void set_configuration(const std::shared_ptr<configuration> _configuration) = 0; + virtual diagnosis_t get_diagnosis() const = 0; /** * @@ -120,7 +117,6 @@ public: virtual void start() = 0; /** - * * \brief Stops message processing. * * This method stops message processing. Thus, @ref start will return @@ -130,6 +126,26 @@ public: virtual void stop() = 0; /** + * \brief Process messages / events. + * + * This methods controls the message / event processing from an application + * context. You must not call start / stop if you use this method. + * + * \param _number Number of events/messages that will be processed at + * maximum before returning. + * + */ + virtual void process(int _number = VSOMEIP_ALL) = 0; + + /** + * + * \brief Get the security mode of the application + * + * \return security mode + */ + virtual security_mode_e get_security_mode() const = 0; + + /** * * \brief Offers a SOME/IP service instance. * @@ -181,16 +197,33 @@ public: * event. * \param _instance Instance identifier of the interface containing the * event. - * \param _event Event identifier of the offered event. + * \param _notifier Identifier of the notifier for the offered event. * \param _eventgroups List of eventgroup identifiers of the eventgroups * that contain the event. - * \param _is_field Selector for event or field. - * - */ - virtual void offer_event(service_t _service, - instance_t _instance, event_t _event, - const std::set<eventgroup_t> &_eventgroups, - bool _is_field) = 0; + * \param _type Pure event, selective event or field. + * \param _cycle Cycle time for periodic events + * \param _change_resets_cycle Set to true if a change of the event + * payload shall reset the cycle time for periodically sent events + * \param _update_on_change Set to false if a change of the event should not + * trigger a notification + * \param _epsilon_change_func Function to determine whether two event + * payloads are considered different + * \param _reliability Either RT_UNRELIABLE or RT_RELIABLE. All events + * of the same eventgroup are required to be offered with the same + * reliability. If set to RT_BOTH remote subscriptions are required to + * contain a reliable and unreliable endpoint option to be accepted. + * If set to RT_UNKNOWN the event reliability is determined by the service + * instance's reliability configuration. This parameter has no effect for + * events of local services. + */ + virtual void offer_event(service_t _service, instance_t _instance, + event_t _notifier, const std::set<eventgroup_t> &_eventgroups, + event_type_e _type = event_type_e::ET_EVENT, + std::chrono::milliseconds _cycle =std::chrono::milliseconds::zero(), + bool _change_resets_cycle = false, + bool _update_on_change = true, + const epsilon_change_func_t &_epsilon_change_func = nullptr, + reliability_type_e _reliability = reliability_type_e::RT_UNKNOWN) = 0; /** * @@ -228,8 +261,7 @@ public: */ virtual void request_service(service_t _service, instance_t _instance, major_version_t _major = ANY_MAJOR, - minor_version_t _minor = ANY_MINOR, - bool _use_exclusive_proxy = false) = 0; + minor_version_t _minor = ANY_MINOR) = 0; /** * @@ -264,12 +296,25 @@ public: * \param _event Event identifier of the event. * \param _eventgroups List of Eventgroup identifiers of the eventgroups * that contain the event. - * \param _is_field Pure event (false) or field (true). - * + * \param _type Pure event, selective event or field. + * \param _reliability Either RT_UNRELIABLE or RT_RELIABLE. All events + * of the same eventgroup are required to be requested with the same + * reliability. If set to RT_BOTH remote subscriptions are only done if + * the remote service is offered with an unreliable and reliable endpoint + * option. If set to RT_UNKNOWN the event reliability is determined by the + * service instance's reliability configuration. This parameter has no + * effect for events of local services + * + * Note: If a vsomeip application registers to an event or field and other + * vsomeip application shall be enabled to use events/fields from the same + * eventgroup, the application must register all events and fields that + * belong to the eventgroup. Otherwise, neither event type nor reliability + * type are known which might result in missing events. */ virtual void request_event(service_t _service, instance_t _instance, event_t _event, const std::set<eventgroup_t> &_eventgroups, - bool _is_field) = 0; + event_type_e _type = event_type_e::ET_EVENT, + reliability_type_e _reliability = reliability_type_e::RT_UNKNOWN) = 0; /** * * \brief Unregister the application as user of an event or field. @@ -308,13 +353,11 @@ public: * eventgroup. * \param _eventgroup Eventgroup identifier of the eventgroup. * \param _major Major version number of the service. - * \param _subscription_type Specifies how the events shall be received. * \param _event All (Default) or a specific event. * */ virtual void subscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major = DEFAULT_MAJOR, - subscription_type_e _subscription_type = subscription_type_e::SU_RELIABLE_AND_UNRELIABLE, event_t _event = ANY_EVENT) = 0; /** @@ -347,7 +390,15 @@ public: * */ virtual bool is_available(service_t _service, instance_t _instance, - major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) const = 0; + major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; + + typedef std::map<service_t, + std::map<instance_t, + std::map<major_version_t, minor_version_t >>> available_t; + + virtual bool are_available(available_t &_available, + service_t _service = ANY_SERVICE, instance_t _instance = ANY_INSTANCE, + major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; /** * @@ -359,11 +410,9 @@ public: * identifier. * * \param _message Message object. - * \param _flush If set to true, the message is immediately sent. Otherwise - * the message might be deferred and sent together with other messages. * */ - virtual void send(std::shared_ptr<message> _message, bool _flush = true) = 0; + virtual void send(std::shared_ptr<message> _message) = 0; /** * @@ -386,7 +435,8 @@ public: * */ virtual void notify(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload) const = 0; + event_t _event, std::shared_ptr<payload> _payload, + bool _force = false) const = 0; /** * @@ -410,8 +460,8 @@ public: * */ virtual void notify_one(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload, - client_t _client) const = 0; + event_t _event, std::shared_ptr<payload> _payload, client_t _client, + bool _force = false) const = 0; /** * @@ -510,7 +560,7 @@ public: */ virtual void register_availability_handler(service_t _service, instance_t _instance, availability_handler_t _handler, - major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; + major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) = 0; /** * @@ -528,7 +578,7 @@ public: */ virtual void unregister_availability_handler(service_t _service, instance_t _instance, - major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; + major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) = 0; /** * @@ -545,7 +595,8 @@ public: * subscription state is to be monitored. * \param _eventgroup Eventgroup identifier of eventgroup whose * subscription state is to be monitored. - * \param _handler Callback that shall be called. + * \param _handler Callback that shall be called. The value returned by this + * handler decides if the subscription is accepted or not. * */ virtual void register_subscription_handler(service_t _service, @@ -553,6 +604,32 @@ public: subscription_handler_t _handler) = 0; /** + * + * \brief Registers an async subscription handler. + * + * A subscription handler is called whenever the subscription state of an + * eventgroup changes. The callback is called with the client identifier + * and a boolean that indicates whether the client subscribed or + * unsubscribed. + * This method offers the possibility to asynchronously accept/rejects + * subscriptions through a callback. + * + * \param _service Service identifier of service instance whose + * subscription state is to be monitored. + * \param _instance Instance identifier of service instance whose + * subscription state is to be monitored. + * \param _eventgroup Eventgroup identifier of eventgroup whose + * subscription state is to be monitored. + * \param _handler Callback that shall be called. The value passed to the + * callback passed as a parameter to this handler decides if the + * subscription is accepted or not. + * + */ + virtual void register_async_subscription_handler( + service_t _service, instance_t _instance, eventgroup_t _eventgroup, + async_subscription_handler_t _handler) = 0; + + /** * * \brief Unregister a subscription handler. * @@ -567,43 +644,6 @@ public: virtual void unregister_subscription_handler(service_t _service, instance_t _instance, eventgroup_t _eventgroup) = 0; - // [Un]Register handler for subscription errors - /** - * - * \brief Allows for the registration of a subscription error handler. - * - * This handler is called whenever a subscription request for an eventgroup - * was either accepted or rejected. The respective callback is called with - * ether OK (0x00) or REJECTED (0x07). - * - * \param _service Service identifier of service instance whose - * subscription error state is to be monitored. - * \param _instance Instance identifier of service instance whose - * subscription error state is to be monitored. - * \param _eventgroup Eventgroup identifier of eventgroup whose - * subscription error state is to be monitored. - * \param _handler Callback that shall be called. - * - */ - virtual void register_subscription_error_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, - error_handler_t _handler) = 0; - - /** - * - * \brief Removes a registered subscription error callback. - * - * \param _service Service identifier of service instance whose - * error callback shall be removed. - * \param _instance Instance identifier of service instance whose - * error callback shall be removed. - * \param _eventgroup Eventgroup identifier of eventgroup whose - * error callback shall be removed. - * - */ - virtual void unregister_subscription_error_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) = 0; - /** * * \brief Unregister all registered handlers. @@ -626,197 +666,6 @@ public: virtual bool is_routing() const = 0; /** - * - * \brief Offers a SOME/IP event or field. - * - * A user application must call this method for each event/field it wants - * to offer. The event is registered at the vsomeip routing component that - * enables other applications to subscribe to the event/field as well as - * to get and set the field value. - * - * This version of offer_event adds some additional functionalities: - * - It is possible to configure a cycle time. The notification message of - * this event is then resent cyclically. - * - The parameter _change_resets_cycle is available to control how event - * notification works in case the data is updated by the application. If - * set to true, an update of the data immediately leads to a - * notification. Otherwise, the updated data is sent only after the - * expiration of the cycle time. - * - It is possible to specify callback function that can be used to - * implement a predicate that determines whether or not two event values - * are considered different. Field notifications are only sent if the - * predicate evaluates to true (or if a notify method is called with the - * force flag being set). - * - * \param _service Service identifier of the interface containing the - * event. - * \param _instance Instance identifier of the interface containing the - * event. - * \param _event Event identifier of the offered event. - * \param _eventgroups List of eventgroup identifiers of the eventgroups - * that contain the event. - * \param _is_field Selector for event or field. - * \param _cycle Sets the cycle time of the event. If nonzero, data is - * resent cyclically after the cycle time expired. - * \param _change_resets_cycle Tells if a change immediately leads to - * a notification. - * \param _epsilon_change_func Predicate that determines if two given - * payloads are considered different. - * - * Note: The different versions of offer_event exist for compatibility - * reasons. They will be merged with the next major vsomeip version. - */ - virtual void offer_event(service_t _service, - instance_t _instance, event_t _event, - const std::set<eventgroup_t> &_eventgroups, - bool _is_field, - std::chrono::milliseconds _cycle, - bool _change_resets_cycle, - const epsilon_change_func_t &_epsilon_change_func) = 0; - - /** - * - * \brief Fire an event or field notification. - * - * The specified event is updated with the specified payload data. - * Dependent on the type of the event, the payload is distributed to all - * notified clients (always for events, only if the payload has changed - * for fields). - * - * Note: Prior to using this method, @ref offer_event has to be called by - * the service provider. - * - * \param _service Service identifier of the service that contains the - * event. - * \param _instance Instance identifier of the service instance that - * holds the event. - * \param _event Event identifier of the event. - * \param _payload Serialized payload of the event. - * \param _force Forces the notification to be sent (even if the event - * is a field and the value did not change). - * - * Note: The different versions of notify do exist for compatibility - * reasons. They will be merged with the next major vsomeip release. - */ - virtual void notify(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload, - bool _force) const = 0; - - /** - * - * \brief Fire an event or field notification. - * - * The specified event is updated with the specified payload data. - * Dependent on the type of the event, the payload is distributed to all - * notified clients (always for events, only if the payload has changed - * for fields). - * - * Note: Prior to using this method, @ref offer_event has to be called by - * the service provider. - * - * \param _service Service identifier of the service that contains the - * event. - * \param _instance Instance identifier of the service instance that - * holds the event. - * \param _event Event identifier of the event. - * \param _payload Serialized payload of the event. - * \param _client Target client. - * \param _force Forces the notification to be sent (even if the event - * is a field and the value did not change). - * - * Note: The different versions of notify_one do exist for compatibility - * reasons. They will be merged with the next major vsomeip release. - */ - virtual void notify_one(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload, - client_t _client, bool _force) const = 0; - - typedef std::map<service_t, std::map<instance_t, std::map<major_version_t, minor_version_t >>> available_t; - /** - * \brief Returns all available instances that match the given combination - * of service, instance and version. - * - * This method checks the availability of the service instances that - * match the specified combination of service, instance and version - * parameters. If at least one matching service instance is available, - * the method returns true, otherwise it returns false. All available - * service instances are returned to the caller by filling the - * _available parameter. - * - * \param _available Map that is filled with the available instances. - * \param _service Service identifier that specifies which service(s) - * are checked. - * \param _instance Instance identifier that specifies which instance(s) - * are checked. - * \param _major_version Major version(s) of the service instances that - * are checked - * \param _minor_version Minor version(s) of the service instance that - * are checked - */ - virtual bool are_available(available_t &_available, - service_t _service = ANY_SERVICE, instance_t _instance = ANY_INSTANCE, - major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; - - /** - * - * \brief Fire an event or field notification. - * - * The specified event is updated with the specified payload data. - * Dependent on the type of the event, the payload is distributed to all - * notified clients (always for events, only if the payload has changed - * for fields). - * - * Note: Prior to using this method, @ref offer_event has to be called by - * the service provider. - * - * \param _service Service identifier of the service that contains the - * event. - * \param _instance Instance identifier of the service instance that - * holds the event. - * \param _event Event identifier of the event. - * \param _payload Serialized payload of the event. - * \param _force Forces the notification to be sent (even if the event - * is a field and the value did not change). - * \param _flush Must be set to ensure the event is immediately fired. - * - * Note: The different versions of notify do exist for compatibility - * reasons. They will be merged with the next major vsomeip release. - */ - virtual void notify(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload, - bool _force, bool _flush) const = 0; - - /** - * - * \brief Fire an event or field notification. - * - * The specified event is updated with the specified payload data. - * Dependent on the type of the event, the payload is distributed to all - * notified clients (always for events, only if the payload has changed - * for fields). - * - * Note: Prior to using this method, @ref offer_event has to be called by - * the service provider. - * - * \param _service Service identifier of the service that contains the - * event. - * \param _instance Instance identifier of the service instance that - * holds the event. - * \param _event Event identifier of the event. - * \param _payload Serialized payload of the event. - * \param _client Target client. - * \param _force Forces the notification to be sent (even if the event - * is a field and the value did not change). - * \param _flush Must be set to ensure the event is immediately fired. - * - * Note: The different versions of notify_one do exist for compatibility - * reasons. They will be merged with the next major vsomeip release. - */ - virtual void notify_one(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload, - client_t _client, bool _force, bool _flush) const = 0; - - /** * \brief Set the current routing state. * * The routing state impacts the behavior of the SOME/IP Service Discovery component. It @@ -842,7 +691,6 @@ public: virtual void unsubscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0; - /** * * \brief Registers a subscription status listener. @@ -850,8 +698,9 @@ public: * When registered such a handler it will be called for * every application::subscribe call. * - * This method is intended to replace the application:: - * register_subscription_error_handler call in future releases. + * The handler is called whenever a subscription request for an eventgroup + * and/or event was either accepted or rejected. The respective callback is + * called with either OK (0x00) or REJECTED (0x07). * * \param _service Service identifier of the service that is subscribed to. * \param _instance Instance identifier of the service that is subscribed to. @@ -859,33 +708,28 @@ public: * \param _event Event indentifier of the event is subscribed to. * \param _handler A subscription status handler which will be called by vSomeIP * as a follow of application::subscribe. + * \param _is_selective Flag to enable calling the provided handler if the + * subscription is answered with a SUBSCRIBE_NACK. */ virtual void register_subscription_status_handler(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - subscription_status_handler_t _handler) = 0; + subscription_status_handler_t _handler, bool _is_selective = false) = 0; /** * - * \brief Registers a subscription status listener. - * - * When registered such a handler it will be called for - * every application::subscribe call. - * - * This method is intended to replace the application:: - * register_subscription_error_handler call in future releases. + * \brief Unregisters a subscription status listener. * - * \param _service Service identifier of the service that is subscribed to. - * \param _instance Instance identifier of the service that is subscribed to. - * \param _eventgroup Eventgroup identifier of the eventgroup is subscribed to. - * \param _event Event indentifier of the event is subscribed to. - * \param _handler A subscription status handler which will be called by vSomeIP - * as a follow of application::subscribe. - * \param _is_selective Flag to enable calling the provided handler if the - * subscription is answered with a SUBSCRIBE_NACK. + * \param _service Service identifier of the service for which the handler + * should be removed. + * \param _instance Instance identifier of the service for which the handler + * should be removed + * \param _eventgroup Eventgroup identifier of the eventgroup for which the + * should be removed + * \param _event Event identifier of the event for which the handler should + * be removed. */ - virtual void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, - subscription_status_handler_t _handler, bool _is_selective) = 0; + virtual void unregister_subscription_status_handler(service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0; /** * @@ -915,7 +759,7 @@ public: * or scheduling effects, thus it may underrun or overrun by small * amount. * - * \note Only one handler can be active at the time, thus last handler set + * \note Only one handler can be active at a time, thus last handler set * by calling this function will be invoked. * * \note To disable calling an active handler, invoke this method again, @@ -927,67 +771,60 @@ public: */ virtual void set_watchdog_handler(watchdog_handler_t _handler, std::chrono::seconds _interval) = 0; - /** - * - * \brief Registers a subscription handler. - * - * A subscription handler is called whenever the subscription state of an - * eventgroup changes. The callback is called with the client identifier - * and a boolean that indicates whether the client subscribed or - * unsubscribed. + /** + * \brief Enables or disables calling of registered acceptance + * handlers for given remote info * - * \param _service Service identifier of service instance whose - * subscription state is to be monitored. - * \param _instance Instance identifier of service instance whose - * subscription state is to be monitored. - * \param _eventgroup Eventgroup identifier of eventgroup whose - * subscription state is to be monitored. - * \param _handler Callback that shall be called. + * This method has only an effect when called on the application acting as + * routing manager * + * \param _remote IP and port for which SD 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 register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - async_subscription_handler_t _handler) = 0; + virtual void set_sd_acceptance_required(const remote_info_t& _remote, + const std::string& _path, + bool _enable) = 0; /** - * \brief Enables or disables calling of registered offer acceptance - * handler for given IP address + * \brief Enables or disables calling of registered acceptance + * handlers for given remote info * * 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 + * \param _remotes remote infos for which SD 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; + typedef std::map<remote_info_t, std::string> sd_acceptance_map_type_t; + virtual void set_sd_acceptance_required( + const sd_acceptance_map_type_t& _remotes, bool _enable) = 0; /** - * \brief Returns all configured IP addresses which require calling of - * registered offer acceptance handler + * \brief Returns all configured remote info which require calling of + * registered service discovery (SD) 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 + * \return map with known remotes requiring SD 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; + virtual sd_acceptance_map_type_t get_sd_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 + * a remote SD message with the sending ECU's IP address and port 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; + virtual void register_sd_acceptance_handler(sd_acceptance_handler_t _handler) = 0; /** * \brief Registers a handler which will be called upon detection of a @@ -1088,6 +925,6 @@ public: /** @} */ -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_APPLICATION_HPP +#endif // VSOMEIP_V3_APPLICATION_HPP_ diff --git a/interface/vsomeip/constants.hpp b/interface/vsomeip/constants.hpp index 9dc33f0..e46e0e7 100644 --- a/interface/vsomeip/constants.hpp +++ b/interface/vsomeip/constants.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_CONSTANTS_HPP -#define VSOMEIP_CONSTANTS_HPP +#ifndef VSOMEIP_V3_CONSTANTS_HPP_ +#define VSOMEIP_V3_CONSTANTS_HPP_ #include <string> #include <vsomeip/primitive_types.hpp> #include <vsomeip/enumeration_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { const major_version_t DEFAULT_MAJOR = 0x00; const minor_version_t DEFAULT_MINOR = 0x00000000; @@ -20,6 +20,7 @@ const ttl_t DEFAULT_TTL = 0xFFFFFF; // "until next reboot" const std::string DEFAULT_MULTICAST = "224.0.0.0"; const uint16_t DEFAULT_PORT = 30500; const uint16_t ILLEGAL_PORT = 0xFFFF; +const uint16_t ANY_PORT = 0; const uint16_t NO_TRACE_FILTER_EXPRESSION = 0x0000; @@ -32,12 +33,13 @@ const minor_version_t ANY_MINOR = 0xFFFFFFFF; const eventgroup_t DEFAULT_EVENTGROUP = 0x0001; const client_t ILLEGAL_CLIENT = 0x0000; +const method_t INVALID_METHOD = 0x0000; 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 client_t MAGIC_COOKIE_CLIENT = 0xDEAD; 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,9 +57,10 @@ const byte_t SERVICE_COOKIE[] = { 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, const event_t ANY_EVENT = 0xFFFF; const client_t ANY_CLIENT = 0xFFFF; -const pending_subscription_id_t DEFAULT_SUBSCRIPTION = 0x0; +const int VSOMEIP_ALL = -1; + const pending_security_update_id_t DEFAULT_SECURITY_UPDATE_ID = 0x0; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CONSTANTS_HPP +#endif // VSOMEIP_V3_CONSTANTS_HPP_ diff --git a/interface/vsomeip/defines.hpp b/interface/vsomeip/defines.hpp index 0442fae..e10c453 100644 --- a/interface/vsomeip/defines.hpp +++ b/interface/vsomeip/defines.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_DEFINES_HPP -#define VSOMEIP_DEFINES_HPP +#ifndef VSOMEIP_V3_DEFINES_HPP_ +#define VSOMEIP_V3_DEFINES_HPP_ #define VSOMEIP_PROTOCOL_VERSION 0x1 @@ -38,4 +38,4 @@ #define VSOMEIP_RETURN_CODE_POS 15 #define VSOMEIP_PAYLOAD_POS 16 -#endif // VSOMEIP_DEFINES_HPP +#endif // VSOMEIP_V3_DEFINES_HPP_ diff --git a/interface/vsomeip/enumeration_types.hpp b/interface/vsomeip/enumeration_types.hpp index 71ff38a..8f31c0d 100644 --- a/interface/vsomeip/enumeration_types.hpp +++ b/interface/vsomeip/enumeration_types.hpp @@ -3,12 +3,12 @@ // 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_ENUMERATION_TYPES_HPP -#define VSOMEIP_ENUMERATION_TYPES_HPP +#ifndef VSOMEIP_V3_ENUMERATION_TYPES_HPP_ +#define VSOMEIP_V3_ENUMERATION_TYPES_HPP_ #include <cstdint> -namespace vsomeip { +namespace vsomeip_v3 { enum class state_type_e : uint8_t { ST_REGISTERED = 0x0, @@ -46,14 +46,6 @@ enum class return_code_e : uint8_t { E_UNKNOWN = 0xFF }; -enum class subscription_type_e : uint8_t { - SU_RELIABLE_AND_UNRELIABLE = 0x00, - SU_PREFER_UNRELIABLE = 0x01, - SU_PREFER_RELIABLE = 0x02, - SU_UNRELIABLE = 0x03, - SU_RELIABLE = 0x04, -}; - enum class routing_state_e : uint8_t { RS_RUNNING = 0x00, RS_SUSPENDED = 0x01, @@ -69,6 +61,19 @@ enum class offer_type_e : uint8_t { OT_ALL = 0x02, }; +enum class event_type_e : uint8_t { + ET_EVENT = 0x00, + ET_SELECTIVE_EVENT = 0x01, + ET_FIELD = 0x02, + ET_UNKNOWN = 0xFF +}; + +enum class security_mode_e : uint8_t { + SM_OFF = 0x00, + SM_ON = 0x01, + SM_AUDIT = 0x02 +}; + enum class security_update_state_e : uint8_t { SU_SUCCESS = 0x00, SU_NOT_ALLOWED = 0x01, @@ -76,6 +81,13 @@ enum class security_update_state_e : uint8_t { SU_INVALID_FORMAT = 0x03 }; -} // namespace vsomeip +enum class reliability_type_e : uint8_t { + RT_RELIABLE = 0x01, + RT_UNRELIABLE = 0x02, + RT_BOTH = 0x3, // RT_RELIABLE | RT_UNRELIABLE + RT_UNKNOWN = 0xFF +}; + +} // namespace vsomeip_v3 -#endif // VSOMEIP_ENUMERATION_TYPES_HPP +#endif // VSOMEIP_V3_ENUMERATION_TYPES_HPP_ diff --git a/interface/vsomeip/error.hpp b/interface/vsomeip/error.hpp index 1136957..8415d90 100644 --- a/interface/vsomeip/error.hpp +++ b/interface/vsomeip/error.hpp @@ -3,12 +3,12 @@ // 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_ERROR_HPP -#define VSOMEIP_ERROR_HPP +#ifndef VSOMEIP_V3_ERROR_HPP_ +#define VSOMEIP_V3_ERROR_HPP_ #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { enum class error_code_e : uint8_t { CONFIGURATION_MISSING, @@ -20,7 +20,7 @@ enum class error_code_e : uint8_t { extern const char *ERROR_INFO[]; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_ERROR_HPP +#endif // VSOMEIP_V3_ERROR_HPP_ diff --git a/interface/vsomeip/export.hpp b/interface/vsomeip/export.hpp index a8577ee..5f460eb 100644 --- a/interface/vsomeip/export.hpp +++ b/interface/vsomeip/export.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 __EXPORT__HPP__ -#define __EXPORT__HPP__ +#ifndef VSOMEIP_V3_EXPORT_HPP_ +#define VSOMEIP_V3_EXPORT_HPP_ #if _WIN32 #define VSOMEIP_EXPORT __declspec(dllexport) @@ -27,4 +27,4 @@ #define VSOMEIP_IMPORT_EXPORT_CONFIG #endif -#endif +#endif // VSOMEIP_V3_EXPORT_HPP_ diff --git a/interface/vsomeip/function_types.hpp b/interface/vsomeip/function_types.hpp index aa086dd..31ef9d5 100644 --- a/interface/vsomeip/function_types.hpp +++ b/interface/vsomeip/function_types.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_FUNCTION_TYPES_HPP -#define VSOMEIP_FUNCTION_TYPES_HPP +#ifndef VSOMEIP_V3_FUNCTION_TYPES_HPP_ +#define VSOMEIP_V3_FUNCTION_TYPES_HPP_ #include <functional> #include <memory> -namespace vsomeip { +namespace vsomeip_v3 { class payload; @@ -17,6 +17,6 @@ typedef std::function< bool (const std::shared_ptr<payload> &, const std::shared_ptr<payload> &) > epsilon_change_func_t; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_FUNCTION_TYPES_HPP +#endif // VSOMEIP_V3_FUNCTION_TYPES_HPP_ diff --git a/interface/vsomeip/handler.hpp b/interface/vsomeip/handler.hpp index 2fa57a8..2700567 100644 --- a/interface/vsomeip/handler.hpp +++ b/interface/vsomeip/handler.hpp @@ -3,26 +3,27 @@ // 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_HANDLER_HPP -#define VSOMEIP_HANDLER_HPP +#ifndef VSOMEIP_V3_HANDLER_HPP_ +#define VSOMEIP_V3_HANDLER_HPP_ #include <functional> #include <memory> +#include <tuple> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class message; typedef std::function< void (state_type_e) > state_handler_t; typedef std::function< void (const std::shared_ptr< message > &) > message_handler_t; typedef std::function< void (service_t, instance_t, bool) > availability_handler_t; -typedef std::function< bool (client_t, bool) > subscription_handler_t; +typedef std::function< bool (client_t, uid_t, gid_t, bool) > subscription_handler_t; typedef std::function< void (const uint16_t) > error_handler_t; typedef std::function< void (const service_t, const instance_t, const eventgroup_t, const event_t, const uint16_t) > subscription_status_handler_t; -typedef std::function< void (client_t, bool, std::function< void (const bool) > )> async_subscription_handler_t; +typedef std::function< void (client_t, uid_t, gid_t, bool, std::function< void (const bool) > )> async_subscription_handler_t; 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; @@ -61,12 +62,27 @@ struct ip_address_t { } }; -typedef std::function<bool(const ip_address_t&)> offer_acceptance_handler_t; + +struct remote_info_t { + ip_address_t ip_; + std::uint16_t port_; + std::uint16_t first_; + std::uint16_t last_; + bool is_range_; + + bool operator<(const remote_info_t& _other) const { + return std::tie(ip_, port_, first_, last_, is_range_) < + std::tie(_other.ip_, _other.port_, _other.first_, _other.last_, + _other.is_range_); + } +}; + +typedef std::function<bool(const remote_info_t&)> sd_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 +} // namespace vsomeip_v3 -#endif // VSOMEIP_HANDLER_HPP +#endif // VSOMEIP_V3_HANDLER_HPP_ diff --git a/interface/vsomeip/internal/deserializable.hpp b/interface/vsomeip/internal/deserializable.hpp index 5d8ebcc..ae661e5 100644 --- a/interface/vsomeip/internal/deserializable.hpp +++ b/interface/vsomeip/internal/deserializable.hpp @@ -1,24 +1,24 @@ -// 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_DESERIALIZABLE_HPP
-#define VSOMEIP_DESERIALIZABLE_HPP
-
-#include <vsomeip/export.hpp>
-
-namespace vsomeip {
-
-class deserializer;
-
-class deserializable {
-public:
- VSOMEIP_EXPORT virtual ~deserializable() {
- }
- VSOMEIP_EXPORT virtual bool deserialize(deserializer *_from) = 0;
-};
-
-} // namespace vsomeip
-
-#endif // VSOMEIP_SERIALIZABLE_HPP
+// 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_DESERIALIZABLE_HPP_ +#define VSOMEIP_V3_DESERIALIZABLE_HPP_ + +#include <vsomeip/export.hpp> + +namespace vsomeip_v3 { + +class deserializer; + +class deserializable { +public: + VSOMEIP_EXPORT virtual ~deserializable() { + } + VSOMEIP_EXPORT virtual bool deserialize(deserializer *_from) = 0; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SERIALIZABLE_HPP_ diff --git a/interface/vsomeip/internal/logger.hpp b/interface/vsomeip/internal/logger.hpp new file mode 100644 index 0000000..bbf8e65 --- /dev/null +++ b/interface/vsomeip/internal/logger.hpp @@ -0,0 +1,51 @@ +// 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_LOGGER_HPP_ +#define VSOMEIP_V3_LOGGER_HPP_ + +#include <string> + +#ifdef _WIN32 +#include <iostream> +#endif + +#include <vsomeip/export.hpp> + +#include <boost/log/sources/severity_logger.hpp> +#include <boost/log/trivial.hpp> + +namespace vsomeip_v3 { + +class VSOMEIP_IMPORT_EXPORT logger { +public: + static std::shared_ptr<logger> get(); + + virtual ~logger() { + } + + virtual boost::log::sources::severity_logger_mt< + boost::log::trivial::severity_level> & get_internal() = 0; +}; + +#define VSOMEIP_LOG_DEFAULT_APPLICATION_ID "VSIP" +#define VSOMEIP_LOG_DEFAULT_APPLICATION_NAME "vSomeIP application|SysInfra|IPC" + +#define VSOMEIP_FATAL BOOST_LOG_SEV(vsomeip_v3::logger::get()->get_internal(), \ + boost::log::trivial::severity_level::fatal) +#define VSOMEIP_ERROR BOOST_LOG_SEV(vsomeip_v3::logger::get()->get_internal(), \ + boost::log::trivial::severity_level::error) +#define VSOMEIP_WARNING BOOST_LOG_SEV(vsomeip_v3::logger::get()->get_internal(), \ + boost::log::trivial::severity_level::warning) +#define VSOMEIP_INFO BOOST_LOG_SEV(vsomeip_v3::logger::get()->get_internal(), \ + boost::log::trivial::severity_level::info) +#define VSOMEIP_DEBUG BOOST_LOG_SEV(vsomeip_v3::logger::get()->get_internal(), \ + boost::log::trivial::severity_level::debug) +#define VSOMEIP_TRACE BOOST_LOG_SEV(vsomeip_v3::logger::get()->get_internal(), \ + boost::log::trivial::severity_level::trace) + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_LOGGER_HPP_ diff --git a/interface/vsomeip/internal/policy_manager.hpp b/interface/vsomeip/internal/policy_manager.hpp new file mode 100644 index 0000000..45756ec --- /dev/null +++ b/interface/vsomeip/internal/policy_manager.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2019 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_POLICY_MANAGER_HPP_ +#define VSOMEIP_V3_POLICY_MANAGER_HPP_ + +#include <memory> + +#include <vsomeip/primitive_types.hpp> + +namespace vsomeip_v3 { + +struct policy; + +class policy_manager { +public: + static std::shared_ptr<policy_manager> get(); + + virtual ~policy_manager() {}; + + virtual std::shared_ptr<policy> create_policy() const = 0; + virtual void print_policy(const std::shared_ptr<policy> &_policy) const = 0; + + virtual bool parse_uid_gid(const byte_t* &_buffer, uint32_t &_buffer_size, + uint32_t &_uid, uint32_t &_gid) const = 0; + virtual bool parse_policy(const byte_t* &_buffer, uint32_t &_buffer_size, + uint32_t &_uid, uint32_t &_gid, + const std::shared_ptr<policy> &_policy) const = 0; + + virtual bool is_policy_update_allowed(uint32_t _uid, std::shared_ptr<policy> &_policy) const = 0; + virtual bool is_policy_removal_allowed(uint32_t _uid) const = 0; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_POLICY_MANAGER_HPP_ diff --git a/interface/vsomeip/internal/serializable.hpp b/interface/vsomeip/internal/serializable.hpp index 0791419..52540b8 100644 --- a/interface/vsomeip/internal/serializable.hpp +++ b/interface/vsomeip/internal/serializable.hpp @@ -1,30 +1,30 @@ -// 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_SERIALIZABLE_HPP
-#define VSOMEIP_SERIALIZABLE_HPP
-
-#include <vsomeip/export.hpp>
-
-namespace vsomeip {
-
-class serializer;
-
-/**
- * Abstract base class for element that can be serialized.
- */
-class serializable {
-public:
- VSOMEIP_EXPORT virtual ~serializable() {}
-
- /**
- * \brief serialize the content of the object
- */
- VSOMEIP_EXPORT virtual bool serialize(serializer *_to) const = 0;
-};
-
-} // namespace vsomeip
-
-#endif // VSOMEIP_SERIALIZABLE_HPP
+// 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_SERIALIZABLE_HPP_ +#define VSOMEIP_V3_SERIALIZABLE_HPP_ + +#include <vsomeip/export.hpp> + +namespace vsomeip_v3 { + +class serializer; + +/** + * Abstract base class for element that can be serialized. + */ +class serializable { +public: + VSOMEIP_EXPORT virtual ~serializable() {} + + /** + * \brief serialize the content of the object + */ + VSOMEIP_EXPORT virtual bool serialize(serializer *_to) const = 0; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SERIALIZABLE_HPP_ diff --git a/interface/vsomeip/message.hpp b/interface/vsomeip/message.hpp index 4a68a54..0d1c5cc 100644 --- a/interface/vsomeip/message.hpp +++ b/interface/vsomeip/message.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_MESSAGE_HPP -#define VSOMEIP_MESSAGE_HPP +#ifndef VSOMEIP_V3_MESSAGE_HPP_ +#define VSOMEIP_V3_MESSAGE_HPP_ #include <memory> #include <vsomeip/message_base.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class payload; @@ -43,10 +43,35 @@ public: * \brief Set the message payload. */ virtual void set_payload(std::shared_ptr<payload> _payload) = 0; + + /** + * \brief Get e2e protection check result. + */ + VSOMEIP_EXPORT virtual uint8_t get_check_result() const = 0; + + /** + * \brief Set e2e protection check result. + */ + VSOMEIP_EXPORT virtual void set_check_result(uint8_t _check_result) = 0; + + /** + * \brief Return whether or not the CRC value received is valid. + */ + VSOMEIP_EXPORT virtual bool is_valid_crc() const = 0; + + /** + * \brief Return uid of the message sender. + */ + VSOMEIP_EXPORT virtual uid_t get_uid() const = 0; + + /** + * \brief Return gid of the message sender. + */ + VSOMEIP_EXPORT virtual gid_t get_gid() const = 0; }; /** @} */ -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_MESSAGE_HPP +#endif // VSOMEIP_V3_MESSAGE_HPP_ diff --git a/interface/vsomeip/message_base.hpp b/interface/vsomeip/message_base.hpp index 60c80e6..b6efa8b 100644 --- a/interface/vsomeip/message_base.hpp +++ b/interface/vsomeip/message_base.hpp @@ -1,212 +1,200 @@ -// 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_MESSAGE_BASE_HPP
-#define VSOMEIP_MESSAGE_BASE_HPP
-
-#include <vsomeip/export.hpp>
-#include <vsomeip/primitive_types.hpp>
-#include <vsomeip/enumeration_types.hpp>
-
-#include <vsomeip/internal/deserializable.hpp>
-#include <vsomeip/internal/serializable.hpp>
-
-namespace vsomeip {
-
-/**
- *
- * \defgroup vsomeip
- *
- * @{
- *
- */
-
-/**
- * \brief Base class to implement SOME/IP messages.
- *
- * This class implements the SOME/IP message header and connects to the
- * serialzing/deserializing functionalities. The class is inherited by
- * the message classes within ::vsomeip and vsomeip::sd that add the
- * payload representations for regular and Service Discovery messages.
- */
-class message_base
- : public serializable,
- public deserializable {
-public:
- VSOMEIP_EXPORT virtual ~message_base() {};
-
- /**
- * \brief Returns the message identifier.
- *
- * The method returns the message identifier that consists of
- * service identifier and method identifier.
- */
- VSOMEIP_EXPORT virtual message_t get_message() const = 0;
- /**
- * \brief Set the message identifier.
- *
- * The methods sets service identifier and method identifier in
- * a single call.
- *
- * \param _message The new message identifier.
- */
- VSOMEIP_EXPORT virtual void set_message(message_t _message) = 0;
-
- /**
- * \brief Returns the service identifier from the message header.
- */
- VSOMEIP_EXPORT virtual service_t get_service() const = 0;
-
- /**
- * \brief Set the service identifier in the message header.
- */
- VSOMEIP_EXPORT virtual void set_service(service_t _service) = 0;
-
- /**
- * \brief Returns the instance identifier.
- *
- * The instance identifier is _not_ part of the SOME/IP header. It is
- * either derived from the incoming message (local) or from the port
- * that was used to send a message (external).
- */
- VSOMEIP_EXPORT virtual instance_t get_instance() const = 0;
-
- /**
- * \brief Set the instance identifier in the message header.
- *
- * To address the correct service instance, vsomeip uses the instance
- * identifier. For external services it is mapped to a IP address and port
- * combination before the message is sent. For internal messages is
- * transferred as additional data appended to the SOME/IP messages.
- * Therefore, before sending a message, a user application must set the
- * instance identifier.
- */
- VSOMEIP_EXPORT virtual void set_instance(instance_t _instance) = 0;
-
- /**
- * \brief Get the method/event identifier from the message header.
- */
- VSOMEIP_EXPORT virtual method_t get_method() const = 0;
-
- /**
- * \brief Set the method/event identifier in the message header.
- */
- VSOMEIP_EXPORT virtual void set_method(method_t _method) = 0;
-
- /**
- * \brief Get the payload length from the message header.
- */
- VSOMEIP_EXPORT virtual length_t get_length() const = 0;
-
- /**
- * \brief Get the request identifier from the message header.
- *
- * The request identifier consists of the client identifier and the
- * session identifier. As it does really make sense to set it as
- * a whole, setting is not supported.
- */
- VSOMEIP_EXPORT virtual request_t get_request() const = 0;
-
- /**
- * \brief Set the client identifier in the message header.
- */
- VSOMEIP_EXPORT virtual client_t get_client() const = 0;
-
- /**
- * \brief Set the client identifier in the message header.
- *
- * For requests this is automatically done by @ref application::send.
- * For notications this is not needed.
- */
- VSOMEIP_EXPORT virtual void set_client(client_t _client) = 0;
-
- /**
- * \brief Get the session identifier from the message header.
- */
- VSOMEIP_EXPORT virtual session_t get_session() const = 0;
-
- /**
- * \brief Set the session identifier in the message header.
- *
- * For requests this is automatically done by @ref application::send
- * For notifications it is not needed to set the session identifier.
- */
- VSOMEIP_EXPORT virtual void set_session(session_t _session) = 0;
-
- /**
- * \brief Get the protocol version from the message header.
- *
- * As the protocol version is a fixed value for a vsomeip implementation,
- * it cannot be set.
- */
- VSOMEIP_EXPORT virtual protocol_version_t get_protocol_version() const = 0;
-
- /**
- * \brief Get the interface version from the message header.
- */
- VSOMEIP_EXPORT virtual interface_version_t get_interface_version() const = 0;
-
- /**
- * \brief Set the interface version in the message header.
- */
- VSOMEIP_EXPORT virtual void set_interface_version(interface_version_t _version) = 0;
-
- /**
- * \brief Get the message type from the message header.
- */
- VSOMEIP_EXPORT virtual message_type_e get_message_type() const = 0;
-
- /**
- * \brief Set the message type in the message header.
- */
- VSOMEIP_EXPORT virtual void set_message_type(message_type_e _type) = 0;
-
- /**
- * \brief Get the return code from the message header.
- */
- VSOMEIP_EXPORT virtual return_code_e get_return_code() const = 0;
-
- /**
- * \brief Set the return code in the message header.
- */
- VSOMEIP_EXPORT virtual void set_return_code(return_code_e _code) = 0;
-
- /**
- * \brief Return the transport mode that was/will be used to send the message.
- */
- VSOMEIP_EXPORT virtual bool is_reliable() const = 0;
-
- /**
- * \brief Set the transport mode that will be used to send the message.
- */
- VSOMEIP_EXPORT virtual void set_reliable(bool _is_reliable) = 0;
-
- /**
- * \brief Return whether or not the message is an initial event.
- */
- VSOMEIP_EXPORT virtual bool is_initial() const = 0;
-
- /**
- * \brief Set whether or not the message is an initial event.
- */
- VSOMEIP_EXPORT virtual void set_initial(bool _is_initial) = 0;
-
- /**
- * \brief Return whether or not the CRC value received is valid.
- */
- VSOMEIP_EXPORT virtual bool is_valid_crc() const = 0;
-
- /**
- * \brief Set whether or not the CRC value received is valid.
- */
- VSOMEIP_EXPORT virtual void set_is_valid_crc(bool _is_valid_crc) = 0;
-
-};
-
-/** @} */
-
-} // namespace vsomeip
-
-#endif // VSOMEIP_MESSAGE_BASE_HPP
+// 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_MESSAGE_BASE_HPP_ +#define VSOMEIP_V3_MESSAGE_BASE_HPP_ + +#include <vsomeip/export.hpp> +#include <vsomeip/primitive_types.hpp> +#include <vsomeip/enumeration_types.hpp> + +#include <vsomeip/internal/deserializable.hpp> +#include <vsomeip/internal/serializable.hpp> + +namespace vsomeip_v3 { + +/** + * + * \defgroup vsomeip + * + * @{ + * + */ + +/** + * \brief Base class to implement SOME/IP messages. + * + * This class implements the SOME/IP message header and connects to the + * serialzing/deserializing functionalities. The class is inherited by + * the message classes within ::vsomeip and vsomeip::sd that add the + * payload representations for regular and Service Discovery messages. + */ +class message_base + : public serializable, + public deserializable { +public: + VSOMEIP_EXPORT virtual ~message_base() {}; + + /** + * \brief Returns the message identifier. + * + * The method returns the message identifier that consists of + * service identifier and method identifier. + */ + VSOMEIP_EXPORT virtual message_t get_message() const = 0; + /** + * \brief Set the message identifier. + * + * The methods sets service identifier and method identifier in + * a single call. + * + * \param _message The new message identifier. + */ + VSOMEIP_EXPORT virtual void set_message(message_t _message) = 0; + + /** + * \brief Returns the service identifier from the message header. + */ + VSOMEIP_EXPORT virtual service_t get_service() const = 0; + + /** + * \brief Set the service identifier in the message header. + */ + VSOMEIP_EXPORT virtual void set_service(service_t _service) = 0; + + /** + * \brief Returns the instance identifier. + * + * The instance identifier is _not_ part of the SOME/IP header. It is + * either derived from the incoming message (local) or from the port + * that was used to send a message (external). + */ + VSOMEIP_EXPORT virtual instance_t get_instance() const = 0; + + /** + * \brief Set the instance identifier in the message header. + * + * To address the correct service instance, vsomeip uses the instance + * identifier. For external services it is mapped to a IP address and port + * combination before the message is sent. For internal messages is + * transferred as additional data appended to the SOME/IP messages. + * Therefore, before sending a message, a user application must set the + * instance identifier. + */ + VSOMEIP_EXPORT virtual void set_instance(instance_t _instance) = 0; + + /** + * \brief Get the method/event identifier from the message header. + */ + VSOMEIP_EXPORT virtual method_t get_method() const = 0; + + /** + * \brief Set the method/event identifier in the message header. + */ + VSOMEIP_EXPORT virtual void set_method(method_t _method) = 0; + + /** + * \brief Get the payload length from the message header. + */ + VSOMEIP_EXPORT virtual length_t get_length() const = 0; + + /** + * \brief Get the request identifier from the message header. + * + * The request identifier consists of the client identifier and the + * session identifier. As it does really make sense to set it as + * a whole, setting is not supported. + */ + VSOMEIP_EXPORT virtual request_t get_request() const = 0; + + /** + * \brief Set the client identifier in the message header. + */ + VSOMEIP_EXPORT virtual client_t get_client() const = 0; + + /** + * \brief Set the client identifier in the message header. + * + * For requests this is automatically done by @ref application::send. + * For notications this is not needed. + */ + VSOMEIP_EXPORT virtual void set_client(client_t _client) = 0; + + /** + * \brief Get the session identifier from the message header. + */ + VSOMEIP_EXPORT virtual session_t get_session() const = 0; + + /** + * \brief Set the session identifier in the message header. + * + * For requests this is automatically done by @ref application::send + * For notifications it is not needed to set the session identifier. + */ + VSOMEIP_EXPORT virtual void set_session(session_t _session) = 0; + + /** + * \brief Get the protocol version from the message header. + * + * As the protocol version is a fixed value for a vsomeip implementation, + * it cannot be set. + */ + VSOMEIP_EXPORT virtual protocol_version_t get_protocol_version() const = 0; + + /** + * \brief Get the interface version from the message header. + */ + VSOMEIP_EXPORT virtual interface_version_t get_interface_version() const = 0; + + /** + * \brief Set the interface version in the message header. + */ + VSOMEIP_EXPORT virtual void set_interface_version(interface_version_t _version) = 0; + + /** + * \brief Get the message type from the message header. + */ + VSOMEIP_EXPORT virtual message_type_e get_message_type() const = 0; + + /** + * \brief Set the message type in the message header. + */ + VSOMEIP_EXPORT virtual void set_message_type(message_type_e _type) = 0; + + /** + * \brief Get the return code from the message header. + */ + VSOMEIP_EXPORT virtual return_code_e get_return_code() const = 0; + + /** + * \brief Set the return code in the message header. + */ + VSOMEIP_EXPORT virtual void set_return_code(return_code_e _code) = 0; + + /** + * \brief Return the transport mode that was/will be used to send the message. + */ + VSOMEIP_EXPORT virtual bool is_reliable() const = 0; + + /** + * \brief Set the transport mode that will be used to send the message. + */ + VSOMEIP_EXPORT virtual void set_reliable(bool _is_reliable) = 0; + + /** + * \brief Return whether or not the message is an initial event. + */ + VSOMEIP_EXPORT virtual bool is_initial() const = 0; + + /** + * \brief Set whether or not the message is an initial event. + */ + VSOMEIP_EXPORT virtual void set_initial(bool _is_initial) = 0; + +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_MESSAGE_BASE_HPP_ diff --git a/interface/vsomeip/payload.hpp b/interface/vsomeip/payload.hpp index b9b8f61..3e7e45a 100644 --- a/interface/vsomeip/payload.hpp +++ b/interface/vsomeip/payload.hpp @@ -1,106 +1,106 @@ -// 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_PAYLOAD_HPP
-#define VSOMEIP_PAYLOAD_HPP
-
-#include <vector>
-
-#include <vsomeip/export.hpp>
-#include <vsomeip/primitive_types.hpp>
-
-#include <vsomeip/internal/deserializable.hpp>
-#include <vsomeip/internal/serializable.hpp>
-
-namespace vsomeip {
-
-/**
- *
- * \defgroup vsomeip
- *
- * @{
- *
- */
-
-/**
- *
- * \brief This class implements an array of bytes to be used as
- * payload for SOME/IP messages.
- *
-*/
-class payload: public serializable, public deserializable {
-public:
- VSOMEIP_EXPORT virtual ~payload() {}
-
- /**
- * \brief Returns true if the given payload is equal to this one.
- *
- * \param _other Payload that shall be compared to this payload.
- */
- VSOMEIP_EXPORT virtual bool operator ==(const payload &_other) = 0;
-
- /**
- * \brief Returns pointer to the payload content
- */
- VSOMEIP_EXPORT virtual byte_t * get_data() = 0;
-
- /**
- * \brief Returns constant pointer to the payload content
- */
- VSOMEIP_EXPORT virtual const byte_t * get_data() const = 0;
-
- /**
- * \brief Copies the given data array to the payload object.
- *
- * The current payload content is replaced by the data provided.
- * The given buffer remains untouched.
- *
- * \param _data Pointer to a data buffer.
- * \param _length Length of the data buffer.
- */
- VSOMEIP_EXPORT virtual void set_data(const byte_t *_data,
- length_t _length) = 0;
-
- /**
- * \brief Copies the given data array to the payload object.
- *
- * The current payload content is replaced by the data provided.
- * The given buffer remains untouched.
- *
- * \param _data Vector containing the data
- */
- VSOMEIP_EXPORT virtual void set_data(
- const std::vector<byte_t> &_data) = 0;
-
- /**
- * \brief Returns the length of the payload content.
- */
- VSOMEIP_EXPORT virtual length_t get_length() const = 0;
-
- /**
- * \brief Set the maximum length of the payload content.
- *
- * This function must be called before directly copying data using the
- * pointer to the internal buffer.
- */
- VSOMEIP_EXPORT virtual void set_capacity(length_t _length) = 0;
-
- /**
- * \brief Moves the given data array to the payload object.
- *
- * The current payload content is replaced by the data provided.
- * The given buffer is owned by the payload object afterwards.
- *
- * \param _data Vector containing the data
- */
- VSOMEIP_EXPORT virtual void set_data(
- std::vector<byte_t> &&_data) = 0;
-};
-
-/** @} */
-
-} // namespace vsomeip
-
-#endif // VSOMEIP_PAYLOAD_HPP
+// 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_PAYLOAD_HPP_ +#define VSOMEIP_V3_PAYLOAD_HPP_ + +#include <vector> + +#include <vsomeip/export.hpp> +#include <vsomeip/primitive_types.hpp> + +#include <vsomeip/internal/deserializable.hpp> +#include <vsomeip/internal/serializable.hpp> + +namespace vsomeip_v3 { + +/** + * + * \defgroup vsomeip + * + * @{ + * + */ + +/** + * + * \brief This class implements an array of bytes to be used as + * payload for SOME/IP messages. + * +*/ +class payload: public serializable, public deserializable { +public: + VSOMEIP_EXPORT virtual ~payload() {} + + /** + * \brief Returns true if the given payload is equal to this one. + * + * \param _other Payload that shall be compared to this payload. + */ + VSOMEIP_EXPORT virtual bool operator ==(const payload &_other) = 0; + + /** + * \brief Returns pointer to the payload content + */ + VSOMEIP_EXPORT virtual byte_t * get_data() = 0; + + /** + * \brief Returns constant pointer to the payload content + */ + VSOMEIP_EXPORT virtual const byte_t * get_data() const = 0; + + /** + * \brief Copies the given data array to the payload object. + * + * The current payload content is replaced by the data provided. + * The given buffer remains untouched. + * + * \param _data Pointer to a data buffer. + * \param _length Length of the data buffer. + */ + VSOMEIP_EXPORT virtual void set_data(const byte_t *_data, + length_t _length) = 0; + + /** + * \brief Copies the given data array to the payload object. + * + * The current payload content is replaced by the data provided. + * The given buffer remains untouched. + * + * \param _data Vector containing the data + */ + VSOMEIP_EXPORT virtual void set_data( + const std::vector<byte_t> &_data) = 0; + + /** + * \brief Returns the length of the payload content. + */ + VSOMEIP_EXPORT virtual length_t get_length() const = 0; + + /** + * \brief Set the maximum length of the payload content. + * + * This function must be called before directly copying data using the + * pointer to the internal buffer. + */ + VSOMEIP_EXPORT virtual void set_capacity(length_t _length) = 0; + + /** + * \brief Moves the given data array to the payload object. + * + * The current payload content is replaced by the data provided. + * The given buffer is owned by the payload object afterwards. + * + * \param _data Vector containing the data + */ + VSOMEIP_EXPORT virtual void set_data( + std::vector<byte_t> &&_data) = 0; +}; + +/** @} */ + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_PAYLOAD_HPP_ diff --git a/interface/vsomeip/plugin.hpp b/interface/vsomeip/plugin.hpp index 4d608f1..dfb6bba 100644 --- a/interface/vsomeip/plugin.hpp +++ b/interface/vsomeip/plugin.hpp @@ -3,12 +3,12 @@ // 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_PLUGIN_HPP -#define VSOMEIP_PLUGIN_HPP +#ifndef VSOMEIP_V3_PLUGIN_HPP_ +#define VSOMEIP_V3_PLUGIN_HPP_ #include <memory> -#if WIN32 +#if _WIN32 #if VSOMEIP_DLL_COMPILATION_PLUGIN #define VSOMEIP_IMPORT_EXPORT_PLUGIN __declspec(dllexport) #else @@ -20,7 +20,7 @@ #define VSOMEIP_PLUGIN_INIT_SYMBOL "vsomeip_plugin_init" -namespace vsomeip { +namespace vsomeip_v3 { enum class plugin_type_e : uint8_t { APPLICATION_PLUGIN, @@ -79,11 +79,11 @@ private: #define VSOMEIP_PLUGIN(class_name) \ extern "C" { \ - VSOMEIP_EXPORT vsomeip::create_plugin_func vsomeip_plugin_init() { \ + VSOMEIP_EXPORT vsomeip_v3::create_plugin_func vsomeip_plugin_init() { \ return class_name::get_plugin; \ } \ } -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_PLUGIN_HPP +#endif // VSOMEIP_V3_PLUGIN_HPP_ diff --git a/interface/vsomeip/plugins/application_plugin.hpp b/interface/vsomeip/plugins/application_plugin.hpp index 3d5cce1..90e3e64 100644 --- a/interface/vsomeip/plugins/application_plugin.hpp +++ b/interface/vsomeip/plugins/application_plugin.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_APPLICATION_PLUGIN_HPP -#define VSOMEIP_APPLICATION_PLUGIN_HPP +#ifndef VSOMEIP_V3_APPLICATION_PLUGIN_HPP_ +#define VSOMEIP_V3_APPLICATION_PLUGIN_HPP_ #include <string> #include <memory> @@ -14,7 +14,7 @@ // Version should be incremented on breaking API change #define VSOMEIP_APPLICATION_PLUGIN_VERSION 1 -namespace vsomeip { +namespace vsomeip_v3 { enum class application_plugin_state_e : uint8_t { STATE_INITIALIZED, @@ -37,6 +37,6 @@ public: const application_plugin_state_e _app_state) = 0; }; -} +} // namespace vsomeip_v3 -#endif // VSOMEIP_APPLICATION_PLUGIN_HPP +#endif // VSOMEIP_V3_APPLICATION_PLUGIN_HPP_ diff --git a/interface/vsomeip/plugins/pre_configuration_plugin.hpp b/interface/vsomeip/plugins/pre_configuration_plugin.hpp index 6155796..6505249 100644 --- a/interface/vsomeip/plugins/pre_configuration_plugin.hpp +++ b/interface/vsomeip/plugins/pre_configuration_plugin.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_PRE_CONFIGURATION_PLUGIN_HPP -#define VSOMEIP_PRE_CONFIGURATION_PLUGIN_HPP +#ifndef VSOMEIP_V3_PRE_CONFIGURATION_PLUGIN_HPP_ +#define VSOMEIP_V3_PRE_CONFIGURATION_PLUGIN_HPP_ #include <vsomeip/export.hpp> // Version should be incremented on breaking API change #define VSOMEIP_PRE_CONFIGURATION_PLUGIN_VERSION 1 -namespace vsomeip { +namespace vsomeip_v3 { /** * The pre configuration plug-in can be used to extend configuration load behavior * via an module/plug-in. @@ -24,6 +24,7 @@ public: // vSomeIP will use this path for config loading if such a plug-in is availablel. virtual std::string get_configuration_path() = 0; }; -} -#endif // VSOMEIP_PRE_CONFIGURATION_PLUGIN_HPP +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_PRE_CONFIGURATION_PLUGIN_HPP_ diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index 95192eb..f0dd136 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -3,13 +3,17 @@ // 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_PRIMITIVE_TYPES_HPP -#define VSOMEIP_PRIMITIVE_TYPES_HPP +#ifndef VSOMEIP_V3_PRIMITIVE_TYPES_HPP_ +#define VSOMEIP_V3_PRIMITIVE_TYPES_HPP_ #include <array> #include <cstdint> -namespace vsomeip { +#ifndef _WIN32 +#include <sys/types.h> +#endif + +namespace vsomeip_v3 { typedef uint32_t message_t; typedef uint16_t service_t; @@ -34,6 +38,7 @@ typedef uint8_t protocol_version_t; typedef uint8_t interface_version_t; typedef uint8_t byte_t; +typedef uint16_t diagnosis_t; // Addresses typedef std::array<byte_t, 4> ipv4_address_t; @@ -43,12 +48,18 @@ 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 +#ifdef _WIN32 + typedef std::uint32_t uid_t; + typedef std::uint32_t gid_t; +#else + typedef ::uid_t uid_t; + typedef ::uid_t gid_t; +#endif + +} // namespace vsomeip_v3 -#endif // VSOMEIP_PRIMITIVE_TYPES_HPP +#endif // VSOMEIP_V3_PRIMITIVE_TYPES_HPP diff --git a/interface/vsomeip/runtime.hpp b/interface/vsomeip/runtime.hpp index ae54e19..513847d 100644 --- a/interface/vsomeip/runtime.hpp +++ b/interface/vsomeip/runtime.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_RUNTIME_HPP -#define VSOMEIP_RUNTIME_HPP +#ifndef VSOMEIP_V3_RUNTIME_HPP +#define VSOMEIP_V3_RUNTIME_HPP #include <memory> #include <string> @@ -13,7 +13,7 @@ #include <vsomeip/export.hpp> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class application; class message; @@ -211,6 +211,6 @@ public: /** @} */ -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_RUNTIME_HPP +#endif // VSOMEIP_V3_RUNTIME_HPP_ diff --git a/interface/vsomeip/trace.hpp b/interface/vsomeip/trace.hpp index 85cfd30..cf5b7b9 100644 --- a/interface/vsomeip/trace.hpp +++ b/interface/vsomeip/trace.hpp @@ -2,8 +2,9 @@ // 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_ + +#ifndef VSOMEIP_V3_TRACE_HPP_ +#define VSOMEIP_V3_TRACE_HPP_ #include <memory> #include <vector> @@ -11,7 +12,7 @@ #include <vsomeip/constants.hpp> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { /** * \defgroup vsomeip * @@ -153,29 +154,29 @@ public: */ class connector { public: - /** - * \brief Get access to the connector. - * - * \return Shared pointer to the singleton object. - */ + /** + * \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. - */ + /** + * \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; @@ -203,7 +204,7 @@ public: * of the default trace channel. * * \return Shared pointer to the created trace channel or - * nullptr if the trace channel does not exist. + * 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; @@ -213,6 +214,6 @@ public: /** @} */ -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CONSTANTS_HPP +#endif // VSOMEIP_V3_CONSTANTS_HPP_ diff --git a/interface/vsomeip/vsomeip.hpp b/interface/vsomeip/vsomeip.hpp index 1068b0b..231fa3a 100644 --- a/interface/vsomeip/vsomeip.hpp +++ b/interface/vsomeip/vsomeip.hpp @@ -18,4 +18,6 @@ #include <vsomeip/runtime.hpp> #include <vsomeip/trace.hpp> +namespace vsomeip = vsomeip_v3; + #endif // VSOMEIP_VSOMEIP_HPP |