Skip to content

Commit

Permalink
vsomeip 2.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent ba05080 commit e9c35d3
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 44 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 17 additions & 6 deletions documentation/vsomeipUserGuide
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
+
Expand Down Expand Up @@ -1217,6 +1225,7 @@ Example 2 (Using Filters)
"services" : [ "0x1234" ],
"methods" : [ "0x80e8" ],
"clients" : [ "0x1343" ],
"type" : "positive"
}
]
},
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion implementation/configuration/include/internal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion implementation/configuration/include/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ struct trace_filter_rule {
channel_(VSOMEIP_TC_DEFAULT_CHANNEL_ID),
services_(),
methods_(),
clients_() {
clients_(),
type_(VSOMEIP_TC_DEFAULT_FILTER_TYPE) {

}

trace_channel_t channel_;
std::vector<service_t> services_;
std::vector<method_t> methods_;
std::vector<client_t> clients_;
trace_filter_type_t type_;
};

struct trace {
Expand Down
2 changes: 2 additions & 0 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
16 changes: 13 additions & 3 deletions implementation/runtime/src/application_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions implementation/tracing/include/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
5 changes: 5 additions & 0 deletions implementation/tracing/include/enumeration_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion implementation/tracing/include/trace_connector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
54 changes: 24 additions & 30 deletions implementation/tracing/src/trace_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions interface/vsomeip/primitive_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion test/initial_event_tests/initial_event_test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class initial_event_test_client {
}

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,
Expand Down

0 comments on commit e9c35d3

Please sign in to comment.