testing_networklayers.c 1.4 KB

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