apidef.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2008 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@redhat.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <stdlib.h>
  35. #include <string.h>
  36. #include <assert.h>
  37. #include "swab.h"
  38. #include "totem.h"
  39. #include "util.h"
  40. #include "logsys.h"
  41. #include "timer.h"
  42. #include "totempg.h"
  43. #include "totemip.h"
  44. #include "main.h"
  45. #include "ipc.h"
  46. #include "../include/coroapi.h"
  47. #include "service.h"
  48. #include "../lcr/lcr_ifact.h"
  49. LOGSYS_DECLARE_SUBSYS ("APIDEF", LOG_INFO);
  50. static struct corosync_api_v1 apidef_corosync_api_v1 = {
  51. .timer_add_duration = corosync_timer_add_duration,
  52. .timer_add_absolute = corosync_timer_add_absolute,
  53. .timer_delete = corosync_timer_delete,
  54. .timer_time_get = NULL,
  55. .ipc_source_set = message_source_set,
  56. .ipc_source_is_local = message_source_is_local,
  57. .ipc_private_data_get = corosync_conn_private_data_get,
  58. .ipc_response_send = NULL,
  59. .ipc_dispatch_send = NULL,
  60. .ipc_conn_send_response = corosync_conn_send_response,
  61. .ipc_conn_partner_get = corosync_conn_partner_get,
  62. .ipc_refcnt_inc = corosync_ipc_flow_control_local_increment,
  63. .ipc_refcnt_dec = corosync_ipc_flow_control_local_decrement,
  64. .ipc_fc_create = corosync_ipc_flow_control_create,
  65. .ipc_fc_destroy = corosync_ipc_flow_control_destroy,
  66. .totem_nodeid_get = totempg_my_nodeid_get,
  67. .totem_family_get = totempg_my_family_get,
  68. .totem_ring_reenable = totempg_ring_reenable,
  69. .totem_mcast = main_mcast,
  70. .totem_send_ok = main_send_ok,
  71. .totem_ifaces_get = totempg_ifaces_get,
  72. .totem_ifaces_print = totempg_ifaces_print,
  73. .totem_ip_print = totemip_print,
  74. .service_link_and_init = corosync_service_link_and_init,
  75. .service_unlink_and_exit = corosync_service_unlink_and_exit,
  76. .plugin_interface_reference = lcr_ifact_reference,
  77. .plugin_interface_release = lcr_ifact_release,
  78. .error_memory_failure = NULL
  79. };
  80. void apidef_init (struct objdb_iface_ver0 *objdb) {
  81. apidef_corosync_api_v1.object_create = objdb->object_create;
  82. apidef_corosync_api_v1.object_priv_set = objdb->object_priv_set;
  83. apidef_corosync_api_v1.object_key_create = objdb->object_key_create;
  84. apidef_corosync_api_v1.object_destroy = objdb->object_destroy;
  85. apidef_corosync_api_v1.object_valid_set = objdb->object_valid_set;
  86. apidef_corosync_api_v1.object_key_valid_set = objdb->object_key_valid_set;
  87. apidef_corosync_api_v1.object_find_create = objdb->object_find_create;
  88. apidef_corosync_api_v1.object_find_next = objdb->object_find_next;
  89. apidef_corosync_api_v1.object_find_destroy = objdb->object_find_destroy;
  90. apidef_corosync_api_v1.object_key_get = objdb->object_key_get;
  91. apidef_corosync_api_v1.object_priv_get = objdb->object_priv_get;
  92. apidef_corosync_api_v1.object_key_replace = objdb->object_key_replace;
  93. apidef_corosync_api_v1.object_key_delete = objdb->object_key_delete;
  94. apidef_corosync_api_v1.object_iter_reset = objdb->object_iter_reset;
  95. apidef_corosync_api_v1.object_iter = objdb->object_iter;
  96. apidef_corosync_api_v1.object_key_iter = objdb->object_key_iter;
  97. apidef_corosync_api_v1.object_parent_get = objdb->object_parent_get;
  98. apidef_corosync_api_v1.object_dump = objdb->object_dump;
  99. apidef_corosync_api_v1.object_find_from = objdb->object_find_from;
  100. apidef_corosync_api_v1.object_iter_from = objdb->object_iter_from;
  101. apidef_corosync_api_v1.object_key_iter_from = objdb->object_key_iter_from;
  102. apidef_corosync_api_v1.object_track_start = objdb->object_track_start;
  103. apidef_corosync_api_v1.object_track_stop = objdb->object_track_stop;
  104. apidef_corosync_api_v1.object_write_config = objdb->object_write_config;
  105. }
  106. struct corosync_api_v1 *apidef_get (void)
  107. {
  108. return (&apidef_corosync_api_v1);
  109. }