opcua_transportLayer.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. struct TL_messageBodyHEL
  50. {
  51. UInt32 ProtocolVersion;
  52. UInt32 ReceiveBufferSize;
  53. UInt32 SendBufferSize;
  54. UInt32 MaxMessageSize;
  55. UInt32 MaxChunkCount;
  56. UA_String EndpointUrl;
  57. };
  58. struct TL_messageBodyACK
  59. {
  60. UInt32 ProtocolVersion;
  61. UInt32 ReceiveBufferSize;
  62. UInt32 SendBufferSize;
  63. UInt32 MaxMessageSize;
  64. UInt32 MaxChunkCount;
  65. UA_String EndpointUrl;
  66. };
  67. struct TL_messageBodyERR
  68. {
  69. UInt32 Error;
  70. UA_String Reason;
  71. };
  72. //functions
  73. /**
  74. *
  75. * @param connection connection object
  76. * @param TL_message
  77. * @return
  78. */
  79. Int32 TL_check(UA_connection *connection);
  80. /**
  81. *
  82. * @param connection
  83. * @param TL_message
  84. */
  85. Int32 TL_receive(UA_connection *connection,UA_ByteString *packet);
  86. Int32 TL_send(UA_connection *connection, UA_ByteString *packet);
  87. Int32 TL_getPacketType(UA_ByteString *packet, Int32 *pos);
  88. #endif /* OPCUA_TRANSPORTLAYER_H_ */