ua_connection_internal.h 3.0 KB

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