Back to index

natlog  0.91.0
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PcapPacket Class Reference

#include <pcappacket.h>

List of all members.

Classes

struct  Address
struct  Ethernet_Header
struct  IP_Header
struct  TCP_Header

Public Types

enum  SizeofTCPheader { SIZEOF_ETHERNET_HEADER = IP_OFFSET, SIZEOF_TCP_HEADER = DATA_OFFSET }
enum  TCP_Flags {
  FIN = 0x01, SYN = 0x02, RST = 0x04, PUSH = 0x08,
  ACK = 0x10, URG = 0x20, ECE = 0x40, CWR = 0x80,
  TCP_Flags_MASK = FIN | SYN | RST | ACK | URG | ECE | CWR
}

Public Member Functions

 PcapPacket (struct pcap_pkthdr const &hdr, u_char const *packet)
pcap_pkthdr const & timeval () const
time_t seconds () const
suseconds_t microSeconds () const
struct in_addr & sourceAddr () const
struct in_addr & destAddr () const
u_short sourcePort () const
u_short destPort () const
Address sourceIP () const
Address destIP () const
TCP_Flags flags () const
bool flags (u_char testFlags) const
uint32_t sequenceNr () const

Private Types

enum  IP_Fragment { RESERVED = 0x8000, DONT_FRAGMENT = 0x4000, MORE_FRAGMENTS = 0x2000, MASK = 0x1fff }
enum  Offsets { ETHER_OFFSET = 0, IP_OFFSET = ETHER_OFFSET + sizeof(Ethernet_Header), TCP_OFFSET = IP_OFFSET + sizeof(IP_Header), DATA_OFFSET = TCP_OFFSET + sizeof(TCP_Header) }

Private Member Functions

template<typename Type >
Type const & get () const
Address inetAddr (struct in_addr const &addr, u_short port) const

Private Attributes

struct pcap_pkthdr & d_hdr
u_char const * d_packet

Detailed Description

Definition at line 7 of file pcappacket.h.


Class Documentation

struct PcapPacket::Ethernet_Header

Definition at line 12 of file pcappacket.h.

Class Members
u_char destMac
u_short ether_type
u_char srcMac
struct PcapPacket::IP_Header

Definition at line 26 of file pcappacket.h.

Class Members
u_short checkSum
u_short fragmentOffset
u_short identification
u_short length
u_char protocol
u_char timeToLive
u_char tos
u_char versionHdrLength
struct PcapPacket::TCP_Header

Definition at line 40 of file pcappacket.h.

Class Members
uint32_t ackNumber
u_short checkSum
u_char dataOffset
u_short destPort
u_char flags
uint32_t sequenceNr
u_short sourcePort
u_short urgentPtr
u_short window

Member Enumeration Documentation

enum PcapPacket::IP_Fragment [private]
Enumerator:
RESERVED 
DONT_FRAGMENT 
MORE_FRAGMENTS 
MASK 

Definition at line 19 of file pcappacket.h.

    {
        RESERVED =          0x8000,
        DONT_FRAGMENT =     0x4000,
        MORE_FRAGMENTS =    0x2000,
        MASK =              0x1fff
    };
enum PcapPacket::Offsets [private]
Enumerator:
ETHER_OFFSET 
IP_OFFSET 
TCP_OFFSET 
DATA_OFFSET 

Definition at line 55 of file pcappacket.h.

    {                           // the Ethernet header starts at `d_packet'
        ETHER_OFFSET =  0,       
        IP_OFFSET =     ETHER_OFFSET + sizeof(Ethernet_Header),
        TCP_OFFSET =    IP_OFFSET + sizeof(IP_Header),
        DATA_OFFSET =   TCP_OFFSET + sizeof(TCP_Header)
    };
Enumerator:
SIZEOF_ETHERNET_HEADER 
SIZEOF_TCP_HEADER 

Definition at line 64 of file pcappacket.h.

Enumerator:
FIN 
SYN 
RST 
PUSH 
ACK 
URG 
ECE 
CWR 
TCP_Flags_MASK 

Definition at line 70 of file pcappacket.h.

        {
            FIN  = 0x01,
            SYN  = 0x02,
            RST  = 0x04,
            PUSH = 0x08,
            ACK  = 0x10,
            URG  = 0x20,
            ECE  = 0x40,
            CWR  = 0x80,
            TCP_Flags_MASK = FIN | SYN | RST | ACK | URG | ECE | CWR
        };

Constructor & Destructor Documentation

PcapPacket::PcapPacket ( struct pcap_pkthdr const &  hdr,
u_char const *  packet 
)

Definition at line 3 of file pcappacket1.cc.

:
    d_hdr(hdr),
    d_packet(packet)
{
}

Member Function Documentation

struct in_addr& PcapPacket::destAddr ( ) const [read, abstract]

Here is the caller graph for this function:

u_short PcapPacket::destPort ( ) const

Here is the caller graph for this function:

Definition at line 127 of file pcappacket.h.

{
    return static_cast<TCP_Flags>(get<TCP_Header>().flags);
}

Here is the caller graph for this function:

bool PcapPacket::flags ( u_char  testFlags) const
PcapPacket::TCP_Header const & PcapPacket::get ( ) const [inline, private]

Definition at line 116 of file pcappacket.h.

{
    return *reinterpret_cast<IP_Header const *>(d_packet + IP_OFFSET);
}
Address PcapPacket::inetAddr ( struct in_addr const &  addr,
u_short  port 
) const [private]
suseconds_t PcapPacket::microSeconds ( ) const

Here is the caller graph for this function:

time_t PcapPacket::seconds ( ) const

Here is the caller graph for this function:

uint32_t PcapPacket::sequenceNr ( ) const

Here is the caller graph for this function:

struct in_addr& PcapPacket::sourceAddr ( ) const [read, abstract]

Here is the caller graph for this function:

u_short PcapPacket::sourcePort ( ) const

Here is the caller graph for this function:

pcap_pkthdr const& PcapPacket::timeval ( ) const

Here is the caller graph for this function:


Member Data Documentation

struct pcap_pkthdr& PcapPacket::d_hdr [private]

Definition at line 9 of file pcappacket.h.

u_char const* PcapPacket::d_packet [private]

Definition at line 10 of file pcappacket.h.


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