diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | documentation/vsomeipUserGuide | 23 | ||||
-rw-r--r-- | implementation/configuration/include/internal.hpp.in | 2 | ||||
-rw-r--r-- | implementation/configuration/include/trace.hpp | 4 | ||||
-rw-r--r-- | implementation/configuration/src/configuration_impl.cpp | 2 | ||||
-rw-r--r-- | implementation/runtime/src/application_impl.cpp | 16 | ||||
-rw-r--r-- | implementation/tracing/include/defines.hpp | 1 | ||||
-rw-r--r-- | implementation/tracing/include/enumeration_types.hpp | 5 | ||||
-rw-r--r-- | implementation/tracing/include/trace_connector.hpp | 3 | ||||
-rw-r--r-- | implementation/tracing/src/trace_connector.cpp | 54 | ||||
-rw-r--r-- | interface/vsomeip/primitive_types.hpp | 2 | ||||
-rw-r--r-- | test/initial_event_tests/initial_event_test_client.cpp | 4 |
13 files changed, 77 insertions, 44 deletions
@@ -1,6 +1,9 @@ Changes ======= +v2.8.1 +- Support negative filter in trace connector + v2.8.0 - Change behaviour of register_subscription_status_handler method of the application interface: Registered handlers will only be called diff --git a/CMakeLists.txt b/CMakeLists.txt index a46f34a..596b2ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ project (vsomeip) set (VSOMEIP_MAJOR_VERSION 2) set (VSOMEIP_MINOR_VERSION 8) -set (VSOMEIP_PATCH_VERSION 0) +set (VSOMEIP_PATCH_VERSION 1) set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION}) set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentatin/doxygen.in set (CMAKE_VERBOSE_MAKEFILE off) diff --git a/documentation/vsomeipUserGuide b/documentation/vsomeipUserGuide index 922af01..81623ce 100644 --- a/documentation/vsomeipUserGuide +++ b/documentation/vsomeipUserGuide @@ -392,6 +392,14 @@ Contains the method ids. The messages that relates to the specified methods will Contains the client ids. The messages that relates to the specified clients will be filtered. + +*** 'type' (optional) ++ +Specifies the filter type (valid values: "positive", "negative"). When a positive +filter is used and a message matches one of the filter rules, the message will be +traced/forwarded to DLT. With a negative filter messages can be excluded. So when a +message matches one of the filter rules, the message will not be traced/forwarded to +DLT. Default value is "positive". ++ //Applications * 'applications (array)' + @@ -1217,6 +1225,7 @@ Example 2 (Using Filters) "services" : [ "0x1234" ], "methods" : [ "0x80e8" ], "clients" : [ "0x1343" ], + "type" : "positive" } ] }, @@ -1233,9 +1242,14 @@ You can apply filters to the messages. In this example only the messages that * relates to the client with the id _0x1234_ -will be traced/forwarded to DLT. The messages will be forwarded over the channel -with the id _MC_. If just one filter is used, then the definition of a channel is -optional. But if multiple filters are used, each filter needs an own channel! + +will be traced/forwarded to DLT. This is a kind of positive filtering. To +exclude messages from tracing/forwarding to DLT, the filter type can be +set to "negative". This would suppress the messages that relate to the +specified service, method and client ids. The default filter type is +psoitive. + +The messages will be forwarded over the channel with the id _MC_. If +just one filter is used, then the definition of a channel is optional. +But if multiple filters are used, each filter needs an own channel! + In this example each criteria has only one expression/value but it's also possible to define multiple values to get a more fine-grained filter. + The ids of the filter criterias can be found in the appropriate _.fdepl_ files @@ -1273,9 +1287,6 @@ Example: // enable trace connector its_trace_connector->set_enabled(true); - - //forward a message to DLT - its_trace_connector->forward_to_dlt(MESSAGE_TO_FORWARD); ---- Tools diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in index 14d58f9..b16cc01 100644 --- a/implementation/configuration/include/internal.hpp.in +++ b/implementation/configuration/include/internal.hpp.in @@ -18,7 +18,7 @@ #define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" #define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" -#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json" +#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json" #define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" #define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip" diff --git a/implementation/configuration/include/trace.hpp b/implementation/configuration/include/trace.hpp index 687e57e..db92286 100644 --- a/implementation/configuration/include/trace.hpp +++ b/implementation/configuration/include/trace.hpp @@ -34,7 +34,8 @@ struct trace_filter_rule { channel_(VSOMEIP_TC_DEFAULT_CHANNEL_ID), services_(), methods_(), - clients_() { + clients_(), + type_(VSOMEIP_TC_DEFAULT_FILTER_TYPE) { } @@ -42,6 +43,7 @@ struct trace_filter_rule { std::vector<service_t> services_; std::vector<method_t> methods_; std::vector<client_t> clients_; + trace_filter_type_t type_; }; struct trace { diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index d1bdac5..78c4535 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -635,6 +635,8 @@ void configuration_impl::load_trace_filter( std::string its_value = i->second.data(); if(its_key == "channel") { its_filter_rule->channel_ = its_value; + } else if(its_key == "type") { + its_filter_rule->type_ = its_value; } else { load_trace_filter_expressions(i->second, its_key, its_filter_rule); } diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index c776353..d44aa9a 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -175,10 +175,20 @@ bool application_impl::init() { for (auto it = its_filter_rules_cfg.begin(); it != its_filter_rules_cfg.end(); ++it) { std::shared_ptr<cfg::trace_filter_rule> its_filter_rule_cfg = *it; tc::trace_connector::filter_rule_t its_filter_rule; + tc::filter_type_e its_filter_type; - its_filter_rule[tc::filter_criteria_e::SERVICES] = its_filter_rule_cfg->services_; - its_filter_rule[tc::filter_criteria_e::METHODS] = its_filter_rule_cfg->methods_; - its_filter_rule[tc::filter_criteria_e::CLIENTS] = its_filter_rule_cfg->clients_; + if(its_filter_rule_cfg->type_ == "negative") { + its_filter_type = tc::filter_type_e::NEGATIVE; + } else { + its_filter_type = tc::filter_type_e::POSITIVE; + } + + tc::trace_connector::filter_rule_map_t its_filter_rule_map; + its_filter_rule_map[tc::filter_criteria_e::SERVICES] = its_filter_rule_cfg->services_; + its_filter_rule_map[tc::filter_criteria_e::METHODS] = its_filter_rule_cfg->methods_; + its_filter_rule_map[tc::filter_criteria_e::CLIENTS] = its_filter_rule_cfg->clients_; + + its_filter_rule = std::make_pair(its_filter_type, its_filter_rule_map); its_trace_connector->add_filter_rule(it->get()->channel_, its_filter_rule); } diff --git a/implementation/tracing/include/defines.hpp b/implementation/tracing/include/defines.hpp index 1b98e16..aadb44f 100644 --- a/implementation/tracing/include/defines.hpp +++ b/implementation/tracing/include/defines.hpp @@ -8,5 +8,6 @@ #define VSOMEIP_TC_DEFAULT_CHANNEL_NAME "Trace Connector Network Logging" #define VSOMEIP_TC_DEFAULT_CHANNEL_ID "TC" +#define VSOMEIP_TC_DEFAULT_FILTER_TYPE "positive" #endif /* TRACING_INCLUDE_DEFINES_HPP_ */ diff --git a/implementation/tracing/include/enumeration_types.hpp b/implementation/tracing/include/enumeration_types.hpp index 62287bb..7696c57 100644 --- a/implementation/tracing/include/enumeration_types.hpp +++ b/implementation/tracing/include/enumeration_types.hpp @@ -15,6 +15,11 @@ enum class filter_criteria_e : uint8_t { CLIENTS = 0x02, }; +enum class filter_type_e : uint8_t { + NEGATIVE = 0x00, + POSITIVE = 0x01 +}; + } // namespace tc } // namespace vsomeip diff --git a/implementation/tracing/include/trace_connector.hpp b/implementation/tracing/include/trace_connector.hpp index 9af4411..ef36e29 100644 --- a/implementation/tracing/include/trace_connector.hpp +++ b/implementation/tracing/include/trace_connector.hpp @@ -30,7 +30,8 @@ class trace_connector { public: typedef uint16_t filter_expression_t; typedef std::vector<filter_expression_t> filter_expressions_t; - typedef std::map<filter_criteria_e, std::vector<filter_expression_t>> filter_rule_t; + typedef std::map<filter_criteria_e, filter_expressions_t> filter_rule_map_t; + typedef std::pair<filter_type_e, filter_rule_map_t> filter_rule_t; typedef std::map<trace_channel_t, std::string> channels_t; typedef std::map<trace_channel_t, filter_rule_t> filter_rules_t; diff --git a/implementation/tracing/src/trace_connector.cpp b/implementation/tracing/src/trace_connector.cpp index 8734748..93f7d6e 100644 --- a/implementation/tracing/src/trace_connector.cpp +++ b/implementation/tracing/src/trace_connector.cpp @@ -176,10 +176,10 @@ bool trace_connector::add_filter_expression(const trace_channel_t &_channel_id, filter_rule_t its_filter_rule = it_filter_rules->second; // find filter criteria - auto it_filter_rule = its_filter_rule.find(_criteria); - if(it_filter_rule != its_filter_rule.end()) { + auto it_filter_rule_map = its_filter_rule.second.find(_criteria); + if(it_filter_rule_map != its_filter_rule.second.end()) { // add expression - it_filter_rule->second.push_back(_expression); + it_filter_rule_map->second.push_back(_expression); return true; } } @@ -197,10 +197,10 @@ bool trace_connector::change_filter_expressions(const trace_channel_t &_channel_ filter_rule_t its_filter_rule = it_filter_rules->second; // find filter criteria - auto it_filter_rule = its_filter_rule.find(_criteria); - if(it_filter_rule != its_filter_rule.end()) { + auto it_filter_rule_map = its_filter_rule.second.find(_criteria); + if(it_filter_rule_map != its_filter_rule.second.end()) { // change expressions - it_filter_rule->second = _expressions; + it_filter_rule_map->second = _expressions; return true; } } @@ -295,20 +295,23 @@ bool trace_connector::apply_filter_rules(const byte_t *_data, uint16_t _data_si filter_rule_t its_filter_rule = it_filter_rules->second; // apply filter rule - bool filter_rule_matches = false; - for(auto it_filter_rule = its_filter_rule.begin(); it_filter_rule != its_filter_rule.end(); ++it_filter_rule) { - filter_criteria_e its_criteria = it_filter_rule->first; - auto &its_filter_expressions = it_filter_rule->second; - - // check if filter expressions of filter criteria match - filter_rule_matches = filter_expressions_match(its_criteria, its_filter_expressions, _data, _data_size); - if(!filter_rule_matches) { - // filter expressions of filter criteria does not match - break; + bool trace_message = true; + filter_type_e its_filter_type = its_filter_rule.first; + for(auto it_filter_rule_map = its_filter_rule.second.begin(); + it_filter_rule_map != its_filter_rule.second.end() && trace_message; + ++it_filter_rule_map) { + + filter_criteria_e its_criteria = it_filter_rule_map->first; + auto &its_filter_expressions = it_filter_rule_map->second; + + if(its_filter_expressions.size() != 0) { + // check if filter expressions of filter criteria match + const bool filter_rule_matches = filter_expressions_match(its_criteria, its_filter_expressions, _data, _data_size); + trace_message = !(filter_rule_matches && its_filter_type == filter_type_e::NEGATIVE); } } - if(filter_rule_matches) { + if(trace_message) { //filter rule matches -> send message over 'its_channel' to DLT _send_msg_over_channels.push_back(its_channel); } @@ -357,29 +360,20 @@ bool trace_connector::filter_expressions_match( // if extraction is successful, filter if (is_successful) { + bool filter_expressions_matches = false; for (auto it_expressions = _expressions.begin(); - it_expressions != _expressions.end(); + it_expressions != _expressions.end() && !filter_expressions_matches; ++it_expressions) { filter_expression_t its_filter_expression = *it_expressions; uint16_t its_message_value = 0; - - // check if one expression matches (byte order is sometimes wrong -> check both) its_message_value = (uint16_t)((its_message_value << 8) + first); its_message_value = (uint16_t)((its_message_value << 8) + second); - if(its_filter_expression == its_message_value) { - return true; - } - its_message_value = 0; - its_message_value = (uint16_t)((its_message_value << 8) + second); - its_message_value = (uint16_t)((its_message_value << 8) + first); - if(its_filter_expression == its_message_value) { - return true; - } + filter_expressions_matches = (its_filter_expression == its_message_value); } + return filter_expressions_matches; } - return false; } diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index 043fd9b..d6c90de 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -41,6 +41,8 @@ typedef std::array<byte_t, 16> ipv6_address_t; typedef std::string trace_channel_t; +typedef std::string trace_filter_type_t; + } // namespace vsomeip #endif // VSOMEIP_PRIMITIVE_TYPES_HPP diff --git a/test/initial_event_tests/initial_event_test_client.cpp b/test/initial_event_tests/initial_event_test_client.cpp index 9e1314f..ba33265 100644 --- a/test/initial_event_tests/initial_event_test_client.cpp +++ b/test/initial_event_tests/initial_event_test_client.cpp @@ -92,7 +92,9 @@ public: } other_services_available_[std::make_pair(i.service_id, i.instance_id)] = false; - other_services_received_notification_[std::make_pair(i.service_id, i.method_id)] = 0; + for (std::uint32_t j = 0; j < events_to_subscribe_; j++ ) { + other_services_received_notification_[std::make_pair(i.service_id, i.method_id+j)] = 0; + } if (!subscribe_on_available_) { if (events_to_subscribe_ == 1 ) { app_->subscribe(i.service_id, i.instance_id, i.eventgroup_id, |