opcua_transportLayer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.h"
  11. #include "UA_connection.h"
  12. #include "UA_stackInternalTypes.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 UA_UInt32 TL_HEADER_LENGTH = 8;
  23. static const UA_UInt32 TL_MESSAGE_TYPE_LEN = 3;
  24. static const UA_UInt32 TL_RESERVED_LEN = 1;
  25. //variables which belong to layer
  26. #define TL_SERVER_PROTOCOL_VERSION 0
  27. #define TL_SERVER_MAX_CHUNK_COUNT 1
  28. #define TL_SERVER_MAX_MESSAGE_SIZE 8192
  29. enum TL_messageType_td
  30. {
  31. TL_MESSAGETYPE_HEL = 1,
  32. TL_MESSAGETYPE_ACK = 2,
  33. TL_MESSAGETYPE_ERR = 3,
  34. TL_MESSAGETYPE_OPN = 4,
  35. TL_MESSAGETYPE_CLO = 5,
  36. TL_MESSAGETYPE_MSG = 6
  37. }TL_messageType;
  38. struct TL_header
  39. {
  40. UA_UInt32 MessageType;
  41. UA_Byte Reserved;
  42. UA_UInt32 MessageSize;
  43. };
  44. struct TL_message
  45. {
  46. struct TL_header Header;
  47. char *message;
  48. };
  49. struct TL_messageBodyHEL
  50. {
  51. UA_UInt32 ProtocolVersion;
  52. UA_UInt32 ReceiveBufferSize;
  53. UA_UInt32 SendBufferSize;
  54. UA_UInt32 MaxMessageSize;
  55. UA_UInt32 MaxChunkCount;
  56. UA_String EndpointUrl;
  57. };
  58. struct TL_messageBodyACK
  59. {
  60. UA_UInt32 ProtocolVersion;
  61. UA_UInt32 ReceiveBufferSize;
  62. UA_UInt32 SendBufferSize;
  63. UA_UInt32 MaxMessageSize;
  64. UA_UInt32 MaxChunkCount;
  65. UA_String EndpointUrl;
  66. };
  67. struct TL_messageBodyERR
  68. {
  69. UA_UInt32 Error;
  70. UA_String Reason;
  71. };
  72. //functions
  73. /**
  74. *
  75. * @param connection connection object
  76. * @param TL_message
  77. * @return
  78. */
  79. enum UA_TL_CHECK_enum {
  80. UA_TL_CHECK_LOCAL = 0,
  81. UA_TL_CHECK_REMOTE = 1
  82. };
  83. UA_Int32 TL_check(TL_connection *connection, UA_ByteString* msg, UA_Int32 local);
  84. /**
  85. *
  86. * @param connection
  87. * @param TL_message
  88. */
  89. UA_Int32 TL_receive(TL_connection *connection,UA_ByteString *packet);
  90. UA_Int32 TL_send(TL_connection *connection, UA_ByteString *packet);
  91. UA_Int32 TL_getPacketType(UA_ByteString *packet, UA_Int32 *pos);
  92. UA_Int32 TL_process(TL_connection *connection, UA_ByteString *packet, UA_Int32 packetType, UA_Int32 *pos);
  93. #endif /* OPCUA_TRANSPORTLAYER_H_ */