opcua_binaryEncDec.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*
  2. * opcua_BinaryEncDec.h
  3. *
  4. * Created on: Dec 18, 2013
  5. * Author: opcua
  6. */
  7. #ifndef OPCUA_BINARYENCDEC_NEU_H_
  8. #define OPCUA_BINARYENCDEC_NEU_H_
  9. //#include "opcua_builtInDatatypes.h"
  10. //#include "opcua_advancedDatatypes.h"
  11. //#include "opcua_types.h"
  12. #define UA_TRUE 1
  13. #define UA_FALSE 0
  14. #define MAX_PICO_SECONDS 9999
  15. //functions
  16. /**
  17. *
  18. * @param srcBuf
  19. * @param type
  20. * @param pos
  21. * @param dstStructure
  22. * @return
  23. */
  24. UA_Int32 decoder_decodeBuiltInDatatype(char const * srcBuf, UA_Int32 type, UA_Int32 *pos,
  25. void *dstStructure);
  26. /**
  27. *
  28. * @param data
  29. * @param type
  30. * @param pos
  31. * @param dstBuf
  32. * @return
  33. */
  34. UA_Int32 encoder_encodeBuiltInDatatype(void *data, UA_Int32 type, UA_Int32 *pos, char *dstBuf);
  35. /**
  36. *
  37. * @param data
  38. * @param size
  39. * @param type
  40. * @param pos
  41. * @param dstBuf
  42. * @return
  43. */
  44. UA_Int32 encoder_encodeBuiltInDatatypeArray(void **data, UA_Int32 size,
  45. UA_Int32 arrayType, UA_Int32 *pos,
  46. char *dstBuf);
  47. /**
  48. *
  49. * @param buf
  50. * @param pos
  51. * @param dst
  52. * @return
  53. */
  54. UA_Int32 decodeBoolean(char const * buf, UA_Int32 *pos, Boolean *dst);
  55. /**
  56. *
  57. * @param value
  58. * @param pos
  59. * @param dstBuf
  60. */
  61. void encodeBoolean(Boolean value, UA_Int32 *pos, char *dstBuf);
  62. /**
  63. *
  64. * @param buf
  65. * @param pos
  66. * @param dst
  67. * @return
  68. */
  69. UA_Int32 decodeSByte(char const * buf, UA_Int32 *pos, UA_SByte *dst);
  70. /**
  71. *
  72. * @param value
  73. * @param pos
  74. * @param dstBuf
  75. */
  76. void encodeSByte(UA_SByte value, UA_Int32 *pos, char *dstBuf);
  77. /**
  78. *
  79. * @param buf
  80. * @param pos
  81. * @param dst
  82. * @return
  83. */
  84. UA_Int32 decodeByte(char const * buf, UA_Int32 *pos,UA_Byte *dst);
  85. /**
  86. *
  87. * @param value
  88. * @param pos
  89. * @param dstBuf
  90. */
  91. void encodeByte(UA_Byte value, UA_Int32 *pos, char *dstBuf);
  92. /**
  93. *
  94. * @param buf
  95. * @param pos
  96. * @return
  97. */
  98. UA_Int32 decodeUInt16(char const * buf, UA_Int32 *pos, UInt16 *dst);
  99. /**
  100. *
  101. * @param value
  102. * @param pos
  103. * @param dstBuf
  104. */
  105. void encodeUInt16(UInt16 value, UA_Int32 *pos, char *dstBuf);
  106. /**
  107. *
  108. * @param buf
  109. * @param pos
  110. * @param dst
  111. * @return
  112. */
  113. UA_Int32 decodeInt16(char const * buf, UA_Int32 *pos, UA_Int16 *dst);
  114. /**
  115. *
  116. * @param value
  117. * @param pos
  118. * @param dstBuf
  119. */
  120. void encodeInt16(UA_Int16 value, UA_Int32 *pos, char *dstBuf);
  121. /**
  122. *
  123. * @param buf
  124. * @param pos
  125. * @param dst
  126. * @return
  127. */
  128. UA_Int32 decodeInt32(char const * buf, UA_Int32 *pos, UA_Int32 *dst);
  129. /**
  130. *
  131. * @param value
  132. * @param pos
  133. * @param dstBuf
  134. */
  135. void encodeInt32(UA_Int32 value, UA_Int32 *pos, char *dstBuf);
  136. /**
  137. *
  138. * @param buf
  139. * @param pos
  140. * @param dst
  141. * @return
  142. */
  143. UA_Int32 decodeUInt32(char const * const buf, UA_Int32 *pos, UA_UInt32 *dst);
  144. /**
  145. *
  146. * @param value
  147. * @param dstBuf
  148. * @param pos
  149. */
  150. void encodeUInt32(UA_UInt32 value, UA_Int32 *pos, char *dstBuf);
  151. /**
  152. *
  153. * @param buf
  154. * @param pos
  155. * @param dst
  156. * @return
  157. */
  158. UA_Int32 decodeInt64(char const * buf, UA_Int32 *pos,UA_Int64 *dst);
  159. /**
  160. *
  161. * @param value
  162. * @param pos
  163. * @param dstBuf
  164. */
  165. void encodeInt64(UA_Int64 value, UA_Int32 *pos, char *dstBuf);
  166. /**
  167. *
  168. * @param buf
  169. * @param pos
  170. * @param dst
  171. * @return
  172. */
  173. UA_Int32 decodeUInt64(char const * buf, UA_Int32 *pos, UA_UInt64 *dst);
  174. /**
  175. *
  176. * @param value
  177. * @param pos
  178. * @param dstBuf
  179. */
  180. void encodeUInt64(UA_UInt64 value, UA_Int32 *pos, char *dstBuf);
  181. /**
  182. *
  183. * @param buf binary encoded message
  184. * @param pos position at which the data is located in/out, parser position after the conversion
  185. * @param dstNodeId receiver of the nodeid structure
  186. * @param return success = 0
  187. */
  188. UA_Int32 decodeUANodeId(char const * buf, UA_Int32 *pos, UA_NodeId *dstNodeId);
  189. /**
  190. *
  191. * @param buf
  192. * @param pos
  193. * @param dst
  194. * @return
  195. */
  196. UA_Int32 decodeFloat(char const * buf, UA_Int32 *pos, Float *dst);
  197. /**
  198. *
  199. * @param value
  200. * @param pos
  201. * @param dstBuf
  202. * @return
  203. */
  204. UA_Int32 encodeFloat(Float value,UA_Int32 *pos,char *dstBuf);
  205. /**
  206. *
  207. * @param buf
  208. * @param pos
  209. * @param dst
  210. * @return
  211. */
  212. UA_Int32 decodeDouble(char const * buf, UA_Int32 *pos, UA_Double *dst);
  213. /**
  214. *
  215. * @param value
  216. * @param pos
  217. * @param dstBuf
  218. * @return
  219. */
  220. UA_Int32 encodeDouble(UA_Double value, UA_Int32 *pos,char *dstBuf);
  221. /**
  222. *
  223. * @param srcNodeId
  224. * @param pos
  225. * @param buf
  226. * @return
  227. */
  228. UA_Int32 encodeUANodeId(UA_NodeId *srcNodeId, UA_Int32 *pos, char *buf);
  229. /**
  230. *
  231. * @param srcGuid
  232. * @param pos
  233. * @param buf
  234. * @return
  235. */
  236. UA_Int32 encodeUAGuid(UA_Guid *srcGuid, UA_Int32 *pos, char *buf);
  237. /**
  238. *
  239. * @param buf
  240. * @param pos
  241. * @param dstGUID
  242. * @return
  243. */
  244. UA_Int32 decodeUAGuid(char const * buf, UA_Int32 *pos, UA_Guid *dstGUID);
  245. /**
  246. *
  247. * @param buf
  248. * @param pos
  249. * @param dst
  250. * @return
  251. */
  252. UA_Int32 decodeUAStatusCode(char const * buf, UA_Int32 *pos,UA_StatusCode* dst);
  253. /**
  254. *
  255. * @param buf
  256. * @param pos
  257. * @return
  258. */
  259. UA_Int32 decodeUADateTime(char const * buf, UA_Int32 *pos,UA_DateTime *dst);
  260. /**
  261. *
  262. * @param time
  263. * @param pos
  264. * @param dstBuf
  265. * @return
  266. */
  267. void encodeUADateTime(UA_DateTime time, UA_Int32 *pos, char *dstBuf);
  268. /**
  269. *
  270. * @param buf
  271. * @param pos
  272. * @param dstUAString
  273. * @return
  274. */
  275. UA_Int32 decodeUAString(char const * buf, UA_Int32 *pos, UA_String *dstUAString);
  276. /**
  277. *
  278. * @param byteString
  279. * @return length of the binary encoded data
  280. */
  281. UA_Int32 UAByteString_calcSize(UA_ByteString *byteString);
  282. /**
  283. *
  284. * @param xmlElement
  285. * @param pos
  286. * @param dstBuf
  287. * @return
  288. */
  289. UA_Int32 encodeXmlElement(UA_XmlElement *xmlElement, UA_Int32 *pos, char *dstBuf);
  290. /**
  291. *
  292. * @param buf
  293. * @param pos
  294. * @param xmlElement
  295. * @return
  296. */
  297. UA_Int32 decodeXmlElement(char const * buf, UA_Int32* pos, UA_XmlElement *xmlElement);
  298. /**
  299. *
  300. * @param buf
  301. * @param pos
  302. * @return
  303. */
  304. UA_Int32 decodeIntegerId(char const * buf, UA_Int32 *pos, UA_Int32* dst);
  305. /**
  306. *
  307. * @param integerId
  308. * @param pos
  309. * @param buf
  310. */
  311. void encodeIntegerId(UA_AD_IntegerId integerId, UA_Int32 *pos, char *buf);
  312. /**
  313. * \brief
  314. * \param srcRaw pointer to raw data which holds the encoded data
  315. * \param pos
  316. * \param dstRequestHeader pointer to a structure which hold the encoded header
  317. * \return 0 = success
  318. */
  319. UA_Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,UA_Int32 *pos, UA_AD_RequestHeader *dstRequestHeader);
  320. /**
  321. *
  322. * @param srcHeader
  323. * @param pos
  324. * @param dstRaw
  325. * @return
  326. */
  327. UA_Int32 encodeRequestHeader(const UA_AD_RequestHeader *srcHeader,UA_Int32 *pos,UA_ByteString *dstRaw);
  328. /**
  329. *
  330. * @param srcRaw
  331. * @param pos
  332. * @param dstResponseHeader
  333. * @return
  334. */
  335. UA_Int32 decodeResponseHeader(const UA_ByteString *srcRaw, UA_Int32 *pos, UA_AD_ResponseHeader *dstResponseHeader);
  336. /**
  337. * @brief function to encode a secureChannelRequestHeader
  338. *
  339. * @param header a open secure channel header structure which should be encoded to binary format
  340. * @param dstBuf pointer to a structure which hold the encoded header
  341. * @return
  342. */
  343. UA_Int32 encodeResponseHeader(const UA_AD_ResponseHeader *responseHeader, UA_Int32 *pos, UA_ByteString *dstBuf);
  344. /**
  345. *
  346. * @param diagnosticInfo
  347. * @return length of the binary encoded data
  348. */
  349. UA_Int32 diagnosticInfo_calcSize(UA_DiagnosticInfo *diagnosticInfo);
  350. /**
  351. *
  352. * @param extensionObject
  353. * @return length of the binary encoded data
  354. */
  355. UA_Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject);
  356. #endif /* OPCUA_BINARYENCDEC_NEU_H_ */