ua_connection_internal.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef UA_CONNECTION_INTERNAL_H_
  5. #define UA_CONNECTION_INTERNAL_H_
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include "ua_plugin_network.h"
  10. /* The network layer may receive chopped up messages since TCP is a streaming
  11. * protocol. Furthermore, the networklayer may operate on ringbuffers or
  12. * statically assigned memory.
  13. *
  14. * If an entire message is received, it is forwarded directly. But the memory
  15. * needs to be freed with the networklayer-specific mechanism. If a half message
  16. * is received, we copy it into a local buffer. Then, the stack-specific free
  17. * needs to be used.
  18. *
  19. * @param connection The connection
  20. * @param message The received message. The content may be overwritten when a
  21. * previsouly received buffer is completed.
  22. * @param realloced The Boolean value is set to true if the outgoing message has
  23. * been reallocated from the network layer.
  24. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs,
  25. * the ingoing message and the current buffer in the connection are
  26. * freed. */
  27. UA_StatusCode
  28. UA_Connection_completeMessages(UA_Connection *connection,
  29. UA_ByteString * UA_RESTRICT message,
  30. UA_Boolean * UA_RESTRICT realloced);
  31. /* Try to receive at least one complete chunk on the connection. This blocks the
  32. * current thread up to the given timeout.
  33. *
  34. * @param connection The connection
  35. * @param chunk The received chunk. The memory is allocated either by the
  36. * networklayer or internally.
  37. * @param realloced The Boolean value is set to true if the chunk has been
  38. * reallocated from the network layer.
  39. * @param timeout The timeout (in milliseconds) the method will block at most.
  40. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs,
  41. * the chunk buffer is returned empty. Upon a timeout,
  42. * UA_STATUSCODE_GOODNONCRITICALTIMEOUT is returned.
  43. */
  44. UA_StatusCode
  45. UA_Connection_receiveChunksBlocking(UA_Connection *connection,
  46. UA_ByteString *chunks,
  47. UA_Boolean *realloced,
  48. UA_UInt32 timeout);
  49. void UA_Connection_detachSecureChannel(UA_Connection *connection);
  50. void UA_Connection_attachSecureChannel(UA_Connection *connection,
  51. UA_SecureChannel *channel);
  52. #ifdef __cplusplus
  53. } // extern "C"
  54. #endif
  55. #endif /* UA_CONNECTION_INTERNAL_H_ */