Back to index

natlog  0.91.0
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
PcapFilter Struct Reference

#include <pcapfilter.h>

Inheritance diagram for PcapFilter:
Inheritance graph
[legend]
Collaboration diagram for PcapFilter:
Collaboration graph
[legend]

List of all members.

Public Types

typedef PcapRecord::Type Type

Public Member Functions

 PcapFilter (char const *device, PcapRecord &record, Type type)
void operator() ()

Private Member Functions

void inDevice (PcapPacket const &packet)
void outDevice (PcapPacket const &packet)
void saveAdd (PcapPacket const &packet)
void saveRemove (PcapPacket const &packet)
int shiftPacketBegin () const
virtual void signaled (size_t signum) override

Static Private Member Functions

static void callback (PcapFilter *pf, struct pcap_pkthdr const *hdr, u_char const *bytes)

Private Attributes

std::string d_device
PcapRecordd_record
Type d_type
Pcap d_pcap

Static Private Attributes

static char s_filterExpr [] = "tcp[13] == 0x11 )"
static std::mutex s_recordMutex

Detailed Description

Definition at line 12 of file pcapfilter.h.


Member Typedef Documentation

Definition at line 14 of file pcapfilter.h.


Constructor & Destructor Documentation

PcapFilter::PcapFilter ( char const *  device,
PcapRecord record,
Type  type 
)

Definition at line 3 of file pcapfilter1.cc.

:
    d_device(device),
    d_record(record),
    d_type(type),
    d_pcap(device, false, PcapPacket::SIZEOF_TCP_HEADER)
{
    d_pcap.filter(s_filterExpr);
}

Here is the call graph for this function:


Member Function Documentation

void PcapFilter::callback ( PcapFilter pf,
struct pcap_pkthdr const *  hdr,
u_char const *  bytes 
) [static, private]

Definition at line 3 of file callback.cc.

{
    PcapPacket packet(*hdr, packetBytes - pf->shiftPacketBegin());

    if (pf->d_type == PcapRecord::IN)
        pf->inDevice(packet);
    else 
        pf->outDevice(packet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PcapFilter::inDevice ( PcapPacket const &  packet) [private]

Definition at line 3 of file indevice.cc.

{
    if (packet.flags(PcapPacket::SYN | PcapPacket::ACK))
        saveAdd(packet);    // src and dest are available
    else if (packet.flags(PcapPacket::FIN | PcapPacket::ACK))
        saveRemove(packet);    
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PcapFilter::operator() ( )

Definition at line 3 of file operatorfun.cc.

{
    d_pcap.loop(reinterpret_cast<u_char *>(this), 
                reinterpret_cast<pcap_handler>(callback));
}

Here is the call graph for this function:

void PcapFilter::outDevice ( PcapPacket const &  packet) [private]

Definition at line 3 of file outdevice.cc.

{
    if (packet.flags(PcapPacket::SYN | PcapPacket::ACK))
        saveAdd(packet);       // via and dest are available
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PcapFilter::saveAdd ( PcapPacket const &  packet) [private]

Definition at line 3 of file saveadd.cc.

{
    lock_guard<mutex> guard(s_recordMutex);

    d_record.add(packet, d_type);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PcapFilter::saveRemove ( PcapPacket const &  packet) [private]

Definition at line 3 of file saveremove.cc.

{
    lock_guard<mutex> guard(s_recordMutex);

    d_record.remove(packet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PcapFilter::shiftPacketBegin ( ) const [private]

Here is the caller graph for this function:

void PcapFilter::signaled ( size_t  signum) [override, private, virtual]

Implements SignalHandler.

Definition at line 3 of file signaled.cc.

{
    d_pcap.stop();
}

Here is the call graph for this function:


Member Data Documentation

std::string PcapFilter::d_device [private]

Definition at line 17 of file pcapfilter.h.

Definition at line 20 of file pcapfilter.h.

Definition at line 18 of file pcapfilter.h.

Definition at line 19 of file pcapfilter.h.

char PcapFilter::s_filterExpr = "tcp[13] == 0x11 )" [static, private]

Definition at line 22 of file pcapfilter.h.

mutex PcapFilter::s_recordMutex [static, private]

Definition at line 23 of file pcapfilter.h.


The documentation for this struct was generated from the following files: