S2OPC OPCUA Toolkit
|
#include <inttypes.h>
#include "sopc_buffer.h"
#include "sopc_dataset_ll_layer.h"
#include "sopc_pub_fixed_buffer.h"
#include "sopc_pubsub_conf.h"
#include "sopc_pubsub_security.h"
#include "sopc_sub_scheduler.h"
#include "sopc_sub_target_variable.h"
Go to the source code of this file.
Data Structures | |
struct | SOPC_UADP_Network_Message |
struct | SOPC_UADP_NetworkMessage_Reader_Callbacks |
struct | SOPC_UADP_NetworkMessage_Reader_Configuration |
Typedefs | |
typedef struct SOPC_UADP_Network_Message | SOPC_UADP_NetworkMessage |
typedef bool | SOPC_UADP_IsWriterSequenceNumberNewer_Func(const SOPC_Conf_PublisherId *pubId, const uint16_t groupId, const uint16_t writerId, const uint16_t receivedSN) |
Function used to check if a DataSetMessage sequence number is newer for the identified DataSetWriter. | |
typedef void | SOPC_UADP_UpdateTimeout_Func(const SOPC_Conf_PublisherId *pubId, const uint16_t groupId, const uint16_t writerId) |
Function used to update timeout state of an identified dataSetWriter. This function should be call if decode process was succesfull. | |
typedef const SOPC_ReaderGroup * | SOPC_UADP_NetworkMessage_GetReaderGroup(const SOPC_PubSubConnection *connection, const SOPC_UADP_Configuration *uadp_conf, const SOPC_Dataset_LL_PublisherId *pubid, const uint32_t groupVersion, const uint32_t groupId) |
A callback for ReaderGroup identification. When a network message is received, this callback is expected to return a matching SOPC_ReaderGroup. It is used to check if the remaining parts of the message has to be decoded or not. | |
typedef const SOPC_DataSetReader * | SOPC_UADP_NetworkMessage_GetReader(const SOPC_ReaderGroup *group, const SOPC_UADP_Configuration *uadp_conf, const uint16_t dataSetWriterId) |
A callback for DataSetReader identification. When a DataSet content is received, this callback is expected to return a matching SOPC_DataSetReader. It is used to check if the content of the dataset has to be decoded or not, and to route decoding to the correct reader. | |
typedef SOPC_ReturnStatus | SOPC_UADP_NetworkMessage_SetDsm(SOPC_Dataset_LL_DataSetMessage *dsm, SOPC_SubTargetVariableConfig *targetConfig, const SOPC_DataSetReader *reader, SOPC_TargetVariableCtx *targetVariable) |
A callback for DataSet message application. When a compliant DataSet is received, this callback is expected to forward all variables received in dsm to targetConfig, depending on filter parameters in reader. | |
typedef SOPC_TargetVariableCtx * | SOPC_UADP_GetTargetVariable_Func(const SOPC_Conf_PublisherId *pubId, const uint16_t groupId, const uint16_t writerId) |
A callback to retrieve a SOPC_TargetVariableCtx provided to user. The SOPC_TargetVariableCtx provided to the user cannot be modified. Ideally a SOPC_TargetVariableCtx has been created per dataSetMessage and can be identify by the tuple PublisherId, WriterId. | |
Functions | |
bool | SOPC_Is_UInt16_Sequence_Number_Newer (uint16_t received, uint16_t processed) |
check if received sequence number is newer than processsed sequence number following part 14 rules | |
SOPC_NetworkMessage_Error_Code | SOPC_JSON_NetworkMessage_Encode (SOPC_Dataset_LL_NetworkMessage *message, SOPC_PubSub_SecurityType *security, SOPC_Buffer **buffer) |
Encode a NetworkMessage with JSON Mapping. | |
SOPC_NetworkMessage_Error_Code | SOPC_UADP_NetworkMessage_Encode_Buffers (SOPC_Dataset_LL_NetworkMessage *nm, SOPC_PubSub_SecurityType *security, SOPC_Buffer **buffer_header, SOPC_Buffer **buffer_payload) |
Encode a NetworkMessage with UADP Mapping. Buffer is split in a Header buffer and payload buffer. | |
SOPC_NetworkMessage_Error_Code | SOPC_UADP_NetworkMessage_BuildFinalMessage (SOPC_PubSub_SecurityType *security, SOPC_Buffer *buffer_header, SOPC_Buffer **buffer_payload) |
Sign and encrypt encoded buffer if necessary and merge header and payload buffer in one buffer. | |
SOPC_Buffer * | SOPC_UADP_NetworkMessage_Get_PreencodedBuffer (SOPC_Dataset_LL_NetworkMessage *nm, SOPC_PubSub_SecurityType *security) |
Get updated preencoded buffer. | |
SOPC_NetworkMessage_Error_Code | SOPC_UADP_NetworkMessage_Decode (SOPC_Buffer *buffer, const SOPC_UADP_NetworkMessage_Reader_Configuration *reader_config, const SOPC_PubSubConnection *connection, SOPC_UADP_NetworkMessage **uadp_nm) |
Decode a UADP packet into a NetworkMessage. | |
void | SOPC_UADP_NetworkMessage_Delete (SOPC_UADP_NetworkMessage *uadp_nm) |
UADP Encoding is divided in two stages
The header buffer contains the final buffer to be sent. It is composed of non-encrypted headers followed by the payload buffer copy, which may be encrypted
The payload buffer contains the unencrypted payload
typedef struct SOPC_UADP_Network_Message SOPC_UADP_NetworkMessage |
typedef bool SOPC_UADP_IsWriterSequenceNumberNewer_Func(const SOPC_Conf_PublisherId *pubId, const uint16_t groupId, const uint16_t writerId, const uint16_t receivedSN) |
Function used to check if a DataSetMessage sequence number is newer for the identified DataSetWriter.
pubId | the publisher id associated to the DataSetWriter |
groupId | the WriterGroupId |
writerId | the DataSetWriter id |
receivedSN | the dataset message sequence number |
typedef void SOPC_UADP_UpdateTimeout_Func(const SOPC_Conf_PublisherId *pubId, const uint16_t groupId, const uint16_t writerId) |
Function used to update timeout state of an identified dataSetWriter. This function should be call if decode process was succesfull.
pubId | the publisher id associated to the DataSetWriter |
groupId | the WriterGroupId |
writerId | the DataSetWriter id |
typedef const SOPC_ReaderGroup * SOPC_UADP_NetworkMessage_GetReaderGroup(const SOPC_PubSubConnection *connection, const SOPC_UADP_Configuration *uadp_conf, const SOPC_Dataset_LL_PublisherId *pubid, const uint32_t groupVersion, const uint32_t groupId) |
A callback for ReaderGroup identification. When a network message is received, this callback is expected to return a matching SOPC_ReaderGroup. It is used to check if the remaining parts of the message has to be decoded or not.
connection | is the Network connection |
uadp_conf | Configuration of the received message |
pubid | Publisher Id received |
groupVersion | Group Version received |
groupId | Group Id received |
typedef const SOPC_DataSetReader * SOPC_UADP_NetworkMessage_GetReader(const SOPC_ReaderGroup *group, const SOPC_UADP_Configuration *uadp_conf, const uint16_t dataSetWriterId) |
A callback for DataSetReader identification. When a DataSet content is received, this callback is expected to return a matching SOPC_DataSetReader. It is used to check if the content of the dataset has to be decoded or not, and to route decoding to the correct reader.
group | is the Reader Group on which the DataSet is received |
uadp_conf | Configuration of the received message |
dataSetWriterId | DataSetWriter Id received |
NULL
if no matching Reader is configured for the given group. typedef SOPC_ReturnStatus SOPC_UADP_NetworkMessage_SetDsm(SOPC_Dataset_LL_DataSetMessage *dsm, SOPC_SubTargetVariableConfig *targetConfig, const SOPC_DataSetReader *reader, SOPC_TargetVariableCtx *targetVariable) |
A callback for DataSet message application. When a compliant DataSet is received, this callback is expected to forward all variables received in dsm to targetConfig, depending on filter parameters in reader.
dsm | The received DataSetMessage |
targetConfig | Configuration of the Subscriber receive event |
reader | The matching reader. |
targetVariable | Object containing the data provided to user |
typedef SOPC_TargetVariableCtx * SOPC_UADP_GetTargetVariable_Func(const SOPC_Conf_PublisherId *pubId, const uint16_t groupId, const uint16_t writerId) |
A callback to retrieve a SOPC_TargetVariableCtx provided to user. The SOPC_TargetVariableCtx provided to the user cannot be modified. Ideally a SOPC_TargetVariableCtx has been created per dataSetMessage and can be identify by the tuple PublisherId, WriterId.
pubId | Publisher Id of the networkMessage received |
groupId | WriterGroup Id of the received message |
writerId | DataSetWriter Id of the received message |
Error code used by encoding and decoding functions
bool SOPC_Is_UInt16_Sequence_Number_Newer | ( | uint16_t | received, |
uint16_t | processed ) |
check if received sequence number is newer than processsed sequence number following part 14 rules
received | received sequence number |
processed | sequence number already processed |
SOPC_NetworkMessage_Error_Code SOPC_JSON_NetworkMessage_Encode | ( | SOPC_Dataset_LL_NetworkMessage * | message, |
SOPC_PubSub_SecurityType * | security, | ||
SOPC_Buffer ** | buffer ) |
Encode a NetworkMessage with JSON Mapping.
message | is the NetworkMessage to encode |
security | is the data use to encrypt and sign. Can be NULL if security is not used. No security possible for JSON encoding. |
buffer | pointer to a newly allocated buffer containing the JSON string |
SOPC_NetworkMessage_Error_Code SOPC_UADP_NetworkMessage_Encode_Buffers | ( | SOPC_Dataset_LL_NetworkMessage * | nm, |
SOPC_PubSub_SecurityType * | security, | ||
SOPC_Buffer ** | buffer_header, | ||
SOPC_Buffer ** | buffer_payload ) |
Encode a NetworkMessage with UADP Mapping. Buffer is split in a Header buffer and payload buffer.
nm | is the NetworkMessage to encode |
security | is the data use to set security flags. Can be NULL if security is not used |
buffer_header | [OUT] pointer to a newly allocated buffer with header flags encoded. |
buffer_payload | [OUT] pointer to a newly allocated buffer with payload data encoded. |
SOPC_NetworkMessage_Error_Code SOPC_UADP_NetworkMessage_BuildFinalMessage | ( | SOPC_PubSub_SecurityType * | security, |
SOPC_Buffer * | buffer_header, | ||
SOPC_Buffer ** | buffer_payload ) |
Sign and encrypt encoded buffer if necessary and merge header and payload buffer in one buffer.
security | is the data used to encrypt and sign. Can be NULL if security is not used |
buffer_header | [IN/OUT] encoded header buffer which will become the final buffer |
buffer_payload | encoded payload buffer. Freed in all cases by this function |
SOPC_Buffer * SOPC_UADP_NetworkMessage_Get_PreencodedBuffer | ( | SOPC_Dataset_LL_NetworkMessage * | nm, |
SOPC_PubSub_SecurityType * | security ) |
Get updated preencoded buffer.
nm | NetworkMessage containing preencoded structure |
security | the data used to encrypt and sign. Must be NULL, preencode mechanism cannot handle sign and encrypt |
SOPC_NetworkMessage_Error_Code SOPC_UADP_NetworkMessage_Decode | ( | SOPC_Buffer * | buffer, |
const SOPC_UADP_NetworkMessage_Reader_Configuration * | reader_config, | ||
const SOPC_PubSubConnection * | connection, | ||
SOPC_UADP_NetworkMessage ** | uadp_nm ) |
Decode a UADP packet into a NetworkMessage.
buffer | the UADP byte to decode |
reader_config | The configuration for message parsing/filtering |
connection | The related connection |
uadp_nm | a pointer to a new network message (must be freed by caller) if decoding succeeded |
void SOPC_UADP_NetworkMessage_Delete | ( | SOPC_UADP_NetworkMessage * | uadp_nm | ) |