ua_connection_internal.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "ua_connection.h"
  7. /* The network layer may receive chopped up messages since TCP is a streaming
  8. * protocol. Furthermore, the networklayer may operate on ringbuffers or
  9. * statically assigned memory.
  10. *
  11. * If an entire message is received, it is forwarded directly. But the memory
  12. * needs to be freed with the networklayer-specific mechanism. If a half message
  13. * is received, we copy it into a local buffer. Then, the stack-specific free
  14. * needs to be used.
  15. *
  16. * @param connection The connection
  17. * @param message The received message. The content may be overwritten when a
  18. * previsouly received buffer is completed.
  19. * @param realloced The Boolean value is set to true if the outgoing message has
  20. * been reallocated from the network layer.
  21. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs, the ingoing message
  22. * and the current buffer in the connection are freed. */
  23. UA_StatusCode
  24. UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString *message,
  25. UA_Boolean *realloced);
  26. /* Try to receive at least one complete chunk on the connection. This blocks the
  27. * current thread up to the given timeout.
  28. *
  29. * @param connection The connection
  30. * @param chunk The received chunk. The memory is allocated either by the
  31. * networklayer or internally.
  32. * @param realloced The Boolean value is set to true if the chunk has been
  33. * reallocated from the network layer.
  34. * @param timeout The timeout (in milliseconds) the method will block at most.
  35. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs,
  36. * the chunk buffer is returned empty. Upon a timeout,
  37. * UA_STATUSCODE_GOODNONCRITICALTIMEOUT is returned.
  38. */
  39. UA_StatusCode
  40. UA_Connection_receiveChunksBlocking(UA_Connection *connection, UA_ByteString *chunks,
  41. UA_Boolean *realloced, UA_UInt32 timeout);
  42. void UA_Connection_detachSecureChannel(UA_Connection *connection);
  43. void UA_Connection_attachSecureChannel(UA_Connection *connection, UA_SecureChannel *channel);
  44. /* Split the given endpoint url into hostname and port. Some of the chunks are
  45. * returned as pointer.
  46. * @param endpointUrl The endpoint URL to split up
  47. * @param hostname the target array for hostname. Has to be at least 256 size.
  48. * @param port if url contains port, it will point to the beginning of port.
  49. * NULL otherwise. It may also include the path part, thus stop at
  50. * position of path pointer, if it is not NULL.
  51. * @param path points to the first occurance of '/' after the port or NULL if no
  52. * path in url
  53. * @return UA_STATUSCODE_BADOUTOFRANGE if url too long,
  54. * UA_STATUSCODE_BADATTRIBUTEIDINVALID if url not starting with
  55. * 'opc.tcp://', UA_STATUSCODE_GOOD on success */
  56. UA_StatusCode
  57. UA_EndpointUrl_split_ptr(const char *endpointUrl, char *hostname,
  58. const char ** port, const char ** path);
  59. #endif /* UA_CONNECTION_INTERNAL_H_ */