CNQMessage Class Reference

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

#include <NQMessage.h>

List of all members.

Public Member Functions

 CNQMessage ()
 Constructor.
 ~CNQMessage ()
 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 CNQMessage
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 CNQMessage Object
bool read_FLOAT (UINT16 varid, FLOAT &target_buffer)
 read a float value from the CNQMessage Object
bool read_DOUBLE (UINT16 varid, DOUBLE &target_buffer)
 read a double float value from the CNQMessage Object
bool read_INT8 (UINT16 varid, INT8 &target_buffer)
 read a 8 bit signed value from the CNQMessage Object
bool read_UINT8 (UINT16 varid, UINT8 &target_buffer)
 read a 8 bit unsigned value from the CNQMessage Object
bool read_INT16 (UINT16 varid, INT16 &target_buffer)
 read a 16 bit signed value from the CNQMessage Object
bool read_UINT16 (UINT16 varid, UINT16 &target_buffer)
 read a 16 bit unsigned value from the CNQMessage Object
bool read_INT32 (UINT16 varid, INT32 &target_buffer)
 read a 32 bit signed value from the CNQMessage Object
bool read_UINT32 (UINT16 varid, UINT32 &target_buffer)
 read a 32 bit unsigned value from the CNQMessage Object
bool read_TEXT (UINT16 varid, UINT8 *target_buffer, UINT32 &target_buffer_size_bytes)
 read a text string from the CNQMessage 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 CNQMessage Object
bool write_FLOAT (UINT16 varid, FLOAT source_buffer)
 write a float value into the CNQMessage Object
bool write_DOUBLE (UINT16 varid, DOUBLE source_buffer)
 write a double float value into the CNQMessage Object
bool write_INT8 (UINT16 varid, INT8 source_buffer)
 write a signed 8bit value into the CNQMessage Object
bool write_UINT8 (UINT16 varid, UINT8 source_buffer)
 write a unsigned 8bit value into the CNQMessage Object
bool write_INT16 (UINT16 varid, INT16 source_buffer)
 write a signed 16bit value into the CNQMessage Object
bool write_UINT16 (UINT16 varid, UINT16 source_buffer)
 write a unsigned 16bit value into the CNQMessage Object
bool write_INT32 (UINT16 varid, INT32 source_buffer)
 write a signed 32bit value into the CNQMessage Object
bool write_UINT32 (UINT16 varid, UINT32 source_buffer)
 write a unsigned 32bit value into the CNQMessage Object
bool write_TEXT (UINT16 varid, const UINT8 *source_buffer, UINT32 source_buffer_size_bytes)
 write a text string from the CNQMessage 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 CNQMessage &ack_packet)
void constructAckPacket (const CNQMessage &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 [(NQ_MAX_NUM_ENTRIES *NQ_MIN_SIZE_DATA)+NQ_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 CNQPacketQueue


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 NQMessage.h.


Constructor & Destructor Documentation

CNQMessage::CNQMessage (  ) 

Constructor.

Definition at line 18 of file NQMessage.cpp.

Here is the call graph for this function:

CNQMessage::~CNQMessage (  ) 

Destructor.

Definition at line 24 of file NQMessage.cpp.

Here is the call graph for this function:


Member Function Documentation

void CNQMessage::clear (  ) 

reset contents of message

Definition at line 148 of file NQMessage.cpp.

Referenced by CNQMessage(), constructAckPacket(), CNQMessagePool::putback_reference(), SimulateRemotePeer(), and ~CNQMessage().

Here is the caller graph for this function:

INT32 CNQMessage::check_int (  )  const

check for valid public fields

Returns:
exact error code

Definition at line 188 of file NQMessage.cpp.

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

Here is the caller graph for this function:

bool CNQMessage::check_bool (  )  const

check for valid public fields

Return values:
true public fields are valid

Definition at line 226 of file NQMessage.cpp.

Referenced by ImportMessageFromPacketBuffer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CNQMessage::isResponse (  )  const

check, if message is a response packet

Return values:
true packet is a response paket

Definition at line 57 of file NQMessage.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask().

Here is the caller graph for this function:

bool CNQMessage::isRequest (  )  const

check, if message is a request packet

Return values:
true packet is a request paket

Definition at line 40 of file NQMessage.cpp.

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

Here is the caller graph for this function:

bool CNQMessage::isTelegram (  )  const

check, if message is a telegram packet

Return values:
true üacket is a telegram paket

Definition at line 74 of file NQMessage.cpp.

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

Here is the caller graph for this function:

bool CNQMessage::getSenderIPandPort ( UINT32 ip_peer_hostorder,
UINT16 port_peer_hostorder 
)

get Sender IP and Port from CNQMessage

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 130 of file NQMessage.cpp.

Referenced by SimulateRemotePeer().

Here is the caller graph for this function:

bool CNQMessage::read_BINARY ( UINT16  varid,
UINT8 target_buffer,
UINT32 target_buffer_size_bytes 
)

read a binary object from the CNQMessage 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 641 of file NQMessage.cpp.

Here is the call graph for this function:

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

read a float value from the CNQMessage 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 646 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_DOUBLE ( UINT16  varid,
DOUBLE target_buffer 
)

read a double float value from the CNQMessage 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 660 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_INT8 ( UINT16  varid,
INT8 target_buffer 
)

read a 8 bit signed value from the CNQMessage 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 674 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_UINT8 ( UINT16  varid,
UINT8 target_buffer 
)

read a 8 bit unsigned value from the CNQMessage 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 688 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_INT16 ( UINT16  varid,
INT16 target_buffer 
)

read a 16 bit signed value from the CNQMessage 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 702 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_UINT16 ( UINT16  varid,
UINT16 target_buffer 
)

read a 16 bit unsigned value from the CNQMessage 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 716 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_INT32 ( UINT16  varid,
INT32 target_buffer 
)

read a 32 bit signed value from the CNQMessage 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 730 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::read_UINT32 ( UINT16  varid,
UINT32 target_buffer 
)

read a 32 bit unsigned value from the CNQMessage 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 744 of file NQMessage.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CNQMessage::read_TEXT ( UINT16  varid,
UINT8 target_buffer,
UINT32 target_buffer_size_bytes 
)

read a text string from the CNQMessage 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 758 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::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 796 of file NQMessage.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 CNQMessage::write_BINARY ( UINT16  varid,
const UINT8 source_buffer,
UINT32  source_buffer_size_bytes 
)

write a binary object into the CNQMessage 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 848 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a float value into the CNQMessage 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 853 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a double float value into the CNQMessage 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 858 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a signed 8bit value into the CNQMessage 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 863 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a unsigned 8bit value into the CNQMessage 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 868 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a signed 16bit value into the CNQMessage 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 873 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a unsigned 16bit value into the CNQMessage 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 878 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a signed 32bit value into the CNQMessage 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 883 of file NQMessage.cpp.

Here is the call graph for this function:

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

write a unsigned 32bit value into the CNQMessage 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 888 of file NQMessage.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the call graph for this function:

Here is the caller graph for this function:

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

write a text string from the CNQMessage 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 893 of file NQMessage.cpp.

Here is the call graph for this function:

bool CNQMessage::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 NQ_VARTYPE_BINARY, NQ_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 926 of file NQMessage.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 CNQMessage::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 89 of file NQMessage.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

UINT8 CNQMessage::getPhysicalType (  ) 

get the physical paket type

Definition at line 112 of file NQMessage.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

UINT8 CNQMessage::getLogicalType (  ) 

get the logical paket type

Definition at line 101 of file NQMessage.cpp.

Referenced by SimulateLocalPeer(), and SimulateRemotePeer().

Here is the caller graph for this function:

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

Definition at line 286 of file NQMessage.cpp.

Referenced by CNQPacketQueue::find_elem_ack_and_signal().

Here is the caller graph for this function:

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

Definition at line 321 of file NQMessage.cpp.

Referenced by CNetworkQueue::recvMsg().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CNQMessage::isAckPacket (  )  const [private]

Definition at line 243 of file NQMessage.cpp.

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

Here is the caller graph for this function:

bool CNQMessage::wantAckPacket (  )  const [private]

Definition at line 260 of file NQMessage.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask().

Here is the caller graph for this function:

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

Definition at line 1208 of file NQMessage.cpp.

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

Here is the caller graph for this function:

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

Definition at line 448 of file NQMessage.cpp.

Referenced by CNetworkQueue::ReceiveProcessTask().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CNQMessage::ExportMessageToPacketBuffer ( UINT8 buffer,
INT32 buffer_length 
) [private]

Definition at line 359 of file NQMessage.cpp.

Referenced by CNetworkQueue::SendProcessTask().

Here is the caller graph for this function:

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

Definition at line 1088 of file NQMessage.cpp.

Referenced by read(), and write().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 590 of file NQMessage.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 NQMessage.h.

friend class CNQPacketQueue [friend]

Definition at line 53 of file NQMessage.h.


Member Data Documentation

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

Definition at line 275 of file NQMessage.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 NQMessage.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 NQMessage.h.

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

UINT8 CNQMessage::payload_buffer[(NQ_MAX_NUM_ENTRIES *NQ_MIN_SIZE_DATA)+NQ_SIZE_ADD_LINKEDLIST] [private]

Definition at line 326 of file NQMessage.h.

Referenced by clear(), and write().

Definition at line 340 of file NQMessage.h.

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

Definition at line 343 of file NQMessage.h.

Referenced by ExportMessageToPacketBuffer(), and ImportMessageFromPacketBuffer().

Definition at line 362 of file NQMessage.h.

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

Definition at line 363 of file NQMessage.h.

Referenced by getSenderIPandPort(), and ImportMessageFromPacketBuffer().

Definition at line 364 of file NQMessage.h.

Referenced by getSenderIPandPort(), and ImportMessageFromPacketBuffer().

Definition at line 372 of file NQMessage.h.

Referenced by clear(), and ImportMessageFromPacketBuffer().


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

Generated on Tue Apr 22 18:19:59 2008 for NetworkQueue by  doxygen 1.5.5