testing_networklayers.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. /** @brief Create the TCP networklayer and listen to the specified port
  11. *
  12. * @param verificationBuffer the send function will write the data that is sent to this buffer, so that it is
  13. * possible to check what the send function recieved.
  14. */
  15. UA_Connection createDummyConnection(UA_ByteString *verificationBuffer);
  16. /**
  17. * Simulate network timing conditions
  18. * ---------------------------------- */
  19. extern UA_UInt32 UA_Client_recvSleepDuration;
  20. extern UA_StatusCode (*UA_Client_recv)(UA_Connection *connection, UA_ByteString *response,
  21. UA_UInt32 timeout);
  22. extern UA_StatusCode UA_Client_recvTesting_result;
  23. /* Override the client recv method to increase the simulated clock after the first recv.
  24. * UA_Client_recvSleepDuration is set to zero after the first recv.
  25. * UA_Client_recvTesting_result can be used to simulate an error */
  26. UA_StatusCode
  27. UA_Client_recvTesting(UA_Connection *connection, UA_ByteString *response,
  28. UA_UInt32 timeout);
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif /* TESTING_NETWORKLAYERS_H_ */