mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
This commit is contained in:
parent
9f802b2a4d
commit
fe0c22c789
240 changed files with 6823 additions and 6787 deletions
|
@ -27,7 +27,7 @@ void PcapDumper::Open()
|
|||
{
|
||||
int linktype = -1;
|
||||
|
||||
pd = pcap_open_dead(DLT_EN10MB, zeek::BifConst::Pcap::snaplen);
|
||||
pd = pcap_open_dead(DLT_EN10MB, BifConst::Pcap::snaplen);
|
||||
|
||||
if ( ! pd )
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ void PcapDumper::Open()
|
|||
|
||||
if ( exists < 0 && errno != ENOENT )
|
||||
{
|
||||
Error(zeek::util::fmt("can't stat file %s: %s", props.path.c_str(), strerror(errno)));
|
||||
Error(util::fmt("can't stat file %s: %s", props.path.c_str(), strerror(errno)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -76,13 +76,13 @@ void PcapDumper::Open()
|
|||
dumper = (pcap_dumper_t*) fopen(props.path.c_str(), "a");
|
||||
if ( ! dumper )
|
||||
{
|
||||
Error(zeek::util::fmt("can't open dump %s: %s", props.path.c_str(), strerror(errno)));
|
||||
Error(util::fmt("can't open dump %s: %s", props.path.c_str(), strerror(errno)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
props.open_time = zeek::run_state::network_time;
|
||||
props.hdr_size = zeek::Packet::GetLinkHeaderSize(pcap_datalink(pd));
|
||||
props.open_time = run_state::network_time;
|
||||
props.hdr_size = Packet::GetLinkHeaderSize(pcap_datalink(pd));
|
||||
Opened(props);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ void PcapDumper::Close()
|
|||
Closed();
|
||||
}
|
||||
|
||||
bool PcapDumper::Dump(const zeek::Packet* pkt)
|
||||
bool PcapDumper::Dump(const Packet* pkt)
|
||||
{
|
||||
if ( ! dumper )
|
||||
return false;
|
||||
|
|
|
@ -21,7 +21,7 @@ protected:
|
|||
// PktDumper interface.
|
||||
void Open() override;
|
||||
void Close() override;
|
||||
bool Dump(const zeek::Packet* pkt) override;
|
||||
bool Dump(const Packet* pkt) override;
|
||||
|
||||
private:
|
||||
Properties props;
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
|
||||
namespace zeek::plugin::detail::Zeek_Pcap {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
class Plugin : public plugin::Plugin {
|
||||
public:
|
||||
zeek::plugin::Configuration Configure() override
|
||||
plugin::Configuration Configure() override
|
||||
{
|
||||
AddComponent(new zeek::iosource::PktSrcComponent(
|
||||
"PcapReader", "pcap", zeek::iosource::PktSrcComponent::BOTH,
|
||||
zeek::iosource::pcap::PcapSource::Instantiate));
|
||||
AddComponent(new zeek::iosource::PktDumperComponent(
|
||||
"PcapWriter", "pcap", zeek::iosource::pcap::PcapDumper::Instantiate));
|
||||
AddComponent(new iosource::PktSrcComponent(
|
||||
"PcapReader", "pcap", iosource::PktSrcComponent::BOTH,
|
||||
iosource::pcap::PcapSource::Instantiate));
|
||||
AddComponent(new iosource::PktDumperComponent(
|
||||
"PcapWriter", "pcap", iosource::pcap::PcapDumper::Instantiate));
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
plugin::Configuration config;
|
||||
config.name = "Zeek::Pcap";
|
||||
config.description = "Packet acquisition via libpcap";
|
||||
return config;
|
||||
|
|
|
@ -47,7 +47,7 @@ void PcapSource::Close()
|
|||
Closed();
|
||||
|
||||
if ( Pcap::file_done )
|
||||
zeek::event_mgr.Enqueue(Pcap::file_done, zeek::make_intrusive<zeek::StringVal>(props.path));
|
||||
event_mgr.Enqueue(Pcap::file_done, make_intrusive<StringVal>(props.path));
|
||||
}
|
||||
|
||||
void PcapSource::OpenLive()
|
||||
|
@ -61,7 +61,7 @@ void PcapSource::OpenLive()
|
|||
|
||||
if ( pcap_findalldevs(&devs, errbuf) < 0 )
|
||||
{
|
||||
Error(zeek::util::fmt("pcap_findalldevs: %s", errbuf));
|
||||
Error(util::fmt("pcap_findalldevs: %s", errbuf));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ void PcapSource::OpenLive()
|
|||
return;
|
||||
}
|
||||
|
||||
if ( pcap_set_snaplen(pd, zeek::BifConst::Pcap::snaplen) )
|
||||
if ( pcap_set_snaplen(pd, BifConst::Pcap::snaplen) )
|
||||
{
|
||||
PcapError("pcap_set_snaplen");
|
||||
return;
|
||||
|
@ -136,7 +136,7 @@ void PcapSource::OpenLive()
|
|||
return;
|
||||
}
|
||||
|
||||
if ( pcap_set_buffer_size(pd, zeek::BifConst::Pcap::bufsize * 1024 * 1024) )
|
||||
if ( pcap_set_buffer_size(pd, BifConst::Pcap::bufsize * 1024 * 1024) )
|
||||
{
|
||||
PcapError("pcap_set_buffer_size");
|
||||
return;
|
||||
|
@ -157,7 +157,7 @@ void PcapSource::OpenLive()
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_PCAP_INT_H
|
||||
Info(zeek::util::fmt("pcap bufsize = %d\n", ((struct pcap *) pd)->bufsize));
|
||||
Info(util::fmt("pcap bufsize = %d\n", ((struct pcap *) pd)->bufsize));
|
||||
#endif
|
||||
|
||||
props.selectable_fd = pcap_get_selectable_fd(pd);
|
||||
|
@ -191,7 +191,7 @@ void PcapSource::OpenOffline()
|
|||
Opened(props);
|
||||
}
|
||||
|
||||
bool PcapSource::ExtractNextPacket(zeek::Packet* pkt)
|
||||
bool PcapSource::ExtractNextPacket(Packet* pkt)
|
||||
{
|
||||
if ( ! pd )
|
||||
return false;
|
||||
|
@ -210,11 +210,11 @@ bool PcapSource::ExtractNextPacket(zeek::Packet* pkt)
|
|||
case PCAP_ERROR: // -1
|
||||
// Error occurred while reading the packet.
|
||||
if ( props.is_live )
|
||||
zeek::reporter->Error("failed to read a packet from %s: %s",
|
||||
props.path.data(), pcap_geterr(pd));
|
||||
reporter->Error("failed to read a packet from %s: %s",
|
||||
props.path.data(), pcap_geterr(pd));
|
||||
else
|
||||
zeek::reporter->FatalError("failed to read a packet from %s: %s",
|
||||
props.path.data(), pcap_geterr(pd));
|
||||
reporter->FatalError("failed to read a packet from %s: %s",
|
||||
props.path.data(), pcap_geterr(pd));
|
||||
return false;
|
||||
case 0:
|
||||
// Read from live interface timed out (ok).
|
||||
|
@ -223,7 +223,7 @@ bool PcapSource::ExtractNextPacket(zeek::Packet* pkt)
|
|||
// Read a packet without problem.
|
||||
break;
|
||||
default:
|
||||
zeek::reporter->InternalError("unhandled pcap_next_ex return value: %d", res);
|
||||
reporter->InternalError("unhandled pcap_next_ex return value: %d", res);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ bool PcapSource::SetFilter(int index)
|
|||
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
zeek::iosource::detail::BPF_Program* code = GetBPFFilter(index);
|
||||
iosource::detail::BPF_Program* code = GetBPFFilter(index);
|
||||
|
||||
if ( ! code )
|
||||
{
|
||||
|
@ -328,12 +328,12 @@ void PcapSource::PcapError(const char* where)
|
|||
std::string location;
|
||||
|
||||
if ( where )
|
||||
location = zeek::util::fmt(" (%s)", where);
|
||||
location = util::fmt(" (%s)", where);
|
||||
|
||||
if ( pd )
|
||||
Error(zeek::util::fmt("pcap_error: %s%s", pcap_geterr(pd), location.c_str()));
|
||||
Error(util::fmt("pcap_error: %s%s", pcap_geterr(pd), location.c_str()));
|
||||
else
|
||||
Error(zeek::util::fmt("pcap_error: not open%s", location.c_str()));
|
||||
Error(util::fmt("pcap_error: not open%s", location.c_str()));
|
||||
|
||||
Close();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
|
||||
namespace zeek::iosource::pcap {
|
||||
|
||||
class PcapSource : public zeek::iosource::PktSrc {
|
||||
class PcapSource : public PktSrc {
|
||||
public:
|
||||
PcapSource(const std::string& path, bool is_live);
|
||||
~PcapSource() override;
|
||||
|
@ -23,7 +23,7 @@ protected:
|
|||
// PktSrc interface.
|
||||
void Open() override;
|
||||
void Close() override;
|
||||
bool ExtractNextPacket(zeek::Packet* pkt) override;
|
||||
bool ExtractNextPacket(Packet* pkt) override;
|
||||
void DoneWithPacket() override;
|
||||
bool PrecompileFilter(int index, const std::string& filter) override;
|
||||
bool SetFilter(int index) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue