opcua_binaryEncDec.h 6.2 KB

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