ua_connection_internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_connection.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, the ingoing message
  25. * and the current buffer in the connection are freed. */
  26. UA_StatusCode
  27. UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RESTRICT message,
  28. UA_Boolean * UA_RESTRICT realloced);
  29. /* Try to receive at least one complete chunk on the connection. This blocks the
  30. * current thread up to the given timeout.
  31. *
  32. * @param connection The connection
  33. * @param chunk The received chunk. The memory is allocated either by the
  34. * networklayer or internally.
  35. * @param realloced The Boolean value is set to true if the chunk has been
  36. * reallocated from the network layer.
  37. * @param timeout The timeout (in milliseconds) the method will block at most.
  38. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs,
  39. * the chunk buffer is returned empty. Upon a timeout,
  40. * UA_STATUSCODE_GOODNONCRITICALTIMEOUT is returned.
  41. */
  42. UA_StatusCode
  43. UA_Connection_receiveChunksBlocking(UA_Connection *connection, UA_ByteString *chunks,
  44. UA_Boolean *realloced, UA_UInt32 timeout);
  45. void UA_Connection_detachSecureChannel(UA_Connection *connection);
  46. void UA_Connection_attachSecureChannel(UA_Connection *connection, UA_SecureChannel *channel);
  47. /* Split the given endpoint url into hostname and port. Some of the chunks are
  48. * returned as pointer.
  49. * @param endpointUrl The endpoint URL to split up
  50. * @param hostname the target array for hostname. Has to be at least 256 size.
  51. * @param port if url contains port, it will point to the beginning of port.
  52. * NULL otherwise. It may also include the path part, thus stop at
  53. * position of path pointer, if it is not NULL.
  54. * @param path points to the first occurance of '/' after the port or NULL if no
  55. * path in url
  56. * @return UA_STATUSCODE_BADOUTOFRANGE if url too long,
  57. * UA_STATUSCODE_BADATTRIBUTEIDINVALID if url not starting with
  58. * 'opc.tcp://', UA_STATUSCODE_GOOD on success */
  59. UA_StatusCode
  60. UA_EndpointUrl_split_ptr(const char *endpointUrl, char *hostname,
  61. const char ** port, const char ** path);
  62. #ifdef __cplusplus
  63. } // extern "C"
  64. #endif
  65. #endif /* UA_CONNECTION_INTERNAL_H_ */