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. /** @defgroup communication Communication */
  22. /**
  23. * @ingroup communication
  24. * @defgroup connection Connection */
  25. /** Used for zero-copy communication. The array of bytestrings is sent over the
  26. network as a single buffer. */
  27. typedef struct UA_ByteStringArray {
  28. UA_UInt32 stringsSize;
  29. UA_ByteString *strings;
  30. } UA_ByteStringArray;
  31. typedef enum UA_ConnectionState {
  32. UA_CONNECTION_OPENING,
  33. UA_CONNECTION_CLOSING,
  34. UA_CONNECTION_ESTABLISHED
  35. } UA_ConnectionState;
  36. typedef struct UA_ConnectionConfig {
  37. UA_UInt32 protocolVersion;
  38. UA_UInt32 sendBufferSize;
  39. UA_UInt32 recvBufferSize;
  40. UA_UInt32 maxMessageSize;
  41. UA_UInt32 maxChunkCount;
  42. } UA_ConnectionConfig;
  43. extern UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_standard;
  44. /* Forward declaration */
  45. struct UA_SecureChannel;
  46. typedef struct UA_SecureChannel UA_SecureChannel;
  47. typedef void (*UA_Connection_writeCallback)(void *handle, const UA_ByteStringArray buf);
  48. typedef void (*UA_Connection_closeCallback)(void *handle);
  49. typedef struct UA_Connection {
  50. UA_ConnectionState state;
  51. UA_ConnectionConfig localConf;
  52. UA_ConnectionConfig remoteConf;
  53. UA_SecureChannel *channel;
  54. void *callbackHandle;
  55. UA_Connection_writeCallback write;
  56. UA_Connection_closeCallback close;
  57. } UA_Connection;
  58. UA_StatusCode UA_EXPORT UA_Connection_init(UA_Connection *connection, UA_ConnectionConfig localConf, void *callbackHandle,
  59. UA_Connection_closeCallback close, UA_Connection_writeCallback write);
  60. void UA_EXPORT UA_Connection_deleteMembers(UA_Connection *connection);
  61. // todo: closing a binaryconnection that was closed on the network level
  62. #ifdef __cplusplus
  63. } // extern "C"
  64. #endif
  65. #endif /* UA_CONNECTION_H_ */