ua_connection.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef UA_CONNECTION_H_
  2. #define UA_CONNECTION_H_
  3. #include "ua_transport.h"
  4. /* used for zero-copy communication. the array of bytestrings is sent over the
  5. network as a single buffer. */
  6. typedef struct UA_ByteStringArray {
  7. UA_UInt32 stringsSize;
  8. UA_ByteString *strings;
  9. } UA_ByteStringArray;
  10. UA_Int32 UA_ByteStringArray_init(UA_ByteStringArray *stringarray, UA_UInt32 length);
  11. UA_Int32 UA_ByteStringArray_deleteMembers(UA_ByteStringArray *stringarray);
  12. typedef enum UA_ConnectionState {
  13. UA_CONNECTION_OPENING,
  14. UA_CONNECTION_CLOSING,
  15. UA_CONNECTION_ESTABLISHED
  16. } UA_ConnectionState;
  17. typedef struct UA_ConnectionConfig {
  18. UA_UInt32 protocolVersion;
  19. UA_UInt32 sendBufferSize;
  20. UA_UInt32 recvBufferSize;
  21. UA_UInt32 maxMessageSize;
  22. UA_UInt32 maxChunkCount;
  23. } UA_ConnectionConfig;
  24. extern UA_ConnectionConfig UA_ConnectionConfig_standard;
  25. /* Forward declaration */
  26. struct UA_SecureChannel;
  27. typedef struct UA_SecureChannel UA_SecureChannel;
  28. typedef UA_Int32 (*UA_Connection_writeCallback)(void *handle, UA_ByteStringArray *buf);
  29. typedef UA_Int32 (*UA_Connection_closeCallback)(void *handle);
  30. typedef struct UA_Connection {
  31. UA_ConnectionState state;
  32. UA_ConnectionConfig localConf;
  33. UA_ConnectionConfig remoteConf;
  34. UA_SecureChannel *channel;
  35. void *callbackHandle;
  36. UA_Connection_writeCallback write;
  37. UA_Connection_closeCallback close;
  38. } UA_Connection;
  39. UA_Int32 UA_Connection_init(UA_Connection *connection, UA_ConnectionConfig localConf,
  40. void *callbackHandle, UA_Int32 (*close)(void *handle),
  41. UA_Int32 (*write)(void *handle, UA_ByteStringArray *buf));
  42. UA_Int32 UA_Connection_deleteMembers(UA_Connection *connection);
  43. // todo: closing a binaryconnection that was closed on the network level
  44. #endif /* UA_CONNECTION_H_ */