cfg.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * Copyright (c) 2005-2006 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.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 <sys/types.h>
  35. #include <sys/uio.h>
  36. #include <sys/socket.h>
  37. #include <sys/un.h>
  38. #include <netinet/in.h>
  39. #include <arpa/inet.h>
  40. #include <unistd.h>
  41. #include <fcntl.h>
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44. #include <errno.h>
  45. #include <signal.h>
  46. #include <string.h>
  47. #include "../include/saAis.h"
  48. #include "../include/openaisCfg.h"
  49. #include "../include/ipc_gen.h"
  50. #include "../include/ipc_cfg.h"
  51. #include "../include/list.h"
  52. #include "../include/queue.h"
  53. #include "../lcr/lcr_comp.h"
  54. #include "totempg.h"
  55. #include "aispoll.h"
  56. #include "mempool.h"
  57. #include "util.h"
  58. #include "handlers.h"
  59. #define LOG_SERVICE LOG_SERVICE_AMF
  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. struct totem_ip_address *member_list, int member_list_entries,
  67. struct totem_ip_address *left_list, int left_list_entries,
  68. struct totem_ip_address *joined_list, int joined_list_entries,
  69. struct memb_ring_id *ring_id);
  70. static int cfg_lib_exit_fn (struct conn_info *conn_info);
  71. static int cfg_exec_init_fn (struct openais_config *);
  72. static int cfg_lib_init_fn (struct conn_info *conn_info);
  73. static void message_handler_req_lib_cfg_statetrackstart (struct conn_info *conn_info, void *message);
  74. static void message_handler_req_lib_cfg_statetrackstop (struct conn_info *conn_info, void *message);
  75. static void message_handler_req_lib_cfg_administrativestateset (struct conn_info *conn_info, void *message);
  76. static void message_handler_req_lib_cfg_administrativestateget (struct conn_info *conn_info, void *message);
  77. /*
  78. * Service Handler Definition
  79. */
  80. static struct openais_lib_handler cfg_lib_handlers[] =
  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_handlers[] =
  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. .lib_init_fn = cfg_lib_init_fn,
  125. .lib_exit_fn = cfg_lib_exit_fn,
  126. .lib_handlers = cfg_lib_handlers,
  127. .lib_handlers_count = sizeof (cfg_lib_handlers) / sizeof (struct openais_lib_handler),
  128. .exec_init_fn = cfg_exec_init_fn,
  129. .exec_handlers = cfg_exec_handlers,
  130. .exec_handlers_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. #ifdef BUILD_DYNAMIC
  137. struct openais_service_handler *cfg_get_handler_ver0 (void);
  138. struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
  139. .openais_get_service_handler_ver0 = cfg_get_handler_ver0
  140. };
  141. 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 = (void **)&cfg_service_handler_iface,
  152. }
  153. };
  154. struct lcr_comp cfg_comp_ver0 = {
  155. .iface_count = 1,
  156. .ifaces = openais_cfg_ver0
  157. };
  158. extern int lcr_comp_get (struct lcr_comp **component)
  159. {
  160. *component = &cfg_comp_ver0;
  161. return (0);
  162. }
  163. struct openais_service_handler *cfg_get_handler_ver0 (void)
  164. {
  165. return (&cfg_service_handler);
  166. }
  167. #endif /* BUILD_DYNAMIC */
  168. /* IMPL */
  169. static int cfg_exec_init_fn (struct openais_config *openais_config)
  170. {
  171. return (0);
  172. }
  173. static void cfg_confchg_fn (
  174. enum totem_configuration_type configuration_type,
  175. struct totem_ip_address *member_list, int member_list_entries,
  176. struct totem_ip_address *left_list, int left_list_entries,
  177. struct totem_ip_address *joined_list, int joined_list_entries,
  178. struct memb_ring_id *ring_id)
  179. {
  180. }
  181. int cfg_lib_exit_fn (struct conn_info *conn_info)
  182. {
  183. return (0);
  184. }
  185. static int cfg_lib_init_fn (struct conn_info *conn_info)
  186. {
  187. log_printf (LOG_LEVEL_DEBUG, "Got request to initalize configuration service.\n");
  188. // list_init (&conn_info->conn_list);
  189. return (0);
  190. }
  191. /*
  192. * Library Interface Implementation
  193. */
  194. static void message_handler_req_lib_cfg_statetrackstart (struct conn_info *conn_info, void *message)
  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 (struct conn_info *conn_info, void *message)
  201. {
  202. // struct req_lib_cfg_statetrackstop *req_lib_cfg_statetrackstop = (struct req_lib_cfg_statetrackstop *)message;
  203. log_printf (LOG_LEVEL_FROM_LIB,
  204. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  205. }
  206. static void message_handler_req_lib_cfg_administrativestateset (struct conn_info *conn_info, void *message)
  207. {
  208. // struct req_lib_cfg_administrativestateset *req_lib_cfg_administrativestateset = (struct req_lib_cfg_administrativestateset *)message;
  209. log_printf (LOG_LEVEL_FROM_LIB,
  210. "Handle : message_handler_req_lib_cfg_administrativestateset()\n");
  211. }
  212. static void message_handler_req_lib_cfg_administrativestateget (struct conn_info *conn_info, void *message)
  213. {
  214. // struct req_lib_cfg_administrativestateget *req_lib_cfg_administrativestateget = (struct req_lib_cfg_administrativestateget *)message;
  215. log_printf (LOG_LEVEL_FROM_LIB,
  216. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  217. }