WpcPacket Class Reference
[Classes hierarchy]

Base class for libpcap packet. More...

Inheritance diagram for WpcPacket:

WpcArpPacket WpcIpPacket WpcIcmpPacket WpcTcpPacket WpcUdpPacket

List of all members.

Public Member Functions

 WpcPacket ()
 Creates an empty WpcPacket.
 WpcPacket (WpcPacket const &packet)
 Creates a WpcPacket object as a copy from another.
 WpcPacket (unsigned char *data, int len)
 Creates a WpcPacket from raw data.
 WpcPacket (int len)
 Creates an empty WpcPacket required length.
WpcPacketoperator= (WpcPacket &packet)
 Assign another WpcPacket object's contents to this one.
virtual ~WpcPacket ()
 Destroys the packet object.
int Length ()
 Gets packet length.
void Assign (pcap_pkthdr hdr, unsigned char *data)
 Sets data from raw array.
void Assign (bpf_u_int32 pktlen, unsigned char *data)
 Sets data from raw array.
virtual int PayloadLength ()
 Gets packet payload length.
virtual string & Dump (bool printPayload=true)
 Dumps packet data to string representation.
virtual unsigned char * GetData ()
 Gets a pointer to the data (payload) of the WpcPacket.
unsigned char * GetBuffer ()
 Gets a pointer to the packet buffer.
pcap_pkthdr GetHeader ()
 Gets the header of the packet.
unsigned char & operator[] (unsigned int pos)
 Direct access to packet data bytes This operator allows the direct access to whole packet data including headers, not only payload. To obtain payload data get pointer from GetData function.
void Resize (unsigned int newLen)
 Change packet data length.
virtual bool ReadyToSend (WpcAdapter *adapter=NULL)
 Prepare data to send.
WpcMacAddreth_src ()
 Gets source Ethernet MAC address.
void eth_src (WpcMacAddr &addr)
 Sets source Ethernet MAC address.
void eth_src (WpcAdapter &adapter)
 Sets source Ethernet MAC address.
WpcMacAddreth_dst ()
 Gets destination Ethernet MAC address.
void eth_dst (WpcMacAddr &addr)
 Sets destination Ethernet MAC address.
unsigned short eth_proto ()
 Gets Ethernet protocol number.
void eth_proto (unsigned short proto)
 Sets Ethernet protocol number.
bool GetOption (WpcPktOptions code)
 Gets packet post-processing option.
void SetOption (WpcPktOptions code, bool state=true)
 Sets packet post-processing option.
void ResetOption (WpcPktOptions code)
 Clears packet post-processing option.

Protected Attributes

WPC_ETH_HDRm_ethHdr
 Maps data to ETH header structure.
pcap_pkthdr m_header
 libpcap's packet header
unsigned int m_dataLen
 Packet buffer length.
unsigned char * m_data
 Packet buffer.
unsigned int m_options
 Packet post-processing options.


Detailed Description

Base class for libpcap packet.

All properties to access Ethernet-header fields are have one important issue:

Examples:

wpcCapture.cpp, and wpcPacket.cpp.


Constructor & Destructor Documentation

WpcPacket::WpcPacket (  ) 

Creates an empty WpcPacket.

WpcPacket::WpcPacket ( WpcPacket const &  packet  ) 

Creates a WpcPacket object as a copy from another.

WpcPacket::WpcPacket ( unsigned char *  data,
int  len 
)

Creates a WpcPacket from raw data.

WpcPacket::WpcPacket ( int  len  ) 

Creates an empty WpcPacket required length.

WpcPacket::~WpcPacket (  )  [virtual]

Destroys the packet object.


Member Function Documentation

void WpcPacket::Assign ( bpf_u_int32  pktlen,
unsigned char *  data 
)

Sets data from raw array.

void WpcPacket::Assign ( pcap_pkthdr  hdr,
unsigned char *  data 
)

Sets data from raw array.

string & WpcPacket::Dump ( bool  printPayload = true  )  [virtual]

Dumps packet data to string representation.

Reimplemented in WpcIpPacket, WpcArpPacket, WpcTcpPacket, and WpcIcmpPacket.

Examples:
wpcCapture.cpp, and wpcPacket.cpp.

void WpcPacket::eth_dst ( WpcMacAddr addr  ) 

Sets destination Ethernet MAC address.

WpcMacAddr & WpcPacket::eth_dst (  ) 

Gets destination Ethernet MAC address.

Examples:
wpcPacket.cpp.

void WpcPacket::eth_proto ( unsigned short  proto  ) 

Sets Ethernet protocol number.

unsigned short WpcPacket::eth_proto (  ) 

Gets Ethernet protocol number.

Examples:
wpcPacket.cpp.

void WpcPacket::eth_src ( WpcAdapter adapter  ) 

Sets source Ethernet MAC address.

void WpcPacket::eth_src ( WpcMacAddr addr  ) 

Sets source Ethernet MAC address.

WpcMacAddr & WpcPacket::eth_src (  ) 

Gets source Ethernet MAC address.

Examples:
wpcPacket.cpp.

unsigned char* WpcPacket::GetBuffer (  )  [inline]

Gets a pointer to the packet buffer.

This function returns whole packet data, include headers. To obtain packet payload call the GetData function.

Returns:
pointer to the packet payload, or NULL if the packet size less than header size

unsigned char * WpcPacket::GetData (  )  [virtual]

Gets a pointer to the data (payload) of the WpcPacket.

Returns:
pointer to the packet payload, or NULL if the packet size less than header size

Reimplemented in WpcIpPacket, WpcArpPacket, WpcTcpPacket, and WpcIcmpPacket.

Examples:
wpcPacket.cpp.

pcap_pkthdr WpcPacket::GetHeader (  )  [inline]

Gets the header of the packet.

bool WpcPacket::GetOption ( WpcPktOptions  code  )  [inline]

Gets packet post-processing option.

If multiple options are given (by logical OR operation) function returns true if ALL these options are sets to true

int WpcPacket::Length (  )  [inline]

Gets packet length.

Examples:
wpcPacket.cpp.

WpcPacket & WpcPacket::operator= ( WpcPacket packet  ) 

Assign another WpcPacket object's contents to this one.

unsigned char & WpcPacket::operator[] ( unsigned int  pos  ) 

Direct access to packet data bytes This operator allows the direct access to whole packet data including headers, not only payload. To obtain payload data get pointer from GetData function.

Exceptions:
WpcError if index is out of range

int WpcPacket::PayloadLength ( void   )  [virtual]

Gets packet payload length.

Returns:
Packet payload length, or NULL if the packet size less than header size

Reimplemented in WpcIpPacket, WpcArpPacket, WpcTcpPacket, and WpcIcmpPacket.

bool WpcPacket::ReadyToSend ( WpcAdapter adapter = NULL  )  [virtual]

Prepare data to send.

Prepare WpcPacket to send through network. Implements "last minute" checks and necessary processing (checksum calculation, for example)

Returns:
true if packet is ready to send false otherwise

Reimplemented in WpcIpPacket, WpcTcpPacket, and WpcIcmpPacket.

void WpcPacket::ResetOption ( WpcPktOptions  code  )  [inline]

Clears packet post-processing option.

If multiple options are given (by logical OR operation) function sets ALL these options to false

void WpcPacket::Resize ( unsigned int  newLen  ) 

Change packet data length.

Exceptions:
WpcError on memory operations error
Examples:
wpcPacket.cpp.

void WpcPacket::SetOption ( WpcPktOptions  code,
bool  state = true 
)

Sets packet post-processing option.

If multiple options are given (by logical OR operation) function sets ALL these options to true


Member Data Documentation

unsigned char* WpcPacket::m_data [protected]

Packet buffer.

unsigned int WpcPacket::m_dataLen [protected]

Packet buffer length.

Maps data to ETH header structure.

pcap_pkthdr WpcPacket::m_header [protected]

libpcap's packet header

unsigned int WpcPacket::m_options [protected]

Packet post-processing options.



 
©2009 Positive Technologies
 
Generated on Fri May 22 18:17:01 2009 for wpcObj by 
 
 
1.5.7
 
Get wpcObj at SourceForge.net. Fast, secure and Free Open Source software downloads