ua_connection_internal.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include "ua_transport_generated.h"
  11. /* The application can be the client or the server */
  12. typedef UA_StatusCode (*UA_Connection_processChunk)(void *application,
  13. UA_Connection *connection,
  14. UA_ByteString *chunk);
  15. /* The network layer may receive chopped up messages since TCP is a streaming
  16. * protocol. This method calls the processChunk callback on all full chunks that
  17. * were received. Dangling half-complete chunks are buffered in the connection
  18. * and considered for the next received packet.
  19. *
  20. * If an entire chunk is received, it is forwarded directly. But the memory
  21. * needs to be freed with the networklayer-specific mechanism. If a half message
  22. * is received, we copy it into a local buffer. Then, the stack-specific free
  23. * needs to be used.
  24. *
  25. * @param connection The connection
  26. * @param application The client or server application
  27. * @param processCallback The function pointer for processing each chunk
  28. * @param packet The received packet.
  29. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs,
  30. * the ingoing message and the current buffer in the connection are
  31. * freed. */
  32. UA_StatusCode
  33. UA_Connection_processChunks(UA_Connection *connection, void *application,
  34. UA_Connection_processChunk processCallback,
  35. const UA_ByteString *packet);
  36. /* Try to receive at least one complete chunk on the connection. This blocks the
  37. * current thread up to the given timeout.
  38. *
  39. * @param connection The connection
  40. * @param application The client or server application
  41. * @param processCallback The function pointer for processing each chunk
  42. * @param timeout The timeout (in milliseconds) the method will block at most.
  43. * @return Returns UA_STATUSCODE_GOOD or an error code. When an timeout occurs,
  44. * UA_STATUSCODE_GOODNONCRITICALTIMEOUT is returned. */
  45. UA_StatusCode
  46. UA_Connection_receiveChunksBlocking(UA_Connection *connection, void *application,
  47. UA_Connection_processChunk processCallback,
  48. UA_UInt32 timeout);
  49. /* When a fatal error occurs the Server shall send an Error Message to the
  50. * Client and close the socket. When a Client encounters one of these errors, it
  51. * shall also close the socket but does not send an Error Message. After the
  52. * socket is closed a Client shall try to reconnect automatically using the
  53. * mechanisms described in [...]. */
  54. void
  55. UA_Connection_sendError(UA_Connection *connection,
  56. UA_TcpErrorMessage *error);
  57. void UA_Connection_detachSecureChannel(UA_Connection *connection);
  58. void UA_Connection_attachSecureChannel(UA_Connection *connection,
  59. UA_SecureChannel *channel);
  60. #ifdef __cplusplus
  61. } // extern "C"
  62. #endif
  63. #endif /* UA_CONNECTION_INTERNAL_H_ */