ua_connection.h 2.4 KB

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