opcua_binaryEncDec.h 6.5 KB

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