testing_networklayers.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 TESTING_NETWORKLAYERS_H_
  5. #define TESTING_NETWORKLAYERS_H_
  6. #include "ua_server_config.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /**
  11. * Create the TCP networklayer and listen to the specified port
  12. *
  13. * @param sendBufferSize The send buffer is reused. This is the max chunk size
  14. * @param verificationBuffer the send function will copy the data that is sent
  15. * to this buffer, so that it is possible to check what the send function
  16. * received. */
  17. UA_Connection createDummyConnection(size_t sendBufferSize,
  18. UA_ByteString *verificationBuffer);
  19. /**
  20. * Simulate network timing conditions
  21. * ---------------------------------- */
  22. extern UA_UInt32 UA_Client_recvSleepDuration;
  23. extern UA_StatusCode (*UA_Client_recv)(UA_Connection *connection, UA_ByteString *response,
  24. UA_UInt32 timeout);
  25. extern UA_StatusCode UA_Client_recvTesting_result;
  26. /* Override the client recv method to increase the simulated clock after the first recv.
  27. * UA_Client_recvSleepDuration is set to zero after the first recv.
  28. * UA_Client_recvTesting_result can be used to simulate an error */
  29. UA_StatusCode
  30. UA_Client_recvTesting(UA_Connection *connection, UA_ByteString *response,
  31. UA_UInt32 timeout);
  32. #ifdef __cplusplus
  33. }
  34. #endif
  35. #endif /* TESTING_NETWORKLAYERS_H_ */