cfg.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 "aispoll.h"
  58. #include "mempool.h"
  59. #include "util.h"
  60. #include "print.h"
  61. #define LOG_LEVEL_FROM_LIB LOG_LEVEL_DEBUG
  62. #define LOG_LEVEL_FROM_GMI LOG_LEVEL_DEBUG
  63. #define LOG_LEVEL_ENTER_FUNC LOG_LEVEL_DEBUG
  64. static void cfg_confchg_fn (
  65. enum totem_configuration_type configuration_type,
  66. unsigned int *member_list, int member_list_entries,
  67. unsigned int *left_list, int left_list_entries,
  68. unsigned int *joined_list, int joined_list_entries,
  69. struct memb_ring_id *ring_id);
  70. static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb);
  71. static int cfg_lib_init_fn (void *conn);
  72. static int cfg_lib_exit_fn (void *conn);
  73. static void message_handler_req_lib_cfg_statetrackstart (void *conn, void *msg);
  74. static void message_handler_req_lib_cfg_statetrackstop (void *conn, void *msg);
  75. static void message_handler_req_lib_cfg_administrativestateset (void *conn, void *msg);
  76. static void message_handler_req_lib_cfg_administrativestateget (void *conn, void *msg);
  77. /*
  78. * Service Handler Definition
  79. */
  80. static struct openais_lib_handler cfg_lib_service[] =
  81. {
  82. { /* 0 */
  83. .lib_handler_fn = message_handler_req_lib_cfg_statetrackstart,
  84. .response_size = sizeof (struct res_lib_cfg_statetrackstart),
  85. .response_id = MESSAGE_RES_CFG_STATETRACKSTART,
  86. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  87. },
  88. { /* 1 */
  89. .lib_handler_fn = message_handler_req_lib_cfg_statetrackstop,
  90. .response_size = sizeof (struct res_lib_cfg_statetrackstop),
  91. .response_id = MESSAGE_RES_CFG_STATETRACKSTOP,
  92. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  93. },
  94. { /* 2 */
  95. .lib_handler_fn = message_handler_req_lib_cfg_administrativestateset,
  96. .response_size = sizeof (struct res_lib_cfg_administrativestateset),
  97. .response_id = MESSAGE_RES_CFG_ADMINISTRATIVESTATESET,
  98. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
  99. },
  100. { /* 3 */
  101. .lib_handler_fn = message_handler_req_lib_cfg_administrativestateget,
  102. .response_size = sizeof (struct res_lib_cfg_administrativestateget),
  103. .response_id = MESSAGE_RES_CFG_ADMINISTRATIVESTATEGET,
  104. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
  105. }
  106. };
  107. static struct openais_exec_handler cfg_exec_service[] =
  108. {
  109. {
  110. }
  111. /*
  112. message_handler_req_exec_cfg_componentregister,
  113. message_handler_req_exec_cfg_componentunregister,
  114. message_handler_req_exec_cfg_componenterrorreport,
  115. message_handler_req_exec_cfg_componenterrorclear,
  116. */
  117. };
  118. /*
  119. * Exports the interface for the service
  120. */
  121. struct openais_service_handler cfg_service_handler = {
  122. .name = (unsigned char*)"openais configuration service",
  123. .id = CFG_SERVICE,
  124. .private_data_size = 0,
  125. .lib_init_fn = cfg_lib_init_fn,
  126. .lib_exit_fn = cfg_lib_exit_fn,
  127. .lib_service = cfg_lib_service,
  128. .lib_service_count = sizeof (cfg_lib_service) / sizeof (struct openais_lib_handler),
  129. .exec_init_fn = cfg_exec_init_fn,
  130. .exec_service = cfg_exec_service,
  131. .exec_service_count = 0, /* sizeof (cfg_aisexec_handler_fns) / sizeof (openais_exec_handler), */
  132. .confchg_fn = cfg_confchg_fn,
  133. };
  134. /*
  135. * Dynamic Loader definition
  136. */
  137. static struct openais_service_handler *cfg_get_handler_ver0 (void);
  138. static struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
  139. .openais_get_service_handler_ver0 = cfg_get_handler_ver0
  140. };
  141. static struct lcr_iface openais_cfg_ver0[1] = {
  142. {
  143. .name = "openais_cfg",
  144. .version = 0,
  145. .versions_replace = 0,
  146. .versions_replace_count = 0,
  147. .dependencies = 0,
  148. .dependency_count = 0,
  149. .constructor = NULL,
  150. .destructor = NULL,
  151. .interfaces = NULL
  152. }
  153. };
  154. static struct lcr_comp cfg_comp_ver0 = {
  155. .iface_count = 1,
  156. .ifaces = openais_cfg_ver0
  157. };
  158. static struct openais_service_handler *cfg_get_handler_ver0 (void)
  159. {
  160. return (&cfg_service_handler);
  161. }
  162. __attribute__ ((constructor)) static void register_this_component (void) {
  163. lcr_interfaces_set (&openais_cfg_ver0[0], &cfg_service_handler_iface);
  164. lcr_component_register (&cfg_comp_ver0);
  165. }
  166. /* IMPL */
  167. static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb)
  168. {
  169. log_init ("CFG");
  170. return (0);
  171. }
  172. static void cfg_confchg_fn (
  173. enum totem_configuration_type configuration_type,
  174. unsigned int *member_list, int member_list_entries,
  175. unsigned int *left_list, int left_list_entries,
  176. unsigned int *joined_list, int joined_list_entries,
  177. struct memb_ring_id *ring_id)
  178. {
  179. }
  180. int cfg_lib_exit_fn (void *conn)
  181. {
  182. return (0);
  183. }
  184. static int cfg_lib_init_fn (void *conn)
  185. {
  186. log_printf (LOG_LEVEL_DEBUG, "Got request to initalize configuration service.\n");
  187. return (0);
  188. }
  189. /*
  190. * Library Interface Implementation
  191. */
  192. static void message_handler_req_lib_cfg_statetrackstart (
  193. void *conn,
  194. void *msg)
  195. {
  196. // struct req_lib_cfg_statetrackstart *req_lib_cfg_statetrackstart = (struct req_lib_cfg_statetrackstart *)message;
  197. log_printf (LOG_LEVEL_FROM_LIB,
  198. "Handle : message_handler_req_lib_cfg_statetrackstart()\n");
  199. }
  200. static void message_handler_req_lib_cfg_statetrackstop (
  201. void *conn,
  202. void *msg)
  203. {
  204. // struct req_lib_cfg_statetrackstop *req_lib_cfg_statetrackstop = (struct req_lib_cfg_statetrackstop *)message;
  205. log_printf (LOG_LEVEL_FROM_LIB,
  206. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  207. }
  208. static void message_handler_req_lib_cfg_administrativestateset (
  209. void *conn,
  210. void *msg)
  211. {
  212. // struct req_lib_cfg_administrativestateset *req_lib_cfg_administrativestateset = (struct req_lib_cfg_administrativestateset *)message;
  213. log_printf (LOG_LEVEL_FROM_LIB,
  214. "Handle : message_handler_req_lib_cfg_administrativestateset()\n");
  215. }
  216. static void message_handler_req_lib_cfg_administrativestateget (
  217. void *conn,
  218. void *msg)
  219. {
  220. // struct req_lib_cfg_administrativestateget *req_lib_cfg_administrativestateget = (struct req_lib_cfg_administrativestateget *)message;
  221. log_printf (LOG_LEVEL_FROM_LIB,
  222. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  223. }