CMessage Class Reference

platform independent message object, used as transport buffer for the NetworkQueue More...

#include <Message.h>

List of all members.

Public Member Functions

 CMessage ()
 Constructor.
 ~CMessage ()
 Destructor.
void clear ()
 reset contents of message
INT32 check_int () const
 check for valid public fields
bool check_bool () const
 check for valid public fields
bool isResponse () const
 check, if message is a response packet
bool isRequest () const
 check, if message is a request packet
bool isTelegram () const
 check, if message is a telegram packet
bool getSenderIPandPort (UINT32 &ip_peer_hostorder, UINT16 &port_peer_hostorder)
 get Sender IP and Port from CMessage
void setType (UINT8 aPhysicalType, UINT8 aLogicalType)
 set physical and logical paket type
UINT8 getPhysicalType ()
 get the physical paket type
UINT8 getLogicalType ()
 get the logical paket type
reading data
bool read_BINARY (UINT16 varid, UINT8 *target_buffer, UINT32 &target_buffer_size_bytes)
 read a binary object from the CMessage Object
bool read_FLOAT (UINT16 varid, FLOAT &target_buffer)
 read a float value from the CMessage Object
bool read_DOUBLE (UINT16 varid, DOUBLE &target_buffer)
 read a double float value from the CMessage Object
bool read_INT8 (UINT16 varid, INT8 &target_buffer)
 read a 8 bit signed value from the CMessage Object
bool read_UINT8 (UINT16 varid, UINT8 &target_buffer)
 read a 8 bit unsigned value from the CMessage Object
bool read_INT16 (UINT16 varid, INT16 &target_buffer)
 read a 16 bit signed value from the CMessage Object
bool read_UINT16 (UINT16 varid, UINT16 &target_buffer)
 read a 16 bit unsigned value from the CMessage Object
bool read_INT32 (UINT16 varid, INT32 &target_buffer)
 read a 32 bit signed value from the CMessage Object
bool read_UINT32 (UINT16 varid, UINT32 &target_buffer)
 read a 32 bit unsigned value from the CMessage Object
bool read_TEXT (UINT16 varid, UINT8 *target_buffer, UINT32 &target_buffer_size_bytes)
 read a text string from the CMessage Object
bool read (UINT16 varid, UINT16 vartype, VOIDP target_buffer, UINT32 &target_buffer_num_elements)
 general read function for non standard var types
writinge data
bool write_BINARY (UINT16 varid, const UINT8 *source_buffer, UINT32 source_buffer_size_bytes)
 write a binary object into the CMessage Object
bool write_FLOAT (UINT16 varid, FLOAT source_buffer)
 write a float value into the CMessage Object
bool write_DOUBLE (UINT16 varid, DOUBLE source_buffer)
 write a double float value into the CMessage Object
bool write_INT8 (UINT16 varid, INT8 source_buffer)
 write a signed 8bit value into the CMessage Object
bool write_UINT8 (UINT16 varid, UINT8 source_buffer)
 write a unsigned 8bit value into the CMessage Object
bool write_INT16 (UINT16 varid, INT16 source_buffer)
 write a signed 16bit value into the CMessage Object
bool write_UINT16 (UINT16 varid, UINT16 source_buffer)
 write a unsigned 16bit value into the CMessage Object
bool write_INT32 (UINT16 varid, INT32 source_buffer)
 write a signed 32bit value into the CMessage Object
bool write_UINT32 (UINT16 varid, UINT32 source_buffer)
 write a unsigned 32bit value into the CMessage Object
bool write_TEXT (UINT16 varid, const UINT8 *source_buffer, UINT32 source_buffer_size_bytes)
 write a text string from the CMessage Object
bool write (UINT16 varid, UINT16 vartype, const VOIDP buffer, const UINT32 elements_in_buffer)
 general write function for non standard var types

Public Attributes

public variables free to use for the user code
UINT32 optAuthorisationID
 authorisation ID, an optional parameter to use for paket management in user code
UINT16 optSubsystemDeviceID
 subsystem device id, an optional parameter to use for paket management in user code
UINT16 optPacketTypeParam
 packet type additional parameter

Private Member Functions

bool matchAckPacket (const CMessage &ack_packet)
void constructAckPacket (const CMessage &template_packet)
bool isAckPacket () const
bool wantAckPacket () const
UINT32 sizeof_per_element (const UINT16 vartype)
bool ImportMessageFromPacketBuffer (const UINT8 *buffer, INT32 buffer_length, UINT32 ip_hostorder, UINT16 port_hostorder)
bool ExportMessageToPacketBuffer (UINT8 *buffer, INT32 &buffer_length)
void copy_data_depending_on_vartype (UINT32 *tgtbufpos, const UINT32 *srcbufpos, UINT32 num_elements, UINT16 vartype)
bool check_buffer_against_vartype (UINT16 vartype, const VOIDP buffer, UINT32 buflength)

Private Attributes

UINT8 mandatoryLogicalPacketType
UINT8 mandatoryPhysicalPacketType
INT32 payload_first_offset
UINT8 payload_buffer [(MAX_NUM_ENTRIES *MIN_SIZE_DATA)+SIZE_ADD_LINKEDLIST]
UINT16 payload_buffer_left
UINT16 payload_curlength_net
UINT16 payload_num_elements
UINT16 internalPacketIndex
UINT16 internalRequestID
UINT16 payload_maxlength_net
UINT16 internalPacketMagic
UINT16 internalPacketSize
UINT16 internalPacketVersion
UINT16 internalPacketSpecialBits
UINT16 internalPacketTail
bool message_came_from_set
UINT32 message_came_from_ip
UINT16 message_came_from_port
UINT32 message_sendto_ip_host
UINT16 message_sendto_port_host
HANDLE notifySemaphoreOnReceiveAnswer
HANDLE notifySemaphoreOnReceiveAck

Friends

class CNetworkQueue
class CPacketQueue


Detailed Description

platform independent message object, used as transport buffer for the NetworkQueue

Date:
SW (Updated August 2007)

Important Notes

Platform dependend data encoding

For performance and MMU / absence of MMU reasons on RISC platform, any 'net data' in the block with less than four bytes is padded to four bytes.

This is because of Sparc core dump if unaligned access to e.g. 4-byte integer. This is because NIOS2 processor (little endian RISC) does not contain an MMU and exhibits the same behaviour as Sparc CPU, but there is no 'core dump' but unaligned memory access is shifted to the last/next address (can't remember correctly) - so basically one is writing at a wrong location in memory - possibly overwriting data!

Fragmentation may happen the more times data is overwritten by bigger data! There is no reorganization in this linked list if gaps are formed.

Definition at line 50 of file Message.h.


Constructor & Destructor Documentation

CMessage::CMessage (  ) 

Constructor.

Definition at line 16 of file Message.cpp.

Here is the call graph for this function:

CMessage::~CMessage (  ) 

Destructor.

Definition at line 22 of file Message.cpp.

Here is the call graph for this function:


Member Function Documentation

void CMessage::clear (  ) 

reset contents of message

Definition at line 146 of file Message.cpp.

Referenced by CMessage(), constructAckPacket(), CMessagePool::putback_reference(), SimulateRemotePeer(), and ~CMessage().

Here is the caller graph for this function:

INT32 CMessage::check_int (  )  const

check for valid public fields

Returns:
exact error code

Definition at line 186 of file Message.cpp.

Referenced by check_bool(), CNetworkQueue::sendMsgTo(), and CNetworkQueue::sendMsgToInternal().

Here is the caller graph for this function:

bool CMessage::check_bool (  )  const

check for valid public fields

Return values:
true public fields are valid

Definition at line 224 of file Message.cpp.

Referenced by ImportMessageFromPacketBuffer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::isResponse (  )  const

check, if message is a response packet

Return values:
true packet is a response paket

Definition at line 55 of file Message.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask().

Here is the caller graph for this function:

bool CMessage::isRequest (  )  const

check, if message is a request packet

Return values:
true packet is a request paket

Definition at line 38 of file Message.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask(), CNetworkQueue::sendMsgTo(), CNetworkQueue::SendProcessTask(), CNetworkQueue::sendRecvMsg(), and SimulateRemotePeer().

Here is the caller graph for this function:

bool CMessage::isTelegram (  )  const

check, if message is a telegram packet

Return values:
true üacket is a telegram paket

Definition at line 72 of file Message.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask(), CNetworkQueue::SendProcessTask(), SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

bool CMessage::getSenderIPandPort ( UINT32 &  ip_peer_hostorder,
UINT16 &  port_peer_hostorder 
)

get Sender IP and Port from CMessage

Return values:
true successfully returned requested data
false the message has no valid sender information (it did not come from remote peer)

Definition at line 128 of file Message.cpp.

Referenced by SimulateRemotePeer().

Here is the caller graph for this function:

bool CMessage::read_BINARY ( UINT16  varid,
UINT8 *  target_buffer,
UINT32 &  target_buffer_size_bytes 
)

read a binary object from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
target_buffer_size_bytes target buffer size, if to small nessesary value is written back and function returns false
Returns:
true on success

Definition at line 639 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_FLOAT ( UINT16  varid,
FLOAT &  target_buffer 
)

read a float value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 644 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_DOUBLE ( UINT16  varid,
DOUBLE &  target_buffer 
)

read a double float value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 658 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_INT8 ( UINT16  varid,
INT8 &  target_buffer 
)

read a 8 bit signed value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 672 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_UINT8 ( UINT16  varid,
UINT8 &  target_buffer 
)

read a 8 bit unsigned value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 686 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_INT16 ( UINT16  varid,
INT16 &  target_buffer 
)

read a 16 bit signed value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 700 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_UINT16 ( UINT16  varid,
UINT16 &  target_buffer 
)

read a 16 bit unsigned value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 714 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_INT32 ( UINT16  varid,
INT32 &  target_buffer 
)

read a 32 bit signed value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 728 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read_UINT32 ( UINT16  varid,
UINT32 &  target_buffer 
)

read a 32 bit unsigned value from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
Returns:
true on success

Definition at line 742 of file Message.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::read_TEXT ( UINT16  varid,
UINT8 *  target_buffer,
UINT32 &  target_buffer_size_bytes 
)

read a text string from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
target_buffer target buffer to copy data to
target_buffer_size_bytes target buffer size, if to small nessesary value is written back and function returns false
Returns:
true on success

Definition at line 756 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::read ( UINT16  varid,
UINT16  vartype,
VOIDP  target_buffer,
UINT32 &  target_buffer_num_elements 
)

general read function for non standard var types

Parameters:
varid numeric identifier of a packet field inside the message
vartype numeric identifier of the var type
target_buffer target buffer to copy data to
target_buffer_num_elements number of target buffer elements, if to small nessesary value is written back and function returns false
Returns:
true on success

Definition at line 794 of file Message.cpp.

Referenced by read_BINARY(), read_DOUBLE(), read_FLOAT(), read_INT16(), read_INT32(), read_INT8(), read_TEXT(), read_UINT16(), read_UINT32(), read_UINT8(), SimulateLocalPeer(), and SimulateRemotePeer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::write_BINARY ( UINT16  varid,
const UINT8 *  source_buffer,
UINT32  source_buffer_size_bytes 
)

write a binary object into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
source_buffer_size_bytes size of the source buffer in bytes
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 846 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_FLOAT ( UINT16  varid,
FLOAT  source_buffer 
)

write a float value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 851 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_DOUBLE ( UINT16  varid,
DOUBLE  source_buffer 
)

write a double float value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 856 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_INT8 ( UINT16  varid,
INT8  source_buffer 
)

write a signed 8bit value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 861 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_UINT8 ( UINT16  varid,
UINT8  source_buffer 
)

write a unsigned 8bit value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 866 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_INT16 ( UINT16  varid,
INT16  source_buffer 
)

write a signed 16bit value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 871 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_UINT16 ( UINT16  varid,
UINT16  source_buffer 
)

write a unsigned 16bit value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 876 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_INT32 ( UINT16  varid,
INT32  source_buffer 
)

write a signed 32bit value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 881 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write_UINT32 ( UINT16  varid,
UINT32  source_buffer 
)

write a unsigned 32bit value into the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 886 of file Message.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::write_TEXT ( UINT16  varid,
const UINT8 *  source_buffer,
UINT32  source_buffer_size_bytes 
)

write a text string from the CMessage Object

Parameters:
varid numeric identifier of a packet field inside the message
source_buffer source buffer to copy data from
source_buffer_size_bytes size of source buffer in bytes
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 891 of file Message.cpp.

Here is the call graph for this function:

bool CMessage::write ( UINT16  varid,
UINT16  vartype,
const VOIDP  buffer,
const UINT32  elements_in_buffer 
)

general write function for non standard var types

Parameters:
varid numeric identifier of a packet field inside the message
vartype numeric constant that determines the var type (see VARTYPE_BINARY, VARTYPE_FLOAT ...)
buffer source buffer to copy data from
elements_in_buffer number of elements in buffer
Returns:
true on success
Attention:
if varid already exists, existing content is overwritten

Definition at line 924 of file Message.cpp.

Referenced by SimulateLocalPeer(), SimulateRemotePeer(), write_BINARY(), write_DOUBLE(), write_FLOAT(), write_INT16(), write_INT32(), write_INT8(), write_TEXT(), write_UINT16(), write_UINT32(), and write_UINT8().

Here is the call graph for this function:

Here is the caller graph for this function:

void CMessage::setType ( UINT8  aPhysicalType,
UINT8  aLogicalType 
)

set physical and logical paket type

Parameters:
aPhysicalType numerical identifier of physical paket type
aLogicalType numerical identifier of logical paket type

Definition at line 87 of file Message.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

UINT8 CMessage::getPhysicalType (  ) 

get the physical paket type

Definition at line 110 of file Message.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

UINT8 CMessage::getLogicalType (  ) 

get the logical paket type

Definition at line 99 of file Message.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

bool CMessage::matchAckPacket ( const CMessage ack_packet  )  [private]

Definition at line 284 of file Message.cpp.

Referenced by CPacketQueue::find_elem_ack_and_signal().

Here is the caller graph for this function:

void CMessage::constructAckPacket ( const CMessage template_packet  )  [private]

Definition at line 319 of file Message.cpp.

Referenced by CNetworkQueue::recvMsg().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::isAckPacket (  )  const [private]

Definition at line 241 of file Message.cpp.

Referenced by CPacketQueue::find_elem_ack_and_signal(), CNetworkQueue::ReceiveProcessTask(), and CNetworkQueue::SendProcessTask().

Here is the caller graph for this function:

bool CMessage::wantAckPacket (  )  const [private]

Definition at line 258 of file Message.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask().

Here is the caller graph for this function:

UINT32 CMessage::sizeof_per_element ( const UINT16  vartype  )  [inline, private]

Definition at line 1206 of file Message.cpp.

Referenced by copy_data_depending_on_vartype(), ImportMessageFromPacketBuffer(), and write().

Here is the caller graph for this function:

bool CMessage::ImportMessageFromPacketBuffer ( const UINT8 *  buffer,
INT32  buffer_length,
UINT32  ip_hostorder,
UINT16  port_hostorder 
) [private]

Definition at line 446 of file Message.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::ExportMessageToPacketBuffer ( UINT8 *  buffer,
INT32 &  buffer_length 
) [private]

Definition at line 357 of file Message.cpp.

Referenced by CNetworkQueue::SendProcessTask().

Here is the caller graph for this function:

void CMessage::copy_data_depending_on_vartype ( UINT32 *  tgtbufpos,
const UINT32 *  srcbufpos,
UINT32  num_elements,
UINT16  vartype 
) [private]

Definition at line 1086 of file Message.cpp.

Referenced by read(), and write().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMessage::check_buffer_against_vartype ( UINT16  vartype,
const VOIDP  buffer,
UINT32  buflength 
) [private]

Definition at line 588 of file Message.cpp.

Referenced by write().

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class CNetworkQueue [friend]

Definition at line 52 of file Message.h.

friend class CPacketQueue [friend]

Definition at line 53 of file Message.h.


Member Data Documentation

authorisation ID, an optional parameter to use for paket management in user code

Definition at line 275 of file Message.h.

Referenced by constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().

subsystem device id, an optional parameter to use for paket management in user code

Definition at line 277 of file Message.h.

Referenced by constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().

packet type additional parameter

  • for TRAP type: recommendation: contains TRAP_ID
  • for RESP type: recommendation: contains error code

Definition at line 284 of file Message.h.

Referenced by constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().

UINT8 CMessage::payload_buffer[(MAX_NUM_ENTRIES *MIN_SIZE_DATA)+SIZE_ADD_LINKEDLIST] [private]

Definition at line 323 of file Message.h.

Referenced by ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), read(), and write().

Definition at line 326 of file Message.h.

Referenced by clear(), and write().

UINT16 CMessage::internalRequestID [private]

Definition at line 340 of file Message.h.

Referenced by check_int(), clear(), ImportMessageFromPacketBuffer(), and write().

UINT16 CMessage::internalPacketSize [private]

Definition at line 343 of file Message.h.

Referenced by ExportMessageToPacketBuffer(), and ImportMessageFromPacketBuffer().

UINT16 CMessage::internalPacketTail [private]

Definition at line 362 of file Message.h.

Referenced by clear(), getSenderIPandPort(), and ImportMessageFromPacketBuffer().

Definition at line 363 of file Message.h.

Referenced by getSenderIPandPort(), and ImportMessageFromPacketBuffer().

Definition at line 364 of file Message.h.

Referenced by getSenderIPandPort(), and ImportMessageFromPacketBuffer().

Definition at line 372 of file Message.h.

Referenced by clear(), and ImportMessageFromPacketBuffer().


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

Generated on Wed Apr 16 18:22:16 2008 for NetworkQueue by  doxygen 1.5.5