ua_connection_internal.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. *
  5. * Copyright 2016-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2016-2017 (c) Stefan Profanter, fortiss GmbH
  7. * Copyright 2017 (c) Florian Palm
  8. * Copyright 2017 (c) Mark Giraud, Fraunhofer IOSB
  9. */
  10. #ifndef UA_CONNECTION_INTERNAL_H_
  11. #define UA_CONNECTION_INTERNAL_H_
  12. #include <open62541/plugin/network.h>
  13. #include <open62541/transport_generated.h>
  14. _UA_BEGIN_DECLS
  15. /* Process the remote configuration in the HEL/ACK handshake. The connection
  16. * config is initialized with the local settings. */
  17. UA_StatusCode
  18. UA_Connection_processHELACK(UA_Connection *connection,
  19. const UA_ConnectionConfig *localConfig,
  20. const UA_ConnectionConfig *remoteConfig);
  21. /* The application can be the client or the server */
  22. typedef UA_StatusCode (*UA_Connection_processChunk)(void *application,
  23. UA_Connection *connection,
  24. UA_ByteString *chunk);
  25. /* The network layer may receive several chunks in one packet since TCP is a
  26. * streaming protocol. The last chunk in the packet may be only partial. This
  27. * method calls the processChunk callback on all full chunks that were received.
  28. * The last incomplete chunk is buffered in the connection for the next
  29. * iteration.
  30. *
  31. * The packet itself is not edited in this method. But possibly in the callback
  32. * that is executed on complete chunks.
  33. *
  34. * @param connection The connection
  35. * @param application The client or server application
  36. * @param processCallback The function pointer for processing each chunk
  37. * @param packet The received packet.
  38. * @return Returns UA_STATUSCODE_GOOD or an error code. When an error occurs,
  39. * the current buffer in the connection are
  40. * freed. */
  41. UA_StatusCode
  42. UA_Connection_processChunks(UA_Connection *connection, void *application,
  43. UA_Connection_processChunk processCallback,
  44. const UA_ByteString *packet);
  45. /* Try to receive at least one complete chunk on the connection. This blocks the
  46. * current thread up to the given timeout.
  47. *
  48. * @param connection The connection
  49. * @param application The client or server application
  50. * @param processCallback The function pointer for processing each chunk
  51. * @param timeout The timeout (in milliseconds) the method will block at most.
  52. * @return Returns UA_STATUSCODE_GOOD or an error code. When an timeout occurs,
  53. * UA_STATUSCODE_GOODNONCRITICALTIMEOUT is returned. */
  54. UA_StatusCode
  55. UA_Connection_receiveChunksBlocking(UA_Connection *connection, void *application,
  56. UA_Connection_processChunk processCallback,
  57. UA_UInt32 timeout);
  58. UA_StatusCode
  59. UA_Connection_receiveChunksNonBlocking(UA_Connection *connection, void *application,
  60. UA_Connection_processChunk processCallback);
  61. /* When a fatal error occurs the Server shall send an Error Message to the
  62. * Client and close the socket. When a Client encounters one of these errors, it
  63. * shall also close the socket but does not send an Error Message. After the
  64. * socket is closed a Client shall try to reconnect automatically using the
  65. * mechanisms described in [...]. */
  66. void
  67. UA_Connection_sendError(UA_Connection *connection,
  68. UA_TcpErrorMessage *error);
  69. void UA_Connection_detachSecureChannel(UA_Connection *connection);
  70. void UA_Connection_attachSecureChannel(UA_Connection *connection,
  71. UA_SecureChannel *channel);
  72. _UA_END_DECLS
  73. #endif /* UA_CONNECTION_INTERNAL_H_ */