fuzz_common.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Created by profanter on 18.07.17.
  3. // Copyright (c) 2017 fortiss GmbH. All rights reserved.
  4. //
  5. #ifndef OPEN62541_FUZZ_COMMON_H_H
  6. #define OPEN62541_FUZZ_COMMON_H_H
  7. #include "ua_server.h"
  8. #include "ua_server_internal.h"
  9. #include "ua_config_standard.h"
  10. #include "ua_log_stdout.h"
  11. #include "ua_plugin_log.h"
  12. static UA_StatusCode
  13. dummyGetSendBuffer(UA_Connection *connection, size_t length, UA_ByteString *buf) {
  14. buf->data = (UA_Byte*)malloc(length);
  15. buf->length = length;
  16. return UA_STATUSCODE_GOOD;
  17. }
  18. static void
  19. dummyReleaseSendBuffer(UA_Connection *connection, UA_ByteString *buf) {
  20. free(buf->data);
  21. }
  22. static UA_StatusCode
  23. dummySend(UA_Connection *connection, UA_ByteString *buf) {
  24. UA_ByteString_deleteMembers(buf);
  25. return UA_STATUSCODE_GOOD;
  26. }
  27. static void
  28. dummyReleaseRecvBuffer(UA_Connection *connection, UA_ByteString *buf) {
  29. return;
  30. }
  31. static void
  32. dummyClose(UA_Connection *connection) {
  33. return;
  34. }
  35. UA_Connection createDummyConnection(void) {
  36. UA_Connection c;
  37. c.state = UA_CONNECTION_ESTABLISHED;
  38. c.localConf = UA_ConnectionConfig_standard;
  39. c.remoteConf = UA_ConnectionConfig_standard;
  40. c.channel = NULL;
  41. c.sockfd = 0;
  42. c.handle = NULL;
  43. c.incompleteMessage = UA_BYTESTRING_NULL;
  44. c.getSendBuffer = dummyGetSendBuffer;
  45. c.releaseSendBuffer = dummyReleaseSendBuffer;
  46. c.send = dummySend;
  47. c.recv = NULL;
  48. c.releaseRecvBuffer = dummyReleaseRecvBuffer;
  49. c.close = dummyClose;
  50. return c;
  51. }
  52. #endif //OPEN62541_FUZZ_COMMON_H_H