common.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef __OPC_UA_BINARY_COMMON_H__
00012 #define __OPC_UA_BINARY_COMMON_H__
00013 
00014 #include <opc/ua/protocol/types.h>
00015 #include <opc/ua/protocol/extension_identifiers.h>
00016 #include <opc/ua/protocol/message_identifiers.h>
00017 
00018 #include <algorithm>
00019 #include <stdint.h>
00020 #include <string>
00021 #include <vector>
00022 
00023 namespace OpcUa
00024 {
00025   namespace Binary
00026   {
00027     template<typename T>
00028     std::size_t RawSize(const T& obj);
00029 
00030     template<typename T>
00031     std::size_t RawSizeContainer(const T& container)
00032     {
00033       const std::size_t headerSize = 4;
00034       std::size_t totalSize = headerSize;
00035       std::for_each(container.begin(), container.end(), [&] (const typename T::value_type& val) {totalSize += RawSize(val);});
00036       return totalSize;
00037     }
00038 
00039 
00040     enum MessageType
00041     {
00042       MT_INVALID = 0,
00043       MT_HELLO = 1,
00044       MT_ACKNOWLEDGE,
00045       MT_ERROR,
00046       MT_SECURE_OPEN,
00047       MT_SECURE_CLOSE,
00048       MT_SECURE_MESSAGE,
00049     };
00050 
00051     enum ChunkType
00052     {
00053       CHT_INVALID = 0,
00054       CHT_SINGLE = 1,
00055       CHT_INTERMEDIATE,
00056       CHT_FINAL,
00057     };
00058 
00059     struct Header
00060     {
00061       MessageType Type;
00062       ChunkType Chunk;
00063       uint32_t Size;
00064 
00065       Header();
00066       explicit Header(MessageType type, ChunkType chunk);
00067       std::size_t AddSize(std::size_t size);
00068       std::size_t MessageSize() const;
00069       void ResetSize();
00070     };
00071 
00072 
00073     // Hello
00074     // os << Header << Hello << flush
00075     // is >> Header >> Acknowledge;
00076 
00077     struct Hello
00078     {
00079       uint32_t ProtocolVersion;
00080       uint32_t ReceiveBufferSize;
00081       uint32_t SendBufferSize;
00082       uint32_t MaxMessageSize;
00083       uint32_t MaxChunkCount;
00084       std::string EndpointUrl;
00085 
00086       Hello();
00087     };
00088 
00089     struct Acknowledge
00090     {
00091       uint32_t ProtocolVersion;
00092       uint32_t ReceiveBufferSize;
00093       uint32_t SendBufferSize;
00094       uint32_t MaxMessageSize;
00095       uint32_t MaxChunkCount;
00096 
00097       Acknowledge();
00098     };
00099 
00100     struct Error
00101     {
00102       uint32_t Code;
00103       std::string Reason;
00104 
00105       Error();
00106     };
00107 
00108     struct SecureHeader
00109     {
00110       MessageType Type;
00111       ChunkType Chunk;
00112       uint32_t Size;
00113       uint32_t ChannelId;
00114 
00115       SecureHeader();
00116       explicit SecureHeader(MessageType type, ChunkType chunk, uint32_t channelId);
00117 
00118       std::size_t AddSize(std::size_t size);
00119       std::size_t MessageSize() const;
00120       void ResetSize();
00121     };
00122 
00123     struct AsymmetricAlgorithmHeader
00124     {
00125       std::string SecurityPolicyUri;
00126       std::vector<uint8_t> SenderCertificate;
00127       std::vector<uint8_t> ReceiverCertificateThumbPrint;
00128     };
00129 
00130     struct SymmetricAlgorithmHeader
00131     {
00132       uint32_t TokenId;
00133 
00134       SymmetricAlgorithmHeader();
00135     };
00136 
00137     struct SequenceHeader
00138     {
00139       uint32_t SequenceNumber;
00140       uint32_t RequestId;
00141 
00142       SequenceHeader();
00143     };
00144 
00145   } // namespace Binary
00146 } // namespace OpcUa
00147 
00148 
00149 #endif  // __OPC_UA_BINARY_COMMON_H__
00150 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:40