opcua_binaryEncDec.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. //functions
  13. /**
  14. *
  15. * @param buf binary encoded message
  16. * @param pos position at which the data is located in/out, parser position after the conversion
  17. * @return
  18. */
  19. Byte decodeByte(const char* buf, Int32 *pos);
  20. /**
  21. *
  22. * @param encodeByte byte that should be encoded
  23. * @param pos position at which the data is located in/out, parser position after the conversion
  24. * @param dstBuf rawMessage where the Byte is encoded in
  25. */
  26. void encodeByte(Byte encodeByte, Int32 *pos, AD_RawMessage *dstBuf);
  27. /**
  28. *
  29. * @param buf
  30. * @param pos
  31. * @return
  32. */
  33. Int16 decodeInt16(const char* buf, Int32 *pos);
  34. /**
  35. *
  36. * @param value
  37. * @param pos
  38. * @param dstBuf
  39. */
  40. void encodeUInt16(UInt16 value, Int32 *pos, AD_RawMessage *dstBuf);
  41. /**
  42. *
  43. * @param buf
  44. * @param pos
  45. * @return
  46. */
  47. UInt16 decodeUInt16(const char* buf, Int32 *pos);
  48. /**
  49. *
  50. * @param buf binary encoded message
  51. * @param pos position at which the data is located in/out, parser position after the conversion
  52. * @return
  53. */
  54. Int32 decodeInt32(const char* buf, Int32 *pos);
  55. /**
  56. *
  57. * @param buf binary encoded message
  58. * @param pos position at which the data is located in/out, parser position after the conversion
  59. * @return encoded data
  60. */
  61. UInt32 decodeUInt32(const char* buf, Int32 *pos);
  62. /**
  63. *
  64. * @param buf
  65. * @param pos
  66. * @return
  67. */
  68. Int64 decodeInt64(const char* buf, Int32 *pos);
  69. /**
  70. *
  71. * @param buf binary encoded message
  72. * @param pos position at which the data is located in/out, parser position after the conversion
  73. * @param dstNodeId receiver of the nodeid structure
  74. * @param return success = 0
  75. */
  76. Int32 decodeUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId);
  77. /**
  78. *
  79. * @param buf
  80. * @param pos
  81. * @param dstGUID
  82. * @return
  83. */
  84. Int32 decodeUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID);
  85. /**
  86. *
  87. * @param buf
  88. * @param pos
  89. * @return
  90. */
  91. UA_StatusCode decodeUAStatusCode(const char* buf, Int32 *pos);
  92. /**
  93. *
  94. * @param buf
  95. * @param pos
  96. * @return
  97. */
  98. UA_DateTime decodeUADateTime(const char *buf, Int32 *pos);
  99. /**
  100. *
  101. * @param buf
  102. * @param pos
  103. * @param dstUAString
  104. * @return
  105. */
  106. Int32 decodeUAString(const char* buf, Int32 *pos, UA_String *dstUAString);
  107. /**
  108. *
  109. * @param value
  110. * @param dstBuf
  111. * @param pos
  112. */
  113. void encodeUInt32(UInt32 value, char *dstBuf, Int32 *pos);
  114. /**
  115. * \brief
  116. * \param srcRaw pointer to raw data which holds the encoded data
  117. * \param pos
  118. * \param dstRequestHeader pointer to a structure which hold the encoded header
  119. * \return 0 = success
  120. */
  121. Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,Int32 *pos, T_RequestHeader *dstRequestHeader);
  122. /**
  123. *
  124. * @param srcHeader
  125. * @param pos
  126. * @param dstRaw
  127. * @return
  128. */
  129. Int32 encodeRequestHeader(const T_RequestHeader *srcHeader,Int32 *pos,AD_RawMessage *dstRaw);
  130. /**
  131. *
  132. * @param srcRaw
  133. * @param pos
  134. * @param dstResponseHeader
  135. * @return
  136. */
  137. Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, Int32 *pos, T_ResponseHeader *dstResponseHeader);
  138. /**
  139. * @brief function to encode a secureChannelRequestHeader
  140. *
  141. * @param header a open secure channel header structure which should be encoded to binary format
  142. * @param dstBuf pointer to a structure which hold the encoded header
  143. * @return
  144. */
  145. Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf);
  146. /**
  147. *
  148. * @param diagnosticInfo
  149. * @return length of the binary encoded data
  150. */
  151. Int32 diagnosticInfo_calcSize(UA_DiagnosticInfo *diagnosticInfo);
  152. /**
  153. *
  154. * @param extensionObject
  155. * @return length of the binary encoded data
  156. */
  157. Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject);
  158. #endif /* OPCUA_BINARYENCDEC_NEU_H_ */