ua_connection.c 1.7 KB

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