cfg.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * Copyright (c) 2005-2006 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@mvista.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <sys/types.h>
  36. #include <sys/uio.h>
  37. #include <sys/socket.h>
  38. #include <sys/un.h>
  39. #include <netinet/in.h>
  40. #include <arpa/inet.h>
  41. #include <unistd.h>
  42. #include <fcntl.h>
  43. #include <stdlib.h>
  44. #include <stdio.h>
  45. #include <errno.h>
  46. #include <signal.h>
  47. #include <string.h>
  48. #include "../include/saAis.h"
  49. #include "../include/openaisCfg.h"
  50. #include "../include/ipc_gen.h"
  51. #include "../include/ipc_cfg.h"
  52. #include "../include/list.h"
  53. #include "../include/queue.h"
  54. #include "../lcr/lcr_comp.h"
  55. #include "service.h"
  56. #include "totempg.h"
  57. #include "mempool.h"
  58. #include "util.h"
  59. #include "print.h"
  60. #define LOG_LEVEL_FROM_LIB LOG_LEVEL_DEBUG
  61. #define LOG_LEVEL_FROM_GMI LOG_LEVEL_DEBUG
  62. #define LOG_LEVEL_ENTER_FUNC LOG_LEVEL_DEBUG
  63. static void cfg_confchg_fn (
  64. enum totem_configuration_type configuration_type,
  65. unsigned int *member_list, int member_list_entries,
  66. unsigned int *left_list, int left_list_entries,
  67. unsigned int *joined_list, int joined_list_entries,
  68. struct memb_ring_id *ring_id);
  69. static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb);
  70. static int cfg_lib_init_fn (void *conn);
  71. static int cfg_lib_exit_fn (void *conn);
  72. static void message_handler_req_lib_cfg_statetrackstart (void *conn, void *msg);
  73. static void message_handler_req_lib_cfg_statetrackstop (void *conn, void *msg);
  74. static void message_handler_req_lib_cfg_administrativestateset (void *conn, void *msg);
  75. static void message_handler_req_lib_cfg_administrativestateget (void *conn, void *msg);
  76. /*
  77. * Service Handler Definition
  78. */
  79. static struct openais_lib_handler cfg_lib_service[] =
  80. {
  81. { /* 0 */
  82. .lib_handler_fn = message_handler_req_lib_cfg_statetrackstart,
  83. .response_size = sizeof (struct res_lib_cfg_statetrackstart),
  84. .response_id = MESSAGE_RES_CFG_STATETRACKSTART,
  85. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  86. },
  87. { /* 1 */
  88. .lib_handler_fn = message_handler_req_lib_cfg_statetrackstop,
  89. .response_size = sizeof (struct res_lib_cfg_statetrackstop),
  90. .response_id = MESSAGE_RES_CFG_STATETRACKSTOP,
  91. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  92. },
  93. { /* 2 */
  94. .lib_handler_fn = message_handler_req_lib_cfg_administrativestateset,
  95. .response_size = sizeof (struct res_lib_cfg_administrativestateset),
  96. .response_id = MESSAGE_RES_CFG_ADMINISTRATIVESTATESET,
  97. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
  98. },
  99. { /* 3 */
  100. .lib_handler_fn = message_handler_req_lib_cfg_administrativestateget,
  101. .response_size = sizeof (struct res_lib_cfg_administrativestateget),
  102. .response_id = MESSAGE_RES_CFG_ADMINISTRATIVESTATEGET,
  103. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
  104. }
  105. };
  106. static struct openais_exec_handler cfg_exec_service[] =
  107. {
  108. {
  109. }
  110. /*
  111. message_handler_req_exec_cfg_componentregister,
  112. message_handler_req_exec_cfg_componentunregister,
  113. message_handler_req_exec_cfg_componenterrorreport,
  114. message_handler_req_exec_cfg_componenterrorclear,
  115. */
  116. };
  117. /*
  118. * Exports the interface for the service
  119. */
  120. struct openais_service_handler cfg_service_handler = {
  121. .name = (unsigned char*)"openais configuration service",
  122. .id = CFG_SERVICE,
  123. .private_data_size = 0,
  124. .lib_init_fn = cfg_lib_init_fn,
  125. .lib_exit_fn = cfg_lib_exit_fn,
  126. .lib_service = cfg_lib_service,
  127. .lib_service_count = sizeof (cfg_lib_service) / sizeof (struct openais_lib_handler),
  128. .exec_init_fn = cfg_exec_init_fn,
  129. .exec_service = cfg_exec_service,
  130. .exec_service_count = 0, /* sizeof (cfg_aisexec_handler_fns) / sizeof (openais_exec_handler), */
  131. .confchg_fn = cfg_confchg_fn,
  132. };
  133. /*
  134. * Dynamic Loader definition
  135. */
  136. static struct openais_service_handler *cfg_get_handler_ver0 (void);
  137. static struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
  138. .openais_get_service_handler_ver0 = cfg_get_handler_ver0
  139. };
  140. static struct lcr_iface openais_cfg_ver0[1] = {
  141. {
  142. .name = "openais_cfg",
  143. .version = 0,
  144. .versions_replace = 0,
  145. .versions_replace_count = 0,
  146. .dependencies = 0,
  147. .dependency_count = 0,
  148. .constructor = NULL,
  149. .destructor = NULL,
  150. .interfaces = NULL
  151. }
  152. };
  153. static struct lcr_comp cfg_comp_ver0 = {
  154. .iface_count = 1,
  155. .ifaces = openais_cfg_ver0
  156. };
  157. static struct openais_service_handler *cfg_get_handler_ver0 (void)
  158. {
  159. return (&cfg_service_handler);
  160. }
  161. __attribute__ ((constructor)) static void register_this_component (void) {
  162. lcr_interfaces_set (&openais_cfg_ver0[0], &cfg_service_handler_iface);
  163. lcr_component_register (&cfg_comp_ver0);
  164. }
  165. /* IMPL */
  166. static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb)
  167. {
  168. log_init ("CFG");
  169. return (0);
  170. }
  171. static void cfg_confchg_fn (
  172. enum totem_configuration_type configuration_type,
  173. unsigned int *member_list, int member_list_entries,
  174. unsigned int *left_list, int left_list_entries,
  175. unsigned int *joined_list, int joined_list_entries,
  176. struct memb_ring_id *ring_id)
  177. {
  178. }
  179. int cfg_lib_exit_fn (void *conn)
  180. {
  181. return (0);
  182. }
  183. static int cfg_lib_init_fn (void *conn)
  184. {
  185. log_printf (LOG_LEVEL_DEBUG, "Got request to initalize configuration service.\n");
  186. return (0);
  187. }
  188. /*
  189. * Library Interface Implementation
  190. */
  191. static void message_handler_req_lib_cfg_statetrackstart (
  192. void *conn,
  193. void *msg)
  194. {
  195. // struct req_lib_cfg_statetrackstart *req_lib_cfg_statetrackstart = (struct req_lib_cfg_statetrackstart *)message;
  196. log_printf (LOG_LEVEL_FROM_LIB,
  197. "Handle : message_handler_req_lib_cfg_statetrackstart()\n");
  198. }
  199. static void message_handler_req_lib_cfg_statetrackstop (
  200. void *conn,
  201. void *msg)
  202. {
  203. // struct req_lib_cfg_statetrackstop *req_lib_cfg_statetrackstop = (struct req_lib_cfg_statetrackstop *)message;
  204. log_printf (LOG_LEVEL_FROM_LIB,
  205. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  206. }
  207. static void message_handler_req_lib_cfg_administrativestateset (
  208. void *conn,
  209. void *msg)
  210. {
  211. // struct req_lib_cfg_administrativestateset *req_lib_cfg_administrativestateset = (struct req_lib_cfg_administrativestateset *)message;
  212. log_printf (LOG_LEVEL_FROM_LIB,
  213. "Handle : message_handler_req_lib_cfg_administrativestateset()\n");
  214. }
  215. static void message_handler_req_lib_cfg_administrativestateget (
  216. void *conn,
  217. void *msg)
  218. {
  219. // struct req_lib_cfg_administrativestateget *req_lib_cfg_administrativestateget = (struct req_lib_cfg_administrativestateget *)message;
  220. log_printf (LOG_LEVEL_FROM_LIB,
  221. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  222. }