#include <NQMessage.h>
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 |
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.
CNQMessage::CNQMessage | ( | ) |
CNQMessage::~CNQMessage | ( | ) |
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().
INT32 CNQMessage::check_int | ( | ) | const |
check for valid public fields
Definition at line 188 of file NQMessage.cpp.
Referenced by check_bool(), CNetworkQueue::sendMsgTo(), and CNetworkQueue::sendMsgToInternal().
bool CNQMessage::check_bool | ( | ) | const |
check for valid public fields
true | public fields are valid |
Definition at line 226 of file NQMessage.cpp.
Referenced by ImportMessageFromPacketBuffer().
bool CNQMessage::isResponse | ( | ) | const |
check, if message is a response packet
true | packet is a response paket |
Definition at line 57 of file NQMessage.cpp.
Referenced by CNetworkQueue::ReceiveProcessTask().
bool CNQMessage::isRequest | ( | ) | const |
check, if message is a request packet
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().
bool CNQMessage::isTelegram | ( | ) | const |
check, if message is a telegram packet
true | üacket is a telegram paket |
Definition at line 74 of file NQMessage.cpp.
Referenced by CNetworkQueue::ReceiveProcessTask(), CNetworkQueue::SendProcessTask(), SimulateLocalPeer(), and SimulateRemotePeer().
get Sender IP and Port from CNQMessage
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().
bool CNQMessage::read_BINARY | ( | UINT16 | varid, | |
UINT8 * | target_buffer, | |||
UINT32 & | target_buffer_size_bytes | |||
) |
read a binary object from the CNQMessage Object
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 |
Definition at line 641 of file NQMessage.cpp.
bool CNQMessage::read_FLOAT | ( | UINT16 | varid, | |
FLOAT & | target_buffer | |||
) |
read a float value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 646 of file NQMessage.cpp.
read a double float value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 660 of file NQMessage.cpp.
read a 8 bit signed value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 674 of file NQMessage.cpp.
read a 8 bit unsigned value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 688 of file NQMessage.cpp.
read a 16 bit signed value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 702 of file NQMessage.cpp.
read a 16 bit unsigned value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 716 of file NQMessage.cpp.
read a 32 bit signed value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 730 of file NQMessage.cpp.
read a 32 bit unsigned value from the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
target_buffer | target buffer to copy data to |
Definition at line 744 of file NQMessage.cpp.
Referenced by SimulateLocalPeer(), and SimulateRemotePeer().
bool CNQMessage::read_TEXT | ( | UINT16 | varid, | |
UINT8 * | target_buffer, | |||
UINT32 & | target_buffer_size_bytes | |||
) |
read a text string from the CNQMessage Object
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 |
Definition at line 758 of file NQMessage.cpp.
bool CNQMessage::read | ( | UINT16 | varid, | |
UINT16 | vartype, | |||
VOIDP | target_buffer, | |||
UINT32 & | target_buffer_num_elements | |||
) |
general read function for non standard var types
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 |
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().
bool CNQMessage::write_BINARY | ( | UINT16 | varid, | |
const UINT8 * | source_buffer, | |||
UINT32 | source_buffer_size_bytes | |||
) |
write a binary object into the CNQMessage Object
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 |
Definition at line 848 of file NQMessage.cpp.
bool CNQMessage::write_FLOAT | ( | UINT16 | varid, | |
FLOAT | source_buffer | |||
) |
write a float value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 853 of file NQMessage.cpp.
write a double float value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 858 of file NQMessage.cpp.
write a signed 8bit value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 863 of file NQMessage.cpp.
write a unsigned 8bit value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 868 of file NQMessage.cpp.
write a signed 16bit value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 873 of file NQMessage.cpp.
write a unsigned 16bit value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 878 of file NQMessage.cpp.
write a signed 32bit value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 883 of file NQMessage.cpp.
write a unsigned 32bit value into the CNQMessage Object
varid | numeric identifier of a packet field inside the message | |
source_buffer | source buffer to copy data from |
Definition at line 888 of file NQMessage.cpp.
Referenced by SimulateLocalPeer(), and SimulateRemotePeer().
bool CNQMessage::write_TEXT | ( | UINT16 | varid, | |
const UINT8 * | source_buffer, | |||
UINT32 | source_buffer_size_bytes | |||
) |
write a text string from the CNQMessage Object
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 |
Definition at line 893 of file NQMessage.cpp.
bool CNQMessage::write | ( | UINT16 | varid, | |
UINT16 | vartype, | |||
const VOIDP | buffer, | |||
const UINT32 | elements_in_buffer | |||
) |
general write function for non standard var types
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 |
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().
set physical and logical paket type
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().
UINT8 CNQMessage::getPhysicalType | ( | ) |
get the physical paket type
Definition at line 112 of file NQMessage.cpp.
Referenced by SimulateLocalPeer(), and SimulateRemotePeer().
UINT8 CNQMessage::getLogicalType | ( | ) |
get the logical paket type
Definition at line 101 of file NQMessage.cpp.
Referenced by SimulateLocalPeer(), and SimulateRemotePeer().
bool CNQMessage::matchAckPacket | ( | const CNQMessage & | ack_packet | ) | [private] |
Definition at line 286 of file NQMessage.cpp.
Referenced by CNQPacketQueue::find_elem_ack_and_signal().
void CNQMessage::constructAckPacket | ( | const CNQMessage & | template_packet | ) | [private] |
Definition at line 321 of file NQMessage.cpp.
Referenced by CNetworkQueue::recvMsg().
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().
bool CNQMessage::wantAckPacket | ( | ) | const [private] |
Definition at line 260 of file NQMessage.cpp.
Referenced by CNetworkQueue::ReceiveProcessTask().
Definition at line 1208 of file NQMessage.cpp.
Referenced by copy_data_depending_on_vartype(), ImportMessageFromPacketBuffer(), and write().
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().
Definition at line 359 of file NQMessage.cpp.
Referenced by CNetworkQueue::SendProcessTask().
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().
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().
friend class CNetworkQueue [friend] |
Definition at line 52 of file NQMessage.h.
friend class CNQPacketQueue [friend] |
Definition at line 53 of file NQMessage.h.
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
Definition at line 284 of file NQMessage.h.
Referenced by constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().
UINT8 CNQMessage::mandatoryLogicalPacketType [private] |
Definition at line 318 of file NQMessage.h.
Referenced by check_int(), clear(), constructAckPacket(), ExportMessageToPacketBuffer(), getLogicalType(), ImportMessageFromPacketBuffer(), matchAckPacket(), and setType().
UINT8 CNQMessage::mandatoryPhysicalPacketType [private] |
Definition at line 319 of file NQMessage.h.
Referenced by check_int(), clear(), constructAckPacket(), ExportMessageToPacketBuffer(), getPhysicalType(), ImportMessageFromPacketBuffer(), isRequest(), isResponse(), isTelegram(), matchAckPacket(), and setType().
INT32 CNQMessage::payload_first_offset [private] |
Definition at line 322 of file NQMessage.h.
Referenced by clear(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), read(), and write().
UINT8 CNQMessage::payload_buffer[(NQ_MAX_NUM_ENTRIES *NQ_MIN_SIZE_DATA)+NQ_SIZE_ADD_LINKEDLIST] [private] |
Definition at line 323 of file NQMessage.h.
Referenced by ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), read(), and write().
UINT16 CNQMessage::payload_buffer_left [private] |
UINT16 CNQMessage::payload_curlength_net [private] |
Definition at line 331 of file NQMessage.h.
Referenced by check_int(), clear(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and write().
UINT16 CNQMessage::payload_num_elements [private] |
Definition at line 332 of file NQMessage.h.
Referenced by clear(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and write().
UINT16 CNQMessage::internalPacketIndex [private] |
Definition at line 336 of file NQMessage.h.
Referenced by ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), CNetworkQueue::ReceiveProcessTask(), and CNetworkQueue::SendProcessTask().
UINT16 CNQMessage::internalRequestID [private] |
Definition at line 337 of file NQMessage.h.
Referenced by constructAckPacket(), ExportMessageToPacketBuffer(), CNQPacketQueue::find_and_remove_elem(), CNQPacketQueue::find_elem(), ImportMessageFromPacketBuffer(), matchAckPacket(), CNetworkQueue::ReceiveProcessTask(), CNQPacketQueue::remove_elem(), CNetworkQueue::sendMsgTo(), and CNetworkQueue::sendRecvMsg().
UINT16 CNQMessage::payload_maxlength_net [private] |
Definition at line 340 of file NQMessage.h.
Referenced by check_int(), clear(), ImportMessageFromPacketBuffer(), and write().
UINT16 CNQMessage::internalPacketMagic [private] |
Definition at line 342 of file NQMessage.h.
Referenced by check_int(), clear(), constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().
UINT16 CNQMessage::internalPacketSize [private] |
Definition at line 343 of file NQMessage.h.
Referenced by ExportMessageToPacketBuffer(), and ImportMessageFromPacketBuffer().
UINT16 CNQMessage::internalPacketVersion [private] |
Definition at line 344 of file NQMessage.h.
Referenced by check_int(), clear(), constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().
UINT16 CNQMessage::internalPacketSpecialBits [private] |
Definition at line 345 of file NQMessage.h.
Referenced by check_int(), clear(), constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), isAckPacket(), matchAckPacket(), CNetworkQueue::sendMsgTo(), and wantAckPacket().
UINT16 CNQMessage::internalPacketTail [private] |
Definition at line 356 of file NQMessage.h.
Referenced by check_int(), clear(), constructAckPacket(), ExportMessageToPacketBuffer(), ImportMessageFromPacketBuffer(), and matchAckPacket().
bool CNQMessage::message_came_from_set [private] |
Definition at line 362 of file NQMessage.h.
Referenced by clear(), getSenderIPandPort(), and ImportMessageFromPacketBuffer().
UINT32 CNQMessage::message_came_from_ip [private] |
Definition at line 363 of file NQMessage.h.
Referenced by getSenderIPandPort(), and ImportMessageFromPacketBuffer().
UINT16 CNQMessage::message_came_from_port [private] |
Definition at line 364 of file NQMessage.h.
Referenced by getSenderIPandPort(), and ImportMessageFromPacketBuffer().
UINT32 CNQMessage::message_sendto_ip_host [private] |
Definition at line 368 of file NQMessage.h.
Referenced by CNetworkQueue::sendMsgTo(), CNetworkQueue::sendMsgToInternal(), and CNetworkQueue::SendProcessTask().
UINT16 CNQMessage::message_sendto_port_host [private] |
Definition at line 369 of file NQMessage.h.
Referenced by CNetworkQueue::sendMsgTo(), CNetworkQueue::sendMsgToInternal(), and CNetworkQueue::SendProcessTask().
HANDLE CNQMessage::notifySemaphoreOnReceiveAnswer [private] |
Definition at line 372 of file NQMessage.h.
Referenced by clear(), and ImportMessageFromPacketBuffer().
HANDLE CNQMessage::notifySemaphoreOnReceiveAck [private] |
Definition at line 373 of file NQMessage.h.
Referenced by clear(), CNQPacketQueue::find_elem_ack_and_signal(), ImportMessageFromPacketBuffer(), and CNetworkQueue::sendMsgTo().