ua_connection.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "ua_connection.h"
  2. UA_ConnectionConfig UA_ConnectionConfig_standard = { .protocolVersion = 0, .sendBufferSize = 8192,
  3. .recvBufferSize = 8192, .maxMessageSize = 8192,
  4. .maxChunkCount = 1 };
  5. UA_Int32 UA_ByteStringArray_init(UA_ByteStringArray *stringarray, UA_UInt32 length) {
  6. if(!stringarray || length == 0)
  7. return UA_ERROR;
  8. if(UA_alloc((void **)&stringarray->strings, sizeof(UA_String) * length) != UA_SUCCESS)
  9. return UA_ERROR;
  10. for(UA_UInt32 i = 0;i < length;i++)
  11. UA_String_init(&stringarray->strings[i]);
  12. stringarray->stringsSize = length;
  13. return UA_ERROR;
  14. }
  15. UA_Int32 UA_ByteStringArray_deleteMembers(UA_ByteStringArray *stringarray) {
  16. if(!stringarray)
  17. return UA_ERROR;
  18. for(UA_UInt32 i = 0;i < stringarray->stringsSize;i++)
  19. UA_String_deleteMembers(&stringarray->strings[i]);
  20. UA_free(stringarray);
  21. return UA_SUCCESS;
  22. }
  23. UA_Int32 UA_Connection_init(UA_Connection *connection,
  24. UA_ConnectionConfig localConf,
  25. void *callbackHandle,
  26. UA_Int32 (*close)(void *handle),
  27. UA_Int32 (*write)(void *handle, UA_ByteStringArray *buf)) {
  28. connection->state = UA_CONNECTION_OPENING;
  29. connection->localConf = localConf;
  30. connection->channel = UA_NULL;
  31. connection->callbackHandle = callbackHandle;
  32. connection->close = close;
  33. connection->write = write;
  34. return UA_SUCCESS;
  35. }
  36. UA_Int32 UA_Connection_deleteMembers(UA_Connection *connection) {
  37. UA_free(connection->callbackHandle);
  38. return UA_SUCCESS;
  39. }