testing_networklayers.c 1.4 KB

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