4
0

cfg.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright (c) 2005 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 "totempg.h"
  54. #include "aispoll.h"
  55. #include "mempool.h"
  56. #include "util.h"
  57. #include "handlers.h"
  58. #define LOG_SERVICE LOG_SERVICE_AMF
  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 int cfg_confchg_fn (
  64. enum totem_configuration_type configuration_type,
  65. struct in_addr *member_list, int member_list_entries,
  66. struct in_addr *left_list, int left_list_entries,
  67. struct in_addr *joined_list, int joined_list_entries,
  68. struct memb_ring_id *ring_id);
  69. static int cfg_exit_fn (struct conn_info *conn_info);
  70. static int cfg_exec_init_fn (struct openais_config *);
  71. static int cfg_init_two_fn (struct conn_info *conn_info);
  72. static int message_handler_req_lib_cfg_statetrackstart (struct conn_info *conn_info, void *message);
  73. static int message_handler_req_lib_cfg_statetrackstop (struct conn_info *conn_info, void *message);
  74. static int message_handler_req_lib_cfg_administrativestateset (struct conn_info *conn_info, void *message);
  75. static int message_handler_req_lib_cfg_administrativestateget (struct conn_info *conn_info, void *message);
  76. /*
  77. * Service Handler Definition
  78. */
  79. struct libais_handler cfg_libais_handlers[] =
  80. {
  81. { /* 0 */
  82. .libais_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 = FLOW_CONTROL_REQUIRED
  86. },
  87. { /* 1 */
  88. .libais_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 = FLOW_CONTROL_REQUIRED
  92. },
  93. { /* 2 */
  94. .libais_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 = FLOW_CONTROL_NOT_REQUIRED
  98. },
  99. { /* 3 */
  100. .libais_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 = FLOW_CONTROL_NOT_REQUIRED
  104. }
  105. };
  106. int (*cfg_aisexec_handler_fns[]) (void *, struct in_addr source_addr, int endian_conversion_required) = {
  107. /*
  108. message_handler_req_exec_cfg_componentregister,
  109. message_handler_req_exec_cfg_componentunregister,
  110. message_handler_req_exec_cfg_componenterrorreport,
  111. message_handler_req_exec_cfg_componenterrorclear,
  112. */
  113. };
  114. /*
  115. * Exports the interface for the service
  116. */
  117. struct service_handler cfg_service_handler = {
  118. .libais_handlers = cfg_libais_handlers,
  119. .libais_handlers_count = sizeof (cfg_libais_handlers) / sizeof (struct libais_handler),
  120. .aisexec_handler_fns = cfg_aisexec_handler_fns,
  121. .aisexec_handler_fns_count = sizeof (cfg_aisexec_handler_fns) / sizeof (int (*)),
  122. .confchg_fn = cfg_confchg_fn,
  123. .libais_init_two_fn = cfg_init_two_fn,
  124. .libais_exit_fn = cfg_exit_fn,
  125. .exec_init_fn = cfg_exec_init_fn,
  126. };
  127. /* IMPL */
  128. static int cfg_exec_init_fn (struct openais_config *openais_config)
  129. {
  130. return (0);
  131. }
  132. static int cfg_confchg_fn (
  133. enum totem_configuration_type configuration_type,
  134. struct in_addr *member_list, int member_list_entries,
  135. struct in_addr *left_list, int left_list_entries,
  136. struct in_addr *joined_list, int joined_list_entries,
  137. struct memb_ring_id *ring_id)
  138. {
  139. return (0);
  140. }
  141. int cfg_exit_fn (struct conn_info *conn_info)
  142. {
  143. return (0);
  144. }
  145. static int cfg_init_two_fn (struct conn_info *conn_info)
  146. {
  147. log_printf (LOG_LEVEL_DEBUG, "Got request to initalize configuration service.\n");
  148. list_init (&conn_info->conn_list);
  149. return (0);
  150. }
  151. /*
  152. * Library Interface Implementation
  153. */
  154. static int message_handler_req_lib_cfg_statetrackstart (struct conn_info *conn_info, void *message)
  155. {
  156. struct req_lib_cfg_statetrackstart *req_lib_cfg_statetrackstart = (struct req_lib_cfg_statetrackstart *)message;
  157. log_printf (LOG_LEVEL_FROM_LIB,
  158. "Handle : message_handler_req_lib_cfg_statetrackstart()\n");
  159. return (0);
  160. }
  161. static int message_handler_req_lib_cfg_statetrackstop (struct conn_info *conn_info, void *message)
  162. {
  163. struct req_lib_cfg_statetrackstop *req_lib_cfg_statetrackstop = (struct req_lib_cfg_statetrackstop *)message;
  164. log_printf (LOG_LEVEL_FROM_LIB,
  165. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  166. return (0);
  167. }
  168. static int message_handler_req_lib_cfg_administrativestateset (struct conn_info *conn_info, void *message)
  169. {
  170. struct req_lib_cfg_administrativestateset *req_lib_cfg_administrativestateset = (struct req_lib_cfg_administrativestateset *)message;
  171. log_printf (LOG_LEVEL_FROM_LIB,
  172. "Handle : message_handler_req_lib_cfg_administrativestateset()\n");
  173. return (0);
  174. }
  175. static int message_handler_req_lib_cfg_administrativestateget (struct conn_info *conn_info, void *message)
  176. {
  177. struct req_lib_cfg_administrativestateget *req_lib_cfg_administrativestateget = (struct req_lib_cfg_administrativestateget *)message;
  178. log_printf (LOG_LEVEL_FROM_LIB,
  179. "Handle : message_handler_req_lib_cfg_administrativestateget()\n");
  180. return (0);
  181. }