opcua_transportLayer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. //constants
  16. static const UInt32 TL_HEADER_LENGTH = 8;
  17. static const UInt32 TL_MESSAGE_TYPE_LEN = 3;
  18. static const UInt32 TL_RESERVED_LEN = 1;
  19. //variables which belong to layer
  20. static const TL_SERVER_PROTOCOL_VERSION = 0;
  21. static const TL_SERVER_MAX_CHUNK_COUNT = 1;
  22. static const TL_SERVER_MAX_MESSAGE_SIZE = 8192;
  23. enum TL_messageType_td
  24. {
  25. TL_HEL,
  26. TL_ACK,
  27. TL_ERR,
  28. TL_OPN,
  29. TL_CLO,
  30. TL_MSG
  31. }TL_messageType;
  32. struct TL_header
  33. {
  34. UInt32 MessageType;
  35. Byte Reserved;
  36. UInt32 MessageSize;
  37. };
  38. struct TL_message
  39. {
  40. struct TL_header Header;
  41. char *message;
  42. };
  43. struct TL_messageBodyHEL
  44. {
  45. UInt32 ProtocolVersion;
  46. UInt32 ReceiveBufferSize;
  47. UInt32 SendBufferSize;
  48. UInt32 MaxMessageSize;
  49. UInt32 MaxChunkCount;
  50. UA_String EndpointUrl;
  51. };
  52. struct TL_messageBodyACK
  53. {
  54. UInt32 ProtocolVersion;
  55. UInt32 ReceiveBufferSize;
  56. UInt32 SendBufferSize;
  57. UInt32 MaxMessageSize;
  58. UInt32 MaxChunkCount;
  59. UA_String EndpointUrl;
  60. };
  61. struct TL_messageBodyERR
  62. {
  63. UInt32 Error;
  64. UA_String Reason;
  65. };
  66. //functions
  67. void TL_receive(UA_connection *connection, AD_RawMessage *TL_message);
  68. //Test
  69. void TL_getMessageHeader_test();
  70. Int32 TL_getPacketType(AD_RawMessage *rawMessage);
  71. void TL_getMessageHeader(struct TL_header *messageHeader,AD_RawMessage *rawMessage);
  72. //Test
  73. void TL_processHELMessage_test();
  74. void TL_processHELMessage(UA_connection *connection, AD_RawMessage *rawMessage);
  75. #endif /* OPCUA_TRANSPORTLAYER_H_ */