opcua_binaryEncDec.h 5.9 KB

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