include/opc/ua/protocol/binary/common.h
Go to the documentation of this file.
1 
11 #ifndef __OPC_UA_BINARY_COMMON_H__
12 #define __OPC_UA_BINARY_COMMON_H__
13 
14 #include <opc/ua/protocol/types.h>
17 
18 #include <algorithm>
19 #include <stdint.h>
20 #include <string>
21 #include <vector>
22 
23 namespace OpcUa
24 {
25 namespace Binary
26 {
27 template<typename T>
28 std::size_t RawSize(const T & obj);
29 
30 template<typename T>
31 std::size_t RawSizeContainer(const T & container)
32 {
33  const std::size_t headerSize = 4;
34  std::size_t totalSize = headerSize;
35  std::for_each(container.begin(), container.end(), [&](const typename T::value_type & val) {totalSize += RawSize(val);});
36  return totalSize;
37 }
38 
39 
41 {
43  MT_HELLO = 1,
49 };
50 
52 {
57 };
58 
59 struct Header
60 {
63  uint32_t Size;
64 
65  Header();
66  explicit Header(MessageType type, ChunkType chunk);
67  std::size_t AddSize(std::size_t size);
68  std::size_t MessageSize() const;
69  void ResetSize();
70 };
71 
72 
73 // Hello
74 // os << Header << Hello << flush
75 // is >> Header >> Acknowledge;
76 
77 struct Hello
78 {
79  uint32_t ProtocolVersion;
81  uint32_t SendBufferSize;
82  uint32_t MaxMessageSize;
83  uint32_t MaxChunkCount;
85 
86  Hello();
87 };
88 
90 {
91  uint32_t ProtocolVersion;
93  uint32_t SendBufferSize;
94  uint32_t MaxMessageSize;
95  uint32_t MaxChunkCount;
96 
97  Acknowledge();
98 };
99 
100 struct Error
101 {
102  uint32_t Code;
104 
105  Error();
106 };
107 
109 {
112  uint32_t Size;
113  uint32_t ChannelId;
114 
115  SecureHeader();
116  explicit SecureHeader(MessageType type, ChunkType chunk, uint32_t channelId);
117 
118  std::size_t AddSize(std::size_t size);
119  std::size_t MessageSize() const;
120  void ResetSize();
121 };
122 
124 {
126  std::vector<uint8_t> SenderCertificate;
127  std::vector<uint8_t> ReceiverCertificateThumbPrint;
128 };
129 
131 {
132  uint32_t TokenId;
133 
135 };
136 
138 {
139  uint32_t SequenceNumber;
140  uint32_t RequestId;
141 
142  SequenceHeader();
143 };
144 
145 } // namespace Binary
146 } // namespace OpcUa
147 
148 
149 #endif // __OPC_UA_BINARY_COMMON_H__
150 
std::size_t AddSize(std::size_t size)
OPC UA Address space part. GNU LGPL.
const char * Binary(const char *input, short n)
std::size_t MessageSize() const
std::size_t RawSizeContainer(const T &container)
std::size_t RawSize(const T &obj)


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:04