testing_networklayers.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <stdlib.h>
  2. #include "testing_networklayers.h"
  3. static UA_StatusCode
  4. dummyGetSendBuffer(UA_Connection *connection, size_t length, UA_ByteString *buf) {
  5. buf->data = malloc(length);
  6. buf->length = length;
  7. return UA_STATUSCODE_GOOD;
  8. }
  9. static void
  10. dummyReleaseSendBuffer(UA_Connection *connection, UA_ByteString *buf) {
  11. free(buf->data);
  12. }
  13. static UA_StatusCode
  14. dummySend(UA_Connection *connection, UA_ByteString *buf) {
  15. UA_ByteString_deleteMembers(buf);
  16. return UA_STATUSCODE_GOOD;
  17. }
  18. static void
  19. dummyReleaseRecvBuffer(UA_Connection *connection, UA_ByteString *buf) {
  20. return;
  21. }
  22. static void
  23. dummyClose(UA_Connection *connection) {
  24. return;
  25. }
  26. UA_Connection createDummyConnection(void) {
  27. UA_Connection c;
  28. c.state = UA_CONNECTION_ESTABLISHED;
  29. c.localConf = UA_ConnectionConfig_standard;
  30. c.remoteConf = UA_ConnectionConfig_standard;
  31. c.channel = NULL;
  32. c.sockfd = 0;
  33. c.handle = NULL;
  34. c.incompleteMessage = UA_BYTESTRING_NULL;
  35. c.getSendBuffer = dummyGetSendBuffer;
  36. c.releaseSendBuffer = dummyReleaseSendBuffer;
  37. c.send = dummySend;
  38. c.recv = NULL;
  39. c.releaseRecvBuffer = dummyReleaseRecvBuffer;
  40. c.close = dummyClose;
  41. return c;
  42. }