ua_transportLayer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * ua_transportLayer.h
  3. *
  4. * Created on: Dec 19, 2013
  5. * Author: opcua
  6. */
  7. #ifndef OPCUA_TRANSPORTLAYER_H_
  8. #define OPCUA_TRANSPORTLAYER_H_
  9. #include <stdio.h>
  10. #include "opcua.h"
  11. #include "ua_connection.h"
  12. #include "ua_stackInternalTypes.h"
  13. /*------------------Defined Error Codes------------------*/
  14. //transport errors begin at 1000
  15. #define UA_ERROR_MULTIPLE_HEL 1000
  16. #define UA_ERROR_RCV_ERROR 1001
  17. /*------------------Defined Lengths------------------*/
  18. #define SIZE_OF_ACKNOWLEDGE_MESSAGE 28
  19. //constants
  20. static const UA_UInt32 TL_HEADER_LENGTH = 8;
  21. static const UA_UInt32 TL_MESSAGE_TYPE_LEN = 3;
  22. static const UA_UInt32 TL_RESERVED_LEN = 1;
  23. //variables which belong to layer
  24. #define TL_SERVER_PROTOCOL_VERSION 0
  25. #define TL_SERVER_MAX_CHUNK_COUNT 1
  26. #define TL_SERVER_MAX_MESSAGE_SIZE 8192
  27. enum TL_messageType_td
  28. {
  29. TL_MESSAGETYPE_HEL = 1,
  30. TL_MESSAGETYPE_ACK = 2,
  31. TL_MESSAGETYPE_ERR = 3,
  32. TL_MESSAGETYPE_OPN = 4,
  33. TL_MESSAGETYPE_CLO = 5,
  34. TL_MESSAGETYPE_MSG = 6
  35. }TL_messageType;
  36. struct TL_header
  37. {
  38. UA_UInt32 MessageType;
  39. UA_Byte Reserved;
  40. UA_UInt32 MessageSize;
  41. };
  42. struct TL_message
  43. {
  44. struct TL_header Header;
  45. char *message;
  46. };
  47. struct TL_messageBodyHEL
  48. {
  49. UA_UInt32 ProtocolVersion;
  50. UA_UInt32 ReceiveBufferSize;
  51. UA_UInt32 SendBufferSize;
  52. UA_UInt32 MaxMessageSize;
  53. UA_UInt32 MaxChunkCount;
  54. UA_String EndpointUrl;
  55. };
  56. struct TL_messageBodyACK
  57. {
  58. UA_UInt32 ProtocolVersion;
  59. UA_UInt32 ReceiveBufferSize;
  60. UA_UInt32 SendBufferSize;
  61. UA_UInt32 MaxMessageSize;
  62. UA_UInt32 MaxChunkCount;
  63. UA_String EndpointUrl;
  64. };
  65. struct TL_messageBodyERR
  66. {
  67. UA_UInt32 Error;
  68. UA_String Reason;
  69. };
  70. //functions
  71. /**
  72. *
  73. * @param connection connection object
  74. * @param TL_message
  75. * @return
  76. */
  77. enum UA_TL_CHECK_enum {
  78. UA_TL_CHECK_LOCAL = 0,
  79. UA_TL_CHECK_REMOTE = 1
  80. };
  81. UA_Int32 TL_check(UA_TL_connection *connection, UA_ByteString* msg, UA_Int32 local);
  82. /**
  83. *
  84. * @param connection
  85. * @param TL_message
  86. */
  87. UA_Int32 TL_receive(UA_TL_connection *connection,UA_ByteString *packet);
  88. UA_Int32 TL_send(UA_TL_connection *connection, UA_ByteString *packet);
  89. UA_Int32 TL_getPacketType(UA_ByteString *packet, UA_Int32 *pos);
  90. UA_Int32 TL_process(UA_TL_connection *connection, UA_ByteString *packet);
  91. #endif /* OPCUA_TRANSPORTLAYER_H_ */