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
  12. * platforms
  13. */
  14. uint32
  15. wasm_open_connection(wasm_exec_env_t exec_env, char *name, char *args_buf,
  16. uint32 len)
  17. {
  18. wasm_module_inst_t module_inst = get_module_inst(exec_env);
  19. attr_container_t *args;
  20. args = (attr_container_t *)args_buf;
  21. if (connection_impl._open != NULL)
  22. return connection_impl._open(module_inst, name, args);
  23. return -1;
  24. }
  25. void
  26. wasm_close_connection(wasm_exec_env_t exec_env, uint32 handle)
  27. {
  28. if (connection_impl._close != NULL)
  29. connection_impl._close(handle);
  30. }
  31. int
  32. wasm_send_on_connection(wasm_exec_env_t exec_env, uint32 handle, char *data,
  33. uint32 len)
  34. {
  35. if (connection_impl._send != NULL)
  36. return connection_impl._send(handle, data, len);
  37. return -1;
  38. }
  39. bool
  40. wasm_config_connection(wasm_exec_env_t exec_env, uint32 handle, char *cfg_buf,
  41. uint32 len)
  42. {
  43. attr_container_t *cfg;
  44. cfg = (attr_container_t *)cfg_buf;
  45. if (connection_impl._config != NULL)
  46. return connection_impl._config(handle, cfg);
  47. return false;
  48. }