summaryrefslogtreecommitdiff
path: root/implementation/tracing/include
diff options
context:
space:
mode:
Diffstat (limited to 'implementation/tracing/include')
-rw-r--r--implementation/tracing/include/channel_impl.hpp62
-rw-r--r--implementation/tracing/include/connector_impl.hpp81
-rw-r--r--implementation/tracing/include/defines.hpp4
-rw-r--r--implementation/tracing/include/enumeration_types.hpp14
-rw-r--r--implementation/tracing/include/header.hpp (renamed from implementation/tracing/include/trace_header.hpp)12
-rw-r--r--implementation/tracing/include/trace_connector.hpp107
6 files changed, 156 insertions, 124 deletions
diff --git a/implementation/tracing/include/channel_impl.hpp b/implementation/tracing/include/channel_impl.hpp
new file mode 100644
index 0000000..9034657
--- /dev/null
+++ b/implementation/tracing/include/channel_impl.hpp
@@ -0,0 +1,62 @@
+// 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_TRACING_CHANNEL_IMPL_HPP_
+#define VSOMEIP_TRACING_CHANNEL_IMPL_HPP_
+
+#include <atomic>
+#include <functional>
+#include <map>
+#include <mutex>
+#include <string>
+
+#include <vsomeip/trace.hpp>
+
+namespace vsomeip {
+namespace trace {
+
+typedef std::function<bool (service_t, instance_t, method_t)> filter_func_t;
+
+class channel_impl : public channel {
+public:
+ channel_impl(const std::string &_id, const std::string &_name);
+
+ std::string get_id() const;
+ std::string get_name() const;
+
+ filter_id_t add_filter(
+ const match_t &_match,
+ bool _is_positive);
+
+ filter_id_t add_filter(
+ const std::vector<match_t> &_matches,
+ bool _is_positive);
+
+ filter_id_t add_filter(
+ const match_t &_from, const match_t &_to,
+ bool _is_positive);
+
+ void remove_filter(
+ filter_id_t _id);
+
+ bool matches(service_t _service, instance_t _instance, method_t _method);
+
+private:
+ filter_id_t add_filter_intern(filter_func_t _func, bool _is_positive);
+
+ std::string id_;
+ std::string name_;
+
+ std::atomic<filter_id_t> current_filter_id_;
+
+ std::map<filter_id_t, filter_func_t> positive_;
+ std::map<filter_id_t, filter_func_t> negative_;
+ std::mutex mutex_; // protects positive_ & negative_
+};
+
+} // namespace trace
+} // namespace vsomeip
+
+#endif // VSOMEIP_TRACING_CHANNEL_IMPL_HPP_
diff --git a/implementation/tracing/include/connector_impl.hpp b/implementation/tracing/include/connector_impl.hpp
new file mode 100644
index 0000000..3234fed
--- /dev/null
+++ b/implementation/tracing/include/connector_impl.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_TC_TRACE_CONNECTOR_HPP
+#define VSOMEIP_TC_TRACE_CONNECTOR_HPP
+
+#ifdef USE_DLT
+#include <dlt/dlt.h>
+#endif
+
+#include <mutex>
+#include <vector>
+#include <map>
+
+#include <boost/shared_ptr.hpp>
+
+#include <vsomeip/primitive_types.hpp>
+#include <vsomeip/export.hpp>
+#include <vsomeip/trace.hpp>
+
+#include "enumeration_types.hpp"
+#include "header.hpp"
+#include "../../endpoints/include/buffer.hpp"
+
+namespace vsomeip {
+
+namespace cfg {
+ struct trace;
+}
+
+namespace trace {
+
+class channel_impl;
+
+class connector_impl : public connector {
+public:
+ VSOMEIP_EXPORT static std::shared_ptr<connector_impl> get();
+
+ VSOMEIP_EXPORT connector_impl();
+ VSOMEIP_EXPORT virtual ~connector_impl();
+
+ VSOMEIP_EXPORT void configure(const std::shared_ptr<cfg::trace> &_configuration);
+ VSOMEIP_EXPORT void reset();
+
+ VSOMEIP_EXPORT void set_enabled(const bool _enabled);
+ VSOMEIP_EXPORT bool is_enabled() const;
+
+ VSOMEIP_EXPORT void set_sd_enabled(const bool _sd_enabled);
+ VSOMEIP_EXPORT bool is_sd_enabled() const;
+
+ VSOMEIP_EXPORT bool is_sd_message(const byte_t *_data, uint16_t _data_size) const;
+
+ VSOMEIP_EXPORT std::shared_ptr<channel> add_channel(const std::string &_id,
+ const std::string &_description);
+ VSOMEIP_EXPORT bool remove_channel(const std::string &_id);
+ VSOMEIP_EXPORT std::shared_ptr<channel> get_channel(const std::string &_id) const;
+
+ VSOMEIP_EXPORT void trace(const byte_t *_header, uint16_t _header_size,
+ const byte_t *_data, uint16_t _data_size);
+
+private:
+ bool is_enabled_;
+ bool is_sd_enabled_;
+ bool is_initialized_;
+
+ std::map<std::string, std::shared_ptr<channel_impl>> channels_;
+ mutable std::mutex channels_mutex_;
+
+#ifdef USE_DLT
+ std::map<std::string, std::shared_ptr<DltContext>> contexts_;
+ mutable std::mutex contexts_mutex_;
+#endif
+
+};
+
+} // namespace trace
+} // namespace vsomeip
+
+#endif // VSOMEIP_TC_TRACE_CONNECTOR_HPP
diff --git a/implementation/tracing/include/defines.hpp b/implementation/tracing/include/defines.hpp
index aadb44f..2325259 100644
--- a/implementation/tracing/include/defines.hpp
+++ b/implementation/tracing/include/defines.hpp
@@ -7,7 +7,9 @@
#define TRACING_INCLUDE_DEFINES_HPP_
#define VSOMEIP_TC_DEFAULT_CHANNEL_NAME "Trace Connector Network Logging"
-#define VSOMEIP_TC_DEFAULT_CHANNEL_ID "TC"
#define VSOMEIP_TC_DEFAULT_FILTER_TYPE "positive"
+#define VSOMEIP_TC_INSTANCE_POS_MIN 8
+#define VSOMEIP_TC_INSTANCE_POS_MAX 9
+
#endif /* TRACING_INCLUDE_DEFINES_HPP_ */
diff --git a/implementation/tracing/include/enumeration_types.hpp b/implementation/tracing/include/enumeration_types.hpp
index 82ed3c4..352ddd3 100644
--- a/implementation/tracing/include/enumeration_types.hpp
+++ b/implementation/tracing/include/enumeration_types.hpp
@@ -3,24 +3,18 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef VSOMEIP_TC_ENUMERATION_TYPES_HPP
-#define VSOMEIP_TC_ENUMERATION_TYPES_HPP
+#ifndef VSOMEIP_TRACE_ENUMERATION_TYPES_HPP
+#define VSOMEIP_TRACE_ENUMERATION_TYPES_HPP
namespace vsomeip {
-namespace tc {
-
-enum class filter_criteria_e : uint8_t {
- SERVICES = 0x00,
- METHODS = 0x01,
- CLIENTS = 0x02,
-};
+namespace trace {
enum class filter_type_e : uint8_t {
NEGATIVE = 0x00,
POSITIVE = 0x01
};
-} // namespace tc
+} // namespace trace
} // namespace vsomeip
#endif // VSOMEIP_TC_ENUMERATION_TYPES_HPP
diff --git a/implementation/tracing/include/trace_header.hpp b/implementation/tracing/include/header.hpp
index 11ccbdd..55ec73e 100644
--- a/implementation/tracing/include/trace_header.hpp
+++ b/implementation/tracing/include/header.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_TC_TRACE_HEADER_HPP
-#define VSOMEIP_TC_TRACE_HEADER_HPP
+#ifndef VSOMEIP_TRACE_HEADER_HPP
+#define VSOMEIP_TRACE_HEADER_HPP
#include <memory>
@@ -18,7 +18,7 @@ namespace vsomeip {
class endpoint;
-namespace tc {
+namespace trace {
enum class protocol_e : uint8_t {
local = 0x0,
@@ -27,7 +27,7 @@ enum class protocol_e : uint8_t {
unknown = 0xFF
};
-struct trace_header {
+struct header {
bool prepare(const std::shared_ptr<endpoint> &_endpoint, bool _is_sending,
instance_t _instance);
bool prepare(const endpoint* _endpoint, bool _is_sending,
@@ -39,7 +39,7 @@ struct trace_header {
byte_t data_[VSOMEIP_TRACE_HEADER_SIZE];
};
-} // namespace tc
+} // namespace trace
} // namespace vsomeip
-#endif // VSOMEIP_TC_TRACE_HEADER_HPP
+#endif // VSOMEIP_TRACE_HEADER_HPP
diff --git a/implementation/tracing/include/trace_connector.hpp b/implementation/tracing/include/trace_connector.hpp
deleted file mode 100644
index ef36e29..0000000
--- a/implementation/tracing/include/trace_connector.hpp
+++ /dev/null
@@ -1,107 +0,0 @@
-// 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_TC_TRACE_CONNECTOR_HPP
-#define VSOMEIP_TC_TRACE_CONNECTOR_HPP
-
-#include <vsomeip/primitive_types.hpp>
-#include <vsomeip/export.hpp>
-#include <boost/shared_ptr.hpp>
-#include <mutex>
-#include <vector>
-#include <map>
-
-#ifdef USE_DLT
-#include <dlt/dlt.h>
-#endif
-
-#include "enumeration_types.hpp"
-#include "trace_header.hpp"
-#include "../../endpoints/include/buffer.hpp"
-
-namespace vsomeip
-{
-namespace tc
-{
-
-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, 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;
-
-#ifdef USE_DLT
- typedef std::map<trace_channel_t, DltContext*> dlt_contexts_t;
-#endif
-
- VSOMEIP_EXPORT static std::shared_ptr<trace_connector> get();
-
- VSOMEIP_EXPORT trace_connector();
- VSOMEIP_EXPORT virtual ~trace_connector();
-
- VSOMEIP_EXPORT void init();
- VSOMEIP_EXPORT void reset();
-
- VSOMEIP_EXPORT void set_enabled(const bool _enabled);
- VSOMEIP_EXPORT bool is_enabled() const;
-
- VSOMEIP_EXPORT void set_sd_enabled(const bool _enabled);
- VSOMEIP_EXPORT bool is_sd_enabled() const;
-
- VSOMEIP_EXPORT bool is_sd_message(const byte_t *_data, uint16_t _data_size) const;
-
- VSOMEIP_EXPORT bool add_channel(const trace_channel_t &_id,const std::string &_name);
- VSOMEIP_EXPORT bool remove_channel(const trace_channel_t &_id);
-
- VSOMEIP_EXPORT bool add_filter_rule(const trace_channel_t &_channel_id,
- const filter_rule_t _filter_rule);
- VSOMEIP_EXPORT bool add_filter_expression(const trace_channel_t &_channel_id,
- const filter_criteria_e _criteria,
- const filter_expression_t _expression);
- VSOMEIP_EXPORT bool change_filter_expressions(const trace_channel_t &_channel_id,
- const filter_criteria_e _criteria,
- const filter_expressions_t _expressions);
- VSOMEIP_EXPORT bool remove_filter_rule(const trace_channel_t &_channel_id);
-
- VSOMEIP_EXPORT void trace(const byte_t *_header, uint16_t _header_size,
- const byte_t *_data, uint16_t _data_size);
-
- VSOMEIP_EXPORT channels_t get_channels();
- VSOMEIP_EXPORT filter_rules_t get_filter_rules();
- VSOMEIP_EXPORT filter_rule_t get_filter_rule(const trace_channel_t &_channel_id);
-
-private:
-
- bool apply_filter_rules(const byte_t *_data, const uint16_t _data_size,
- std::vector<trace_channel_t> &_send_msg_over_channels);
-
- bool filter_expressions_match(const filter_criteria_e _criteria,
- const filter_expressions_t _expressions,
- const byte_t *_data, const uint16_t _data_size);
-
- bool is_enabled_;
- bool is_sd_enabled_;
- bool is_initialized_;
-
- channels_t channels_;
- filter_rules_t filter_rules_;
-
-#ifdef USE_DLT
- dlt_contexts_t dlt_contexts_;
-#endif
-
- std::mutex channels_mutex_;
- std::mutex filter_rules_mutex_;
- std::mutex dlt_contexts_mutex;
-};
-
-} // namespace tc
-} // namespace vsomeip
-
-#endif // VSOMEIP_TC_TRACE_CONNECTOR_HPP