mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
Moving Pkt{Src,Dumper} a directory level up.
Also renaming PktSourceComponent to PktSrcComponent.
This commit is contained in:
parent
ecf1e32f60
commit
caa55ad352
23 changed files with 274 additions and 311 deletions
79
src/iosource/PktDumper.cc
Normal file
79
src/iosource/PktDumper.cc
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "PktDumper.h"
|
||||
|
||||
using namespace iosource;
|
||||
|
||||
PktDumper::PktDumper()
|
||||
{
|
||||
is_open = false;
|
||||
errmsg = "";
|
||||
}
|
||||
|
||||
PktDumper::~PktDumper()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& PktDumper::Path() const
|
||||
{
|
||||
return props.path;
|
||||
}
|
||||
|
||||
bool PktDumper::IsOpen() const
|
||||
{
|
||||
return is_open;
|
||||
}
|
||||
|
||||
double PktDumper::OpenTime() const
|
||||
{
|
||||
return is_open ? props.open_time : 0;
|
||||
}
|
||||
|
||||
bool PktDumper::IsError() const
|
||||
{
|
||||
return errmsg.size();
|
||||
}
|
||||
|
||||
const std::string& PktDumper::ErrorMsg() const
|
||||
{
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
int PktDumper::HdrSize() const
|
||||
{
|
||||
return is_open ? props.hdr_size : -1;
|
||||
}
|
||||
|
||||
bool PktDumper::Record(const Packet* pkt)
|
||||
{
|
||||
return Dump(pkt);
|
||||
}
|
||||
|
||||
void PktDumper::Opened(const Properties& arg_props)
|
||||
{
|
||||
is_open = true;
|
||||
props = arg_props;
|
||||
DBG_LOG(DBG_PKTIO, "Opened dumper %s", props.path.c_str());
|
||||
}
|
||||
|
||||
void PktDumper::Closed()
|
||||
{
|
||||
is_open = false;
|
||||
props.path = "";
|
||||
DBG_LOG(DBG_PKTIO, "Closed dumper %s", props.path.c_str());
|
||||
}
|
||||
|
||||
void PktDumper::Error(const std::string& msg)
|
||||
{
|
||||
errmsg = msg;
|
||||
|
||||
DBG_LOG(DBG_PKTIO, "Error with dumper %s: %s",
|
||||
IsOpen() ? props.path.c_str() : "<not open>",
|
||||
msg.c_str());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue