-- updated usage
-- removed ! from error messages
-- fixed command line vs conf output configs
+-- moved log_tcpdump to log_pcap
+-- changed all output filename configs to be based on module name
122
-- pulled thread pinning from Josh
alert_test.cc
alert_unixsock.cc
log_null.cc
- log_tcpdump.cc
+ log_pcap.cc
unified2.cc
unified2_common.h
)
add_shared_library(alert_test loggers alert_test.cc)
add_shared_library(alert_unixsock loggers alert_unixsock.cc)
add_shared_library(log_null loggers log_null.cc)
- add_shared_library(log_tcpdump loggers log_tcpdump.cc)
+ add_shared_library(log_pcap loggers log_pcap.cc)
add_shared_library(unified2 loggers unified2.cc unified2_common.h)
endif (STATIC_LOGGERS)
alert_test.cc \
alert_unixsock.cc \
log_null.cc \
-log_tcpdump.cc \
+log_pcap.cc \
unified2.cc \
unified2_common.h
liblog_null_la_LDFLAGS = -export-dynamic -shared
liblog_null_la_SOURCES = log_null.cc
-ehlib_LTLIBRARIES += liblog_tcpdump.la
-liblog_tcpdump_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_SO
-liblog_tcpdump_la_LDFLAGS = -export-dynamic -shared
-liblog_tcpdump_la_SOURCES = log_tcpdump.cc
+ehlib_LTLIBRARIES += liblog_pcap.la
+liblog_pcap_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_SO
+liblog_pcap_la_LDFLAGS = -export-dynamic -shared
+liblog_pcap_la_SOURCES = log_pcap.cc
ehlib_LTLIBRARIES += libunified2.la
libunified2_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_SO
static THREAD_LOCAL TextLog* csv_log;
-static const char* s_name = "alert_csv";
+#define S_NAME "alert_csv"
+#define F_NAME S_NAME ".txt"
using namespace std;
static const Parameter s_params[] =
{
- // FIXIT-M provide PT_FILE and PT_PATH and enforce no
- // path chars in file (outputs file must be in instance dir)
- { "file", Parameter::PT_STRING, nullptr, "stdout",
- "name of alert file" },
+ { "file", Parameter::PT_BOOL, nullptr, "false",
+ "output to " F_NAME " instead of stdout" },
{ "csv", Parameter::PT_MULTI, csv_range, csv_deflt,
"selected fields will be output in given order left to right" },
class CsvModule : public Module
{
public:
- CsvModule() : Module(s_name, s_help, s_params) { };
+ CsvModule() : Module(S_NAME, s_help, s_params) { };
bool set(const char*, Value&, SnortConfig*);
bool begin(const char*, int, SnortConfig*);
bool end(const char*, int, SnortConfig*);
public:
- string file;
+ bool file;
string csvargs;
unsigned long limit;
unsigned units;
bool CsvModule::set(const char*, Value& v, SnortConfig*)
{
if ( v.is("file") )
- file = v.get_string();
+ file = v.get_bool();
else if ( v.is("csv") )
csvargs = SnortStrdup(v.get_string());
bool CsvModule::begin(const char*, int, SnortConfig*)
{
- file = "stdout";
+ file = false;
limit = 0;
units = 0;
csvargs = csv_deflt;
CsvLogger::CsvLogger(CsvModule* m)
{
- file = m->file;
+ file = m->file ? F_NAME : "stdout";
limit = m->limit;
args = mSplit(m->csvargs.c_str(), " \n\t", 0, &numargs, 0);
}
{
{
PT_LOGGER,
- s_name,
+ S_NAME,
s_help,
LOGAPI_PLUGIN_V0,
0,
using namespace std;
-static const char* s_name = "alert_fast";
+#define S_NAME "alert_fast"
+#define F_NAME S_NAME ".txt"
//-------------------------------------------------------------------------
// module stuff
static const Parameter s_params[] =
{
- { "file", Parameter::PT_STRING, nullptr, "stdout",
- "name of alert file" },
+ { "file", Parameter::PT_BOOL, nullptr, "false",
+ "output to " F_NAME " instead of stdout" },
{ "packet", Parameter::PT_BOOL, nullptr, "true",
"output packet dump with alert" },
class FastModule : public Module
{
public:
- FastModule() : Module(s_name, s_help, s_params) { };
+ FastModule() : Module(S_NAME, s_help, s_params) { };
bool set(const char*, Value&, SnortConfig*);
bool begin(const char*, int, SnortConfig*);
bool end(const char*, int, SnortConfig*);
public:
- string file;
+ bool file;
unsigned long limit;
unsigned units;
bool packet;
bool FastModule::set(const char*, Value& v, SnortConfig*)
{
if ( v.is("file") )
- file = v.get_string();
+ file = v.get_bool();
else if ( v.is("packet") )
packet = v.get_bool();
bool FastModule::begin(const char*, int, SnortConfig*)
{
- file = "stdout";
+ file = false;
limit = 0;
units = 0;
packet = true;
FastLogger::FastLogger(FastModule* m)
{
- file = m->file;
+ file = m->file ? F_NAME : "stdout";
limit = m->limit;
packet = m->packet;
}
{
{
PT_LOGGER,
- s_name,
+ S_NAME,
s_help,
LOGAPI_PLUGIN_V0,
0,
using namespace std;
-static const char* s_name = "alert_full";
+#define S_NAME "alert_full"
+#define F_NAME S_NAME ".txt"
//-------------------------------------------------------------------------
// module stuff
static const Parameter s_params[] =
{
- { "file", Parameter::PT_STRING, nullptr, nullptr,
- "name of alert file" },
+ { "file", Parameter::PT_BOOL, nullptr, "false",
+ "output to " F_NAME " instread of stdout" },
{ "limit", Parameter::PT_INT, "0:", "0",
"set limit (0 is unlimited)" },
class FullModule : public Module
{
public:
- FullModule() : Module(s_name, s_help, s_params) { };
+ FullModule() : Module(S_NAME, s_help, s_params) { };
bool set(const char*, Value&, SnortConfig*);
bool begin(const char*, int, SnortConfig*);
bool end(const char*, int, SnortConfig*);
public:
- string file;
+ bool file;
unsigned long limit;
unsigned units;
};
bool FullModule::set(const char*, Value& v, SnortConfig*)
{
if ( v.is("file") )
- file = v.get_string();
+ file = v.get_bool();
else if ( v.is("limit") )
limit = v.get_long();
bool FullModule::begin(const char*, int, SnortConfig*)
{
- file = "stdout";
+ file = false;
limit = 0;
units = 0;
return true;
FullLogger::FullLogger(FullModule* m)
{
- file = m->file;
+ file = m->file ? F_NAME : "stdout";
limit = m->limit;
}
{
{
PT_LOGGER,
- s_name,
+ S_NAME,
s_help,
LOGAPI_PLUGIN_V0,
0,
using namespace std;
-static const char* s_name = "alert_test";
+#define S_NAME "alert_test"
+#define F_NAME S_NAME ".txt"
//-------------------------------------------------------------------------
// alert_test module
static const Parameter s_params[] =
{
{ "file", Parameter::PT_BOOL, nullptr, "false",
- "if true, output to alert_csv.txt instead of stdout" },
+ "output to " F_NAME " instead of stdout" },
{ "rebuilt", Parameter::PT_BOOL, nullptr, "false",
"include type:count where type is S for stream and F for frag" },
class TestModule : public Module
{
public:
- TestModule() : Module(s_name, s_help, s_params) { };
+ TestModule() : Module(S_NAME, s_help, s_params) { };
bool set(const char*, Value&, SnortConfig*);
bool begin(const char*, int, SnortConfig*);
void TestLogger::open()
{
- const char* f = (flags & TEST_FLAG_FILE) ? "alert_csv.txt" : "stdout";
+ const char* f = (flags & TEST_FLAG_FILE) ? F_NAME : "stdout";
test_file = TextLog_Init(f);
}
{
{
PT_LOGGER,
- s_name,
+ S_NAME,
s_help,
LOGAPI_PLUGIN_V0,
0,
static THREAD_LOCAL TextLog* test_file = nullptr;
+#define F_NAME "dump.txt"
//-------------------------------------------------------------------------
// module stuff
#define LOG_CODECS_HELP "log protocols in packet by layer"
static const unsigned ALERT_FLAG_MSG = 0x01;
+static const unsigned ALERT_FLAG_FILE = 0x02;
static const Parameter ex_params[] =
{
- { "file", Parameter::PT_STRING, nullptr, "stdout",
- "name of tsv alert file or 'stdout'" },
+ { "file", Parameter::PT_BOOL, nullptr, "stdout",
+ "output to " F_NAME " instead of stdout" },
{ "msg", Parameter::PT_BOOL, nullptr, "false",
"include alert msg" },
bool begin(const char*, int, SnortConfig*);
public:
- std::string file;
uint8_t flags;
};
bool LogCodecModule::set(const char*, Value& v, SnortConfig*)
{
if ( v.is("file") )
- file = v.get_string();
-
+ {
+ if ( v.get_bool() )
+ flags |= ALERT_FLAG_FILE;
+ }
else if ( v.is("msg") )
{
if ( v.get_bool() )
bool LogCodecModule::begin(const char*, int, SnortConfig*)
{
- file = "stdout";
flags = 0;
return true;
}
CodecLogger::CodecLogger(LogCodecModule* m)
{
- file = m->file;
flags = m->flags;
}
TextLog_Print(test_file, "%s\t", msg);
}
- TextLog_NewLine(test_file);
- TextLog_Print(test_file, " **** DUMPING PACKET ****");
TextLog_NewLine(test_file);
PacketManager::log_protocols(test_file, p);
TextLog_NewLine(test_file);
- TextLog_Print(test_file, " **** FINISHED DUMPING ****");
- TextLog_NewLine(test_file);
- TextLog_NewLine(test_file);
- TextLog_NewLine(test_file);
- TextLog_NewLine(test_file);
-
}
//-------------------------------------------------------------------------
static void TcpdumpRollLogFile(LtdConfig*);
-static const char* s_name = "log_tcpdump";
+#define S_NAME "log_pcap"
+#define F_NAME S_NAME "log.pcap"
//-------------------------------------------------------------------------
// module stuff
static const Parameter s_params[] =
{
- { "file", Parameter::PT_STRING, nullptr, "snort.pcap",
- "name of alert file" },
-
{ "limit", Parameter::PT_INT, "0:", "0",
"set limit (0 is unlimited)" },
class TcpdumpModule : public Module
{
public:
- TcpdumpModule() : Module(s_name, s_help, s_params) { };
+ TcpdumpModule() : Module(S_NAME, s_help, s_params) { };
bool set(const char*, Value&, SnortConfig*);
bool begin(const char*, int, SnortConfig*);
bool end(const char*, int, SnortConfig*);
public:
- string file;
unsigned limit;
unsigned units;
};
bool TcpdumpModule::set(const char*, Value& v, SnortConfig*)
{
- if ( v.is("file") )
- file = v.get_string();
-
- else if ( v.is("limit") )
+ if ( v.is("limit") )
limit = v.get_long();
else if ( v.is("units") )
bool TcpdumpModule::begin(const char*, int, SnortConfig*)
{
- file = "snort.pcap";
limit = 0;
units = 0;
return true;
}
}
-static void TcpdumpInitLogFile(LtdConfig* data, int /*nostamps?*/)
+static void TcpdumpInitLogFile(LtdConfig*, int /*nostamps?*/)
{
context.lastTime = time(NULL);
string file;
- get_instance_file(file, data->file.c_str());
+ get_instance_file(file, F_NAME);
{
pcap_t* pcap;
pcap = pcap_open_dead(dlt, DAQ_GetSnapLen());
if ( !pcap )
- FatalError("%s: can't get pcap context\n", s_name);
+ FatalError("%s: can't get pcap context\n", S_NAME);
context.dumpd = pcap ? pcap_dump_open(pcap, file.c_str()) : NULL;
if(context.dumpd == NULL)
{
FatalError("%s: can't open %s: %s\n",
- s_name, file.c_str(), pcap_geterr(pcap));
+ S_NAME, file.c_str(), pcap_geterr(pcap));
}
pcap_close(pcap);
}
PcapLogger::PcapLogger(TcpdumpModule* m)
{
config = new LtdConfig;
- config->file = m->file;
config->limit = m->limit;
}
{
{
PT_LOGGER,
- s_name,
+ S_NAME,
s_help,
LOGAPI_PLUGIN_V0,
0,
nullptr
};
#else
-const BaseApi* log_tcpdump = &tcpdump_api.base;
+const BaseApi* log_pcap = &tcpdump_api.base;
#endif
extern const BaseApi* alert_test;
extern const BaseApi* alert_unix_sock;
extern const BaseApi* log_null;
-extern const BaseApi* log_tcpdump;
+extern const BaseApi* log_pcap;
extern const BaseApi* eh_unified2;
#endif
alert_unix_sock,
// loggers
log_null,
- log_tcpdump,
+ log_pcap,
// both
eh_unified2,
using namespace std;
-static const char* s_name = "unified2";
+#define S_NAME "unified2"
+#define F_NAME S_NAME "log.u2"
/* ------------------ Data structures --------------------------*/
typedef struct _Unified2Config
{
- string base_filename;
unsigned int limit;
int nostamp;
int mpls_event_types;
static const Parameter s_params[] =
{
- { "file", Parameter::PT_STRING, nullptr, "unified2.log",
- "name of alert file" },
-
{ "limit", Parameter::PT_INT, "0:", "0",
"set limit (0 is unlimited)" },
class U2Module : public Module
{
public:
- U2Module() : Module(s_name, s_help, s_params) { };
+ U2Module() : Module(S_NAME, s_help, s_params) { };
bool set(const char*, Value&, SnortConfig*);
bool begin(const char*, int, SnortConfig*);
bool end(const char*, int, SnortConfig*);
public:
- string file;
unsigned limit;
unsigned units;
bool nostamp;
bool U2Module::set(const char*, Value& v, SnortConfig*)
{
- if ( v.is("file") )
- file = v.get_string();
-
- else if ( v.is("limit") )
+ if ( v.is("limit") )
limit = v.get_long();
else if ( v.is("units") )
bool U2Module::begin(const char*, int, SnortConfig*)
{
- file = "unified2.log";
limit = 0;
units = 0;
nostamp = ScNoOutputTimestamp();
U2Logger::U2Logger(U2Module* m)
{
- config.base_filename = m->file;
config.limit = m->limit;
config.nostamp = m->nostamp;
config.mpls_event_types = m->mpls;
int status;
std::string name;
- get_instance_file(name, config.base_filename.c_str());
+ get_instance_file(name, F_NAME);
status = SnortSnprintf(
u2.filepath, sizeof(u2.filepath), "%s", name.c_str());
{
{
PT_LOGGER,
- s_name,
+ S_NAME,
s_help,
LOGAPI_PLUGIN_V0,
0,
#include "perf_module.h"
#include "utils/util.h"
+#define PERF_FILE "perf_monitor.csv"
+#define FLOW_FILE "perf_monitor_flow.csv"
+#define FLIP_FILE "perf_monitor_flow_ip.csv"
+
//-------------------------------------------------------------------------
// perf attributes
//-------------------------------------------------------------------------
"report on qualified vs non-qualified events" },
{ "file", Parameter::PT_BOOL, nullptr, "false",
- "otuput base stats to a csv file" },
+ "otuput base stats to " PERF_FILE " instead of stdout" },
{ "flow", Parameter::PT_BOOL, nullptr, "false",
"enable traffic statistics" },
{ "flow_file", Parameter::PT_BOOL, nullptr, "false",
- "output traffic statistics to a csv file" },
+ "output traffic statistics to a " FLOW_FILE " instead of stdout" },
{ "flow_ip", Parameter::PT_BOOL, nullptr, "false",
"enable statistics on host pairs" },
{ "flow_ip_file", Parameter::PT_BOOL, nullptr, "false",
- "output host pair statistics to csv file" },
+ "output host pair statistics to " FLIP_FILE " instead of stdout" },
{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
};
else if ( v.is("file") )
{
if ( v.get_bool() )
- config.file = SnortStrdup("perf_monitor.csv");
+ config.file = SnortStrdup(PERF_FILE);
}
else if ( v.is("flow") )
{
if ( v.get_bool() )
{
config.perf_flags |= SFPERF_FLOW;
- config.flow_file = SnortStrdup("perf_monitor_flow.csv");
+ config.flow_file = SnortStrdup(FLOW_FILE);
}
}
else if ( v.is("flow_ip") )
if ( v.get_bool() )
{
config.perf_flags |= SFPERF_FLOWIP;
- config.flowip_file = SnortStrdup("perf_monitor_flow_ip.csv");
+ config.flowip_file = SnortStrdup(FLIP_FILE);
}
}
else
#define OUTPUT_AJK "unified2"
#define OUTPUT_CMG "alert_fast"
-#define OUTPUT_PCAP "log_tcpdump"
+#define OUTPUT_PCAP "log_pcap"
static std::string lua_conf;
static std::string snort_conf_dir;