connection_wrapper.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "connection_lib.h"
  6. #include "wasm_export.h"
  7. #include "native_interface.h"
  8. #include "connection_native_api.h"
  9. /* Note:
  10. *
  11. * This file is the consumer of connection lib which is implemented by different platforms
  12. */
  13. uint32
  14. wasm_open_connection(wasm_exec_env_t exec_env,
  15. char *name, char *args_buf, uint32 len)
  16. {
  17. wasm_module_inst_t module_inst = get_module_inst(exec_env);
  18. attr_container_t *args;
  19. args = (attr_container_t *)args_buf;
  20. if (connection_impl._open != NULL)
  21. return connection_impl._open(module_inst, name, args);
  22. return -1;
  23. }
  24. void
  25. wasm_close_connection(wasm_exec_env_t exec_env, uint32 handle)
  26. {
  27. if (connection_impl._close != NULL)
  28. connection_impl._close(handle);
  29. }
  30. int
  31. wasm_send_on_connection(wasm_exec_env_t exec_env,
  32. uint32 handle, char *data, uint32 len)
  33. {
  34. if (connection_impl._send != NULL)
  35. return connection_impl._send(handle, data, len);
  36. return -1;
  37. }
  38. bool
  39. wasm_config_connection(wasm_exec_env_t exec_env,
  40. uint32 handle, char *cfg_buf, uint32 len)
  41. {
  42. attr_container_t *cfg;
  43. cfg = (attr_container_t *)cfg_buf;
  44. if (connection_impl._config != NULL)
  45. return connection_impl._config(handle, cfg);
  46. return false;
  47. }