WpcIpPacket Class Reference
[Classes hierarchy]

Implements protocol-specific fields for IP packets. More...

Inheritance diagram for WpcIpPacket:

WpcPacket WpcIcmpPacket WpcTcpPacket WpcUdpPacket

List of all members.

Public Member Functions

 WpcIpPacket (WpcPacket const &packet)
 Creates a WpcIpPacket object as a copy from another.
 WpcIpPacket (unsigned char *data, int len)
 Creates a WpcPacket from raw data.
 WpcIpPacket (int size=sizeof(WPC_IP_HDR))
 Creates an empty IP packet.
 WpcIpPacket (WpcAddress &target, unsigned int payloadSize=0)
 Creates an empty IP packet.
virtual bool ReadyToSend (WpcAdapter *adapter)
 Prepare data to send.
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 ver ()
 Gets IP version.
void ver (unsigned char val)
 Sets IP version.
unsigned char tos ()
 Gets ToS.
void tos (unsigned char val)
 Sets ToS.
unsigned short len ()
 Gets IP packet length.
void len (unsigned short val)
 Sets IP packet length.
unsigned short id ()
 Gets ID.
void id (unsigned short val)
 Sets ID.
unsigned short fos ()
 Gets FoS.
void fos (unsigned short val)
 Sets FoS.
unsigned char ttl ()
 Gets TTL.
void ttl (unsigned char val)
 Sets TTL.
unsigned char proto ()
 Gets IP protocol.
void proto (unsigned char val)
 Sets IP protocol.
unsigned short chksum ()
 Gets checksum.
void chksum (unsigned short val)
 Sets checksum.
unsigned int src ()
 Gets source address.
void src (unsigned int val)
 Sets source address.
void src (WpcAddress &val)
 Sets source address.
unsigned int dst ()
 Gets destination address.
void dst (unsigned int val)
 Sets destination address.
void dst (WpcAddress &val)
 Sets source address.

Protected Attributes

WPC_IP_HDRm_ipHdr
 Maps data to IP header structure.


Detailed Description

Implements protocol-specific fields for IP packets.

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

Examples:

wpcPacket.cpp.


Constructor & Destructor Documentation

WpcIpPacket::WpcIpPacket ( WpcPacket const &  packet  )  [inline]

Creates a WpcIpPacket object as a copy from another.

WpcIpPacket::WpcIpPacket ( unsigned char *  data,
int  len 
) [inline]

Creates a WpcPacket from raw data.

WpcIpPacket::WpcIpPacket ( int  size = sizeof(WPC_IP_HDR)  )  [inline]

Creates an empty IP packet.

WpcIpPacket::WpcIpPacket ( WpcAddress target,
unsigned int  payloadSize = 0 
)

Creates an empty IP packet.

Packet will be created pointed to the target address. For the created packet options will be set: WPC_PKT_IP_SRC, WPC_PKT_IP_DST, WPC_PKT_ETH_DST, WPC_PKT_IP_CHKSUM. I.e. by default packet will automatically sets the IP and hardware addresses of the source and destination and calculates IP checksum.

Parameters:
target WpcAddress of the target system
payloadSize additional space in the packet, except IP header


Member Function Documentation

void WpcIpPacket::chksum ( unsigned short  val  ) 

Sets checksum.

Reimplemented in WpcTcpPacket, and WpcIcmpPacket.

unsigned short WpcIpPacket::chksum (  ) 

Gets checksum.

Reimplemented in WpcTcpPacket, and WpcIcmpPacket.

void WpcIpPacket::dst ( WpcAddress val  ) 

Sets source address.

void WpcIpPacket::dst ( unsigned int  val  ) 

Sets destination address.

unsigned int WpcIpPacket::dst (  ) 

Gets destination address.

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

Dumps packet data to string representation.

Reimplemented from WpcPacket.

Reimplemented in WpcTcpPacket, and WpcIcmpPacket.

void WpcIpPacket::fos ( unsigned short  val  ) 

Sets FoS.

unsigned short WpcIpPacket::fos (  ) 

Gets FoS.

unsigned char * WpcIpPacket::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 from WpcPacket.

Reimplemented in WpcTcpPacket, and WpcIcmpPacket.

void WpcIpPacket::id ( unsigned short  val  ) 

Sets ID.

Reimplemented in WpcIcmpPacket.

unsigned short WpcIpPacket::id (  ) 

Gets ID.

Reimplemented in WpcIcmpPacket.

void WpcIpPacket::len ( unsigned short  val  ) 

Sets IP packet length.

unsigned short WpcIpPacket::len (  ) 

Gets IP packet length.

int WpcIpPacket::PayloadLength ( void   )  [virtual]

Gets packet payload length.

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

Reimplemented from WpcPacket.

Reimplemented in WpcTcpPacket, and WpcIcmpPacket.

void WpcIpPacket::proto ( unsigned char  val  ) 

Sets IP protocol.

unsigned char WpcIpPacket::proto (  ) 

Gets IP protocol.

bool WpcIpPacket::ReadyToSend ( WpcAdapter adapter  )  [virtual]

Prepare data to send.

Calculate IP checksum.

Returns:
true if packet is ready to send false otherwise

Todo:
implement IP checksum calculation and options processing

Reimplemented from WpcPacket.

Reimplemented in WpcTcpPacket, and WpcIcmpPacket.

void WpcIpPacket::src ( WpcAddress val  ) 

Sets source address.

void WpcIpPacket::src ( unsigned int  val  ) 

Sets source address.

unsigned int WpcIpPacket::src (  ) 

Gets source address.

void WpcIpPacket::tos ( unsigned char  val  ) 

Sets ToS.

unsigned char WpcIpPacket::tos (  ) 

Gets ToS.

void WpcIpPacket::ttl ( unsigned char  val  ) 

Sets TTL.

unsigned char WpcIpPacket::ttl (  ) 

Gets TTL.

void WpcIpPacket::ver ( unsigned char  val  ) 

Sets IP version.

unsigned char WpcIpPacket::ver (  ) 

Gets IP version.


Member Data Documentation

Maps data to IP header structure.



 
©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