nodestore.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2018-2019 SignalWire, Inc
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. #pragma once
  23. KS_BEGIN_EXTERN_C
  24. /* All stores are handles, opaque numbers that manage ref counts */
  25. typedef ks_handle_t swclt_store_t;
  26. /* Obfuscate our connection internals */
  27. typedef struct swclt_store_ctx swclt_store_ctx_t;
  28. typedef void (*swclt_store_cb_protocol_add_t)(swclt_sess_t sess,
  29. const char *protocol);
  30. typedef void (*swclt_store_cb_protocol_remove_t)(swclt_sess_t sess,
  31. const char *protocol);
  32. typedef void (*swclt_store_cb_protocol_provider_add_t)(swclt_sess_t sess,
  33. const blade_netcast_rqu_t *rqu,
  34. const blade_netcast_protocol_provider_add_param_t *params);
  35. typedef void (*swclt_store_cb_protocol_provider_remove_t)(
  36. swclt_sess_t sess,
  37. const blade_netcast_rqu_t* rqu,
  38. const blade_netcast_protocol_provider_remove_param_t *params);
  39. typedef void (*swclt_store_cb_protocol_provider_rank_update_t)(swclt_sess_t sess,
  40. const blade_netcast_rqu_t *rqu,
  41. const blade_netcast_protocol_provider_rank_update_param_t *params);
  42. typedef void (*swclt_store_cb_protocol_provider_data_update_t)(swclt_sess_t sess,
  43. const blade_netcast_rqu_t *rqu,
  44. const blade_netcast_protocol_provider_data_update_param_t *params);
  45. typedef void (*swclt_store_cb_route_add_t)(swclt_sess_t sess,
  46. const blade_netcast_rqu_t *rqu,
  47. const blade_netcast_route_add_param_t *params);
  48. typedef void (*swclt_store_cb_route_remove_t)(
  49. swclt_sess_t sess,
  50. const blade_netcast_rqu_t* rqu,
  51. const blade_netcast_route_remove_param_t *params);
  52. typedef void (*swclt_store_cb_authority_add_t)(swclt_sess_t sess,
  53. const blade_netcast_rqu_t *rqu,
  54. const blade_netcast_authority_add_param_t *params);
  55. typedef void (*swclt_store_cb_authority_remove_t)(
  56. swclt_sess_t sess,
  57. const blade_netcast_rqu_t* rqu,
  58. const blade_netcast_authority_remove_param_t *params);
  59. typedef void (*swclt_store_cb_subscription_add_t)(swclt_sess_t sess,
  60. const blade_netcast_rqu_t *rqu,
  61. const blade_netcast_subscription_add_param_t *params);
  62. typedef void (*swclt_store_cb_subscription_remove_t)(
  63. swclt_sess_t sess,
  64. const blade_netcast_rqu_t* rqu,
  65. const blade_netcast_subscription_remove_param_t *params);
  66. typedef void (*swclt_store_cb_identity_add_t)(swclt_sess_t sess,
  67. const blade_netcast_rqu_t *rqu,
  68. const blade_netcast_identity_add_param_t *params);
  69. typedef void (*swclt_store_cb_identity_remove_t)(
  70. swclt_sess_t sess,
  71. const blade_netcast_rqu_t* rqu,
  72. const blade_netcast_identity_remove_param_t *params);
  73. SWCLT_DECLARE(ks_status_t) swclt_store_create(swclt_store_t *store);
  74. SWCLT_DECLARE(ks_status_t) swclt_store_reset(swclt_store_t store);
  75. SWCLT_DECLARE(ks_status_t) swclt_store_populate(swclt_store_t store, const blade_connect_rpl_t *connect_rpl);
  76. SWCLT_DECLARE(ks_status_t) swclt_store_update(swclt_store_t store, const blade_netcast_rqu_t *netcast_rqu);
  77. SWCLT_DECLARE(ks_status_t) swclt_store_get_node_identities(swclt_store_t store, const char *nodeid, ks_pool_t *pool, ks_hash_t **identities);
  78. SWCLT_DECLARE(ks_status_t) swclt_store_get_protocols(swclt_store_t store, ks_json_t **protocols);
  79. SWCLT_DECLARE(ks_status_t) swclt_store_check_protocol(swclt_store_t store, const char *name);
  80. SWCLT_DECLARE(ks_status_t) swclt_store_select_random_protocol_provider(
  81. swclt_store_t store,
  82. const char *name,
  83. ks_pool_t *pool,
  84. char **providerid);
  85. SWCLT_DECLARE(ks_status_t) swclt_store_get_protocol_providers(
  86. swclt_store_t store,
  87. const char *name,
  88. ks_json_t **providers);
  89. SWCLT_DECLARE(ks_status_t) swclt_store_cb_route_add(swclt_store_t store, swclt_store_cb_route_add_t cb);
  90. SWCLT_DECLARE(ks_status_t) swclt_store_cb_route_remove(swclt_store_t store, swclt_store_cb_route_remove_t cb);
  91. SWCLT_DECLARE(ks_status_t) swclt_store_cb_identity_add(swclt_store_t store, swclt_store_cb_identity_add_t cb);
  92. SWCLT_DECLARE(ks_status_t) swclt_store_cb_identity_remove(swclt_store_t store, swclt_store_cb_identity_remove_t cb);
  93. SWCLT_DECLARE(ks_status_t) swclt_store_cb_protocol_add(swclt_store_t store, swclt_store_cb_protocol_add_t cb);
  94. SWCLT_DECLARE(ks_status_t) swclt_store_cb_protocol_remove(swclt_store_t store, swclt_store_cb_protocol_remove_t cb);
  95. SWCLT_DECLARE(ks_status_t) swclt_store_cb_protocol_provider_add(swclt_store_t store, swclt_store_cb_protocol_provider_add_t cb);
  96. SWCLT_DECLARE(ks_status_t) swclt_store_cb_protocol_provider_remove(swclt_store_t store, swclt_store_cb_protocol_provider_remove_t cb);
  97. SWCLT_DECLARE(ks_status_t) swclt_store_cb_protocol_provider_rank_update(swclt_store_t store, swclt_store_cb_protocol_provider_rank_update_t cb);
  98. SWCLT_DECLARE(ks_status_t) swclt_store_cb_protocol_provider_data_update(swclt_store_t store, swclt_store_cb_protocol_provider_data_update_t cb);
  99. SWCLT_DECLARE(ks_status_t) swclt_store_cb_authority_add(swclt_store_t store, swclt_store_cb_authority_add_t cb);
  100. SWCLT_DECLARE(ks_status_t) swclt_store_cb_authority_remove(swclt_store_t store, swclt_store_cb_authority_remove_t cb);
  101. SWCLT_DECLARE(ks_status_t) swclt_store_cb_subscription_add(swclt_store_t store, swclt_store_cb_subscription_add_t cb);
  102. SWCLT_DECLARE(ks_status_t) swclt_store_cb_subscription_remove(swclt_store_t store, swclt_store_cb_subscription_remove_t cb);
  103. #define swclt_store_get(store, contextP) __ks_handle_get(SWCLT_HTYPE_STORE, store, (ks_handle_base_t**)contextP, __FILE__, __LINE__, __PRETTY_FUNCTION__)
  104. #define swclt_store_put(contextP) __ks_handle_put(SWCLT_HTYPE_STORE, (ks_handle_base_t**)contextP, __FILE__, __LINE__, __PRETTY_FUNCTION__)
  105. KS_END_EXTERN_C