opcua_transportLayer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * opcua_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_binaryEncDec.h"
  11. #include "opcua_advancedDatatypes.h"
  12. #include "opcua_connectionHelper.h"
  13. //TODO : Implement this interface
  14. #include "tcp_layer.h"
  15. /*------------------Defined Error Codes------------------*/
  16. //transport errors begin at 1000
  17. #define UA_ERROR_MULTIPLY_HEL 1000
  18. #define UA_ERROR_RCV_ERROR 1001
  19. /*------------------Defined Lengths------------------*/
  20. #define SIZE_OF_ACKNOWLEDGE_MESSAGE 28
  21. //constants
  22. static const UInt32 TL_HEADER_LENGTH = 8;
  23. static const UInt32 TL_MESSAGE_TYPE_LEN = 3;
  24. static const UInt32 TL_RESERVED_LEN = 1;
  25. //variables which belong to layer
  26. static const TL_SERVER_PROTOCOL_VERSION = 0;
  27. static const TL_SERVER_MAX_CHUNK_COUNT = 1;
  28. static const TL_SERVER_MAX_MESSAGE_SIZE = 8192;
  29. enum TL_messageType_td
  30. {
  31. TL_HEL = 1,
  32. TL_ACK = 2,
  33. TL_ERR = 3,
  34. TL_OPN = 4,
  35. TL_CLO = 5,
  36. TL_MSG = 6
  37. }TL_messageType;
  38. struct TL_header
  39. {
  40. UInt32 MessageType;
  41. Byte Reserved;
  42. UInt32 MessageSize;
  43. };
  44. struct TL_message
  45. {
  46. struct TL_header Header;
  47. char *message;
  48. };
  49. typedef struct UA_T_SecureConversationMessageHeader
  50. {
  51. UA_ByteString messageType;
  52. UA_Byte isFinal;
  53. UA_UInt32 messageSize;
  54. UA_UInt32 secureChannelId;
  55. }UA_SecureConversationMessageHeader;
  56. typedef _Bool UA_Boolean;
  57. UA_TYPE_METHOD_PROTOTYPES (UA_SecureConversationMessageHeader)
  58. struct TL_messageBodyHEL
  59. {
  60. UInt32 ProtocolVersion;
  61. UInt32 ReceiveBufferSize;
  62. UInt32 SendBufferSize;
  63. UInt32 MaxMessageSize;
  64. UInt32 MaxChunkCount;
  65. UA_String EndpointUrl;
  66. };
  67. struct TL_messageBodyACK
  68. {
  69. UInt32 ProtocolVersion;
  70. UInt32 ReceiveBufferSize;
  71. UInt32 SendBufferSize;
  72. UInt32 MaxMessageSize;
  73. UInt32 MaxChunkCount;
  74. UA_String EndpointUrl;
  75. };
  76. struct TL_messageBodyERR
  77. {
  78. UInt32 Error;
  79. UA_String Reason;
  80. };
  81. //functions
  82. /**
  83. *
  84. * @param connection connection object
  85. * @param TL_message
  86. * @return
  87. */
  88. UA_Int32 TL_check(UA_connection *connection);
  89. /**
  90. *
  91. * @param connection
  92. * @param TL_message
  93. */
  94. UA_Int32 TL_receive(UA_connection *connection,UA_ByteString *packet);
  95. UA_Int32 TL_send(UA_connection *connection, UA_ByteString *packet);
  96. UA_Int32 TL_getPacketType(UA_ByteString *packet, UA_Int32 *pos);
  97. #endif /* OPCUA_TRANSPORTLAYER_H_ */