ua_connection.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (C) 2014 the contributors as stated in the AUTHORS file
  3. *
  4. * This file is part of open62541. open62541 is free software: you can
  5. * redistribute it and/or modify it under the terms of the GNU Lesser General
  6. * Public License, version 3 (as published by the Free Software Foundation) with
  7. * a static linking exception as stated in the LICENSE file provided with
  8. * open62541.
  9. *
  10. * open62541 is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. #ifndef UA_CONNECTION_H_
  16. #define UA_CONNECTION_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "ua_types.h"
  21. /**
  22. * @defgroup communication Communication
  23. *
  24. * @{
  25. */
  26. /** Used for zero-copy communication. The array of bytestrings is sent over the
  27. network as a single buffer. */
  28. typedef struct UA_ByteStringArray {
  29. UA_UInt32 stringsSize;
  30. UA_ByteString *strings;
  31. } UA_ByteStringArray;
  32. typedef enum UA_ConnectionState {
  33. UA_CONNECTION_OPENING, ///< The port is open, but we haven't received a HEL
  34. UA_CONNECTION_ESTABLISHED, ///< The port is open and the connection configured
  35. UA_CONNECTION_CLOSING, ///< The port has been closed and the connection will be deleted
  36. } UA_ConnectionState;
  37. typedef struct UA_ConnectionConfig {
  38. UA_UInt32 protocolVersion;
  39. UA_UInt32 sendBufferSize;
  40. UA_UInt32 recvBufferSize;
  41. UA_UInt32 maxMessageSize;
  42. UA_UInt32 maxChunkCount;
  43. } UA_ConnectionConfig;
  44. extern const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_standard;
  45. /* Forward declaration */
  46. struct UA_SecureChannel;
  47. typedef struct UA_SecureChannel UA_SecureChannel;
  48. typedef struct UA_Connection {
  49. UA_ConnectionState state;
  50. UA_ConnectionConfig localConf;
  51. UA_ConnectionConfig remoteConf;
  52. UA_SecureChannel *channel;
  53. void (*write)(void *connection, UA_ByteStringArray buf);
  54. void (*close)(void *connection);
  55. UA_ByteString incompleteMessage;
  56. } UA_Connection;
  57. void UA_EXPORT UA_Connection_detachSecureChannel(UA_Connection *connection);
  58. // void UA_Connection_attachSecureChannel(UA_Connection *connection);
  59. /** Returns a string of complete message (the length entry is decoded for that).
  60. If the received message is incomplete, it is retained in the connection. */
  61. UA_ByteString UA_EXPORT UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString received);
  62. /** @} */
  63. #ifdef __cplusplus
  64. } // extern "C"
  65. #endif
  66. #endif /* UA_CONNECTION_H_ */