Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ssobjects::PacketBufferHeader Class Reference

Header information that is sent with every packet. More...

#include <packetbuffer.h>

List of all members.

Public Methods

 PacketBufferHeader ()
 PacketBufferHeader (unsigned16 wCommand, unsigned16 wCookie)
void makeNetworkReady (bool bOverrideFailsave=false)
 Convert header to network byte order (htonl). More...

void makeHostReady (bool bOverrideFailsafe=false)
 Convert header from network byte order (ntohl). More...

unsigned8getHeader () const
 Returns a pointer to the header data. More...

unsigned32 getBufferSize () const
 Returns the current buffer size. More...

unsigned16 getCookie () const
 Returns the cookie. More...

unsigned16 getCmd () const
 Returns the command. More...

void reset ()
 Puts header to initial state. More...

bool isValid ()
 Verify this header has valid values. More...

bool isNetworkReady () const
 Returns true if the header is in network byte order, false otherwise. More...


Static Public Methods

unsigned32 getMaxPacketSize ()
 Get the max allowed packet size. More...

unsigned32 setMaxPacketSize (unsigned32)
 Set what the limit should be. More...

unsigned32 getSize ()
 Returns the actual size of the header. More...


Public Attributes

typeBufferSize m_nBufferSize
 How much data is in this packet, not including the header. More...

typeCookie m_wCookie
 Special constant value used to determin if the packet is valid. Not to be mistaken for cookies in browsers. More...

typeCommand m_wCommand
 The command, or type of packet this is. More...

bool m_bNetworkReady
 True when the header is in network byte order, false otherwise. More...


Static Public Attributes

unsigned32 m_nMaxPacketSize = 1500000
 How big the buffer is allowed to get. More...


Detailed Description

Header information that is sent with every packet.

The header is what tells you what command/type of packet this is, and how big it is. The header is a vital part of the PacketBuffer class.


Constructor & Destructor Documentation

ssobjects::PacketBufferHeader::PacketBufferHeader   [inline]
 

ssobjects::PacketBufferHeader::PacketBufferHeader unsigned16    wCommand,
unsigned16    wCookie
[inline]
 


Member Function Documentation

unsigned32 ssobjects::PacketBufferHeader::getBufferSize   const [inline]
 

Returns the current buffer size.

unsigned16 ssobjects::PacketBufferHeader::getCmd   const [inline]
 

Returns the command.

unsigned16 ssobjects::PacketBufferHeader::getCookie   const [inline]
 

Returns the cookie.

unsigned8* ssobjects::PacketBufferHeader::getHeader   const [inline]
 

Returns a pointer to the header data.

unsigned32 PacketBufferHeader::getMaxPacketSize   [static]
 

Get the max allowed packet size.

unsigned32 ssobjects::PacketBufferHeader::getSize   [inline, static]
 

Returns the actual size of the header.

bool ssobjects::PacketBufferHeader::isNetworkReady   const [inline]
 

Returns true if the header is in network byte order, false otherwise.

bool PacketBufferHeader::isValid  
 

Verify this header has valid values.

Does some simple tests to see if this header is valid. First checks to see if the cookie is our constant cookie value of PacketBuffer::pkCookie. Then checks if the command is non-zero. Lastly, we check if the buffersize value is better then the max packet size. If all these pass, then we can assume that the header is probably safe.

void PacketBufferHeader::makeHostReady bool    bOverrideFailsafe = false
 

Convert header from network byte order (ntohl).

Convert the header longs and shorts into host byte order.

Parameters:
bOverrideFailsafe  [in] false (default) will not reorder the bytes if you have already. true if you want to anyway.
Note:
Used only in by BufferedSocket::parsForPacket() when a packet is just read in. The new object will be in host byte order, and the data read in will be in network byte order. So we need to force into host byte order even thought the object thinks it is already like that.

void PacketBufferHeader::makeNetworkReady bool    bOverrideFailsafe = false
 

Convert header to network byte order (htonl).

Convert the header longs and shorts into network byte order blah blah blah.

Parameters:
bOverrideFailsafe  [in] false (default) will not reorder the bytes if you have already. true if you want to anyway.

void PacketBufferHeader::reset  
 

Puts header to initial state.

Make the header host-byte ordered, and reset the buffer size to zero.

unsigned32 PacketBufferHeader::setMaxPacketSize unsigned32    newSize [static]
 

Set what the limit should be.

Sets the max packet size to newSize. Does nothing to the actual packet buffer. This is just a number we use for reference.


Member Data Documentation

bool ssobjects::PacketBufferHeader::m_bNetworkReady
 

True when the header is in network byte order, false otherwise.

typeBufferSize ssobjects::PacketBufferHeader::m_nBufferSize
 

How much data is in this packet, not including the header.

unsigned32 PacketBufferHeader::m_nMaxPacketSize = 1500000 [static]
 

How big the buffer is allowed to get.

typeCommand ssobjects::PacketBufferHeader::m_wCommand
 

The command, or type of packet this is.

typeCookie ssobjects::PacketBufferHeader::m_wCookie
 

Special constant value used to determin if the packet is valid. Not to be mistaken for cookies in browsers.


The documentation for this class was generated from the following files:
Generated on Thu Nov 8 12:39:29 2001 for SimpleServerObjects by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001