cfg.c 8.0 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. #define LOG_SERVICE LOG_SERVICE_AMF
  61. #include "print.h"
  62. #define LOG_LEVEL_FROM_LIB LOG_LEVEL_DEBUG
  63. #define LOG_LEVEL_FROM_GMI LOG_LEVEL_DEBUG
  64. #define LOG_LEVEL_ENTER_FUNC LOG_LEVEL_DEBUG
  65. static void cfg_confchg_fn (
  66. enum totem_configuration_type configuration_type,
  67. struct totem_ip_address *member_list, int member_list_entries,
  68. struct totem_ip_address *left_list, int left_list_entries,
  69. struct totem_ip_address *joined_list, int joined_list_entries,
  70. struct memb_ring_id *ring_id);
  71. static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb);
  72. static int cfg_lib_init_fn (void *conn);
  73. static int cfg_lib_exit_fn (void *conn);
  74. static void message_handler_req_lib_cfg_statetrackstart (void *conn, void *msg);
  75. static void message_handler_req_lib_cfg_statetrackstop (void *conn, void *msg);
  76. static void message_handler_req_lib_cfg_administrativestateset (void *conn, void *msg);
  77. static void message_handler_req_lib_cfg_administrativestateget (void *conn, void *msg);
  78. /*
  79. * Service Handler Definition
  80. */
  81. static struct openais_lib_handler cfg_lib_service[] =
  82. {
  83. { /* 0 */
  84. .lib_handler_fn = message_handler_req_lib_cfg_statetrackstart,
  85. .response_size = sizeof (struct res_lib_cfg_statetrackstart),
  86. .response_id = MESSAGE_RES_CFG_STATETRACKSTART,
  87. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  88. },
  89. { /* 1 */
  90. .lib_handler_fn = message_handler_req_lib_cfg_statetrackstop,
  91. .response_size = sizeof (struct res_lib_cfg_statetrackstop),
  92. .response_id = MESSAGE_RES_CFG_STATETRACKSTOP,
  93. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  94. },
  95. { /* 2 */
  96. .lib_handler_fn = message_handler_req_lib_cfg_administrativestateset,
  97. .response_size = sizeof (struct res_lib_cfg_administrativestateset),
  98. .response_id = MESSAGE_RES_CFG_ADMINISTRATIVESTATESET,
  99. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
  100. },
  101. { /* 3 */
  102. .lib_handler_fn = message_handler_req_lib_cfg_administrativestateget,
  103. .response_size = sizeof (struct res_lib_cfg_administrativestateget),
  104. .response_id = MESSAGE_RES_CFG_ADMINISTRATIVESTATEGET,
  105. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
  106. }
  107. };
  108. static struct openais_exec_handler cfg_exec_service[] =
  109. {
  110. {
  111. }
  112. /*
  113. message_handler_req_exec_cfg_componentregister,
  114. message_handler_req_exec_cfg_componentunregister,
  115. message_handler_req_exec_cfg_componenterrorreport,
  116. message_handler_req_exec_cfg_componenterrorclear,
  117. */
  118. };
  119. /*
  120. * Exports the interface for the service
  121. */
  122. struct openais_service_handler cfg_service_handler = {
  123. .name = (unsigned char*)"openais configuration service",
  124. .id = CFG_SERVICE,
  125. .private_data_size = 0,
  126. .lib_init_fn = cfg_lib_init_fn,
  127. .lib_exit_fn = cfg_lib_exit_fn,
  128. .lib_service = cfg_lib_service,
  129. .lib_service_count = sizeof (cfg_lib_service) / sizeof (struct openais_lib_handler),
  130. .exec_init_fn = cfg_exec_init_fn,
  131. .exec_service = cfg_exec_service,
  132. .exec_service_count = 0, /* sizeof (cfg_aisexec_handler_fns) / sizeof (openais_exec_handler), */
  133. .confchg_fn = cfg_confchg_fn,
  134. };
  135. /*
  136. * Dynamic Loader definition
  137. */
  138. static struct openais_service_handler *cfg_get_handler_ver0 (void);
  139. static struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
  140. .openais_get_service_handler_ver0 = cfg_get_handler_ver0
  141. };
  142. static struct lcr_iface openais_cfg_ver0[1] = {
  143. {
  144. .name = "openais_cfg",
  145. .version = 0,
  146. .versions_replace = 0,
  147. .versions_replace_count = 0,
  148. .dependencies = 0,
  149. .dependency_count = 0,
  150. .constructor = NULL,
  151. .destructor = NULL,
  152. .interfaces = NULL
  153. }
  154. };
  155. static struct lcr_comp cfg_comp_ver0 = {
  156. .iface_count = 1,
  157. .ifaces = openais_cfg_ver0
  158. };
  159. static struct openais_service_handler *cfg_get_handler_ver0 (void)
  160. {
  161. return (&cfg_service_handler);
  162. }
  163. __attribute__ ((constructor)) static void register_this_component (void) {
  164. lcr_interfaces_set (&openais_cfg_ver0[0], &cfg_service_handler_iface);
  165. lcr_component_register (&cfg_comp_ver0);
  166. }
  167. /* IMPL */
  168. static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb)
  169. {
  170. return (0);
  171. }
  172. static void cfg_confchg_fn (
  173. enum totem_configuration_type configuration_type,
  174. struct totem_ip_address *member_list, int member_list_entries,
  175. struct totem_ip_address *left_list, int left_list_entries,
  176. struct totem_ip_address *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. }