assert(!conn.second.thread_connectors[instance]);
Connector* connector = sc.api->tinit(conn.second.config);
- assert(connector);
conn.second.thread_connectors[instance] = std::move(connector);
}
}
{
for ( auto& conn : sc.connectors )
{
- assert(conn.second.thread_connectors[instance]);
-
- conn.second.thread_connectors[instance]->reinit();
+ if (conn.second.thread_connectors[instance])
+ conn.second.thread_connectors[instance]->reinit();
}
}
}
{
for ( auto& conn : sc.connectors )
{
- assert(conn.second.thread_connectors[instance]);
-
- sc.api->tterm(conn.second.thread_connectors[instance]);
- conn.second.thread_connectors[instance] = nullptr;
+ if ( conn.second.thread_connectors[instance] )
+ {
+ sc.api->tterm(conn.second.thread_connectors[instance]);
+ conn.second.thread_connectors[instance] = nullptr;
+ }
}
}
}
extractor_service.h
extractors.cc
extractors.h
+ extractor_null_conn.h
)
add_library(extractor OBJECT ${FILE_LIST})
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//--------------------------------------------------------------------------
-// csv_logger.cc author Anna Norokh <anorokh@cisco.com>
+// extractor_csv_logger.cc author Anna Norokh <anorokh@cisco.com>
#ifdef HAVE_CONFIG_H
#include "config.h"
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//--------------------------------------------------------------------------
-// csv_logger.h author Anna Norokh <anorokh@cisco.com>
+// extractor_csv_logger.h author Anna Norokh <anorokh@cisco.com>
#ifndef EXTRACTOR_CSV_LOGGER_H
#define EXTRACTOR_CSV_LOGGER_H
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//--------------------------------------------------------------------------
-// json_logger.cc author Cisco
+// extractor_json_logger.cc author Cisco
#ifdef HAVE_CONFIG_H
#include "config.h"
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//--------------------------------------------------------------------------
-// json_logger.h author Cisco
+// extractor_json_logger.h author Cisco
#ifndef EXTRACTOR_JSON_LOGGER_H
#define EXTRACTOR_JSON_LOGGER_H
#include <cassert>
#include "log/messages.h"
+#include "main/thread.h"
#include "managers/connector_manager.h"
#include "extractor_csv_logger.h"
using namespace snort;
-static Connector* get_connector(const std::string& conn_name)
+Connector* ExtractorLogger::get_connector(const std::string& conn_name)
{
Connector* connector = ConnectorManager::get_connector(conn_name);
if (connector == nullptr)
{
- ErrorMessage("Can't initialize extractor, unable to find Connector \"%s\"\n", conn_name.c_str());
- abort();
+ ErrorMessage("Unable to get '%s' connector in thread %d, fallback to default\n",
+ conn_name.c_str(), get_instance_id());
+
+ static ExtractorNullConnector default_connector;
+
+ return &default_connector;
}
switch (connector->get_connector_direction())
#include "framework/connector.h"
#include "sfip/sf_ip.h"
+#include "extractor_null_conn.h"
#include "extractor_enums.h"
class ExtractorLogger
void flush() { output_conn->flush(); }
protected:
+ static snort::Connector* get_connector(const std::string& conn_name);
+
snort::Connector* const output_conn;
};
--- /dev/null
+//--------------------------------------------------------------------------
+// Copyright (C) 2025-2025 Cisco and/or its affiliates. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License Version 2 as published
+// by the Free Software Foundation. You may not use, modify or distribute
+// this program under any other version of the GNU General Public License.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//--------------------------------------------------------------------------
+// extractor_null_conn.h author Vitalii Horbatov <vhorbato@cisco.com>
+
+#ifndef EXTRACTOR_NULL_CONN_H
+#define EXTRACTOR_NULL_CONN_H
+
+#include "framework/connector.h"
+
+class ExtractorNullConnector : public snort::Connector
+{
+public:
+ ExtractorNullConnector() : snort::Connector(conf)
+ {
+ conf.connector_name = "null";
+ conf.direction = snort::Connector::CONN_DUPLEX;
+ }
+
+ bool transmit_message(const snort::ConnectorMsg&, const ID& = null) override
+ { return true; }
+
+ bool transmit_message(const snort::ConnectorMsg&&, const ID& = null) override
+ { return true; }
+
+ snort::ConnectorMsg receive_message(bool) override
+ { return snort::ConnectorMsg(); }
+
+private:
+ snort::ConnectorConfig conf;
+};
+
+#endif
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//--------------------------------------------------------------------------
-// extractor_services.cc author Maya Dagon <mdagon@cisco.com>
+// extractor_service.cc author Maya Dagon <mdagon@cisco.com>
#ifdef HAVE_CONFIG_H
#include "config.h"