From 23185fe679214c7c87ef2bc589f38f0e60bacff3 Mon Sep 17 00:00:00 2001 From: Roberto Scolaro Date: Fri, 26 Jul 2024 14:00:54 +0000 Subject: [PATCH] fix(libsinsp): add function to set compiler filter and filter string Signed-off-by: Roberto Scolaro --- userspace/libsinsp/sinsp.cpp | 7 +++++++ userspace/libsinsp/sinsp.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/userspace/libsinsp/sinsp.cpp b/userspace/libsinsp/sinsp.cpp index 86b722df418..7681e3f97a4 100644 --- a/userspace/libsinsp/sinsp.cpp +++ b/userspace/libsinsp/sinsp.cpp @@ -1686,6 +1686,13 @@ void sinsp::set_filter(const std::string& filter) m_internal_flt_ast = compiler.get_filter_ast(); } +void sinsp::set_filter(const std::string& filterstring, std::unique_ptr filter) +{ + set_filter(filter); + m_filterstring = filterstring; +} + + std::string sinsp::get_filter() const { return m_filterstring; diff --git a/userspace/libsinsp/sinsp.h b/userspace/libsinsp/sinsp.h index a709cc44a28..52dde9674ed 100644 --- a/userspace/libsinsp/sinsp.h +++ b/userspace/libsinsp/sinsp.h @@ -305,6 +305,17 @@ class SINSP_PUBLIC sinsp : public capture_stats_source */ void set_filter(std::unique_ptr filter); + /*! + \brief Installs the given capture runtime filter object and accordingly + sets the filter string. + + \param filter the filter string. Refer to the filtering language + section for information about the filtering + syntax. + \param filter the runtime filter object + */ + void set_filter(const std::string& filterstring, std::unique_ptr filter); + /*! \brief Return the filter set for this capture.