ipc_gen.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2002-2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2009 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.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. #ifndef IPC_GEN_H_DEFINED
  36. #define IPC_GEN_H_DEFINED
  37. #include <corosync/mar_gen.h>
  38. enum service_types {
  39. EVS_SERVICE = 0,
  40. CLM_SERVICE = 1,
  41. AMF_SERVICE = 2,
  42. CKPT_SERVICE = 3,
  43. EVT_SERVICE = 4,
  44. LCK_SERVICE = 5,
  45. MSG_SERVICE = 6,
  46. CFG_SERVICE = 7,
  47. CPG_SERVICE = 8,
  48. CONFDB_SERVICE = 10,
  49. QUORUM_SERVICE = 11,
  50. PLOAD_SERVICE = 12,
  51. TMR_SERVICE = 13,
  52. VOTEQUORUM_SERVICE = 14,
  53. };
  54. #define IPC_SOCKET_NAME "corosync.ipc"
  55. enum req_init_types {
  56. MESSAGE_REQ_RESPONSE_INIT = 0,
  57. MESSAGE_REQ_DISPATCH_INIT = 1
  58. };
  59. #define MESSAGE_REQ_CHANGE_EUID 1
  60. #define MESSAGE_REQ_OUTQ_FLUSH 2
  61. #define REQ_SIZE 1000000
  62. #define RES_SIZE 1000000
  63. #define DISPATCH_SIZE 1000000
  64. struct shared_memory {
  65. unsigned char req_buffer[REQ_SIZE];
  66. unsigned char res_buffer[RES_SIZE];
  67. unsigned char dispatch_buffer[DISPATCH_SIZE];
  68. unsigned int read;
  69. unsigned int write;
  70. };
  71. enum res_init_types {
  72. MESSAGE_RES_INIT
  73. };
  74. typedef struct {
  75. int size __attribute__((aligned(8)));
  76. int id __attribute__((aligned(8)));
  77. } mar_req_header_t __attribute__((aligned(8)));
  78. typedef struct {
  79. int service __attribute__((aligned(8)));
  80. unsigned long long shmkey __attribute__((aligned(8)));
  81. unsigned long long semkey __attribute__((aligned(8)));
  82. } mar_req_setup_t __attribute__((aligned(8)));
  83. typedef struct {
  84. int error __attribute__((aligned(8)));
  85. } mar_res_setup_t __attribute__((aligned(8)));
  86. static inline void swab_mar_req_header_t (mar_req_header_t *to_swab)
  87. {
  88. swab_mar_int32_t (&to_swab->size);
  89. swab_mar_int32_t (&to_swab->id);
  90. }
  91. typedef struct {
  92. int size; __attribute__((aligned(8)))
  93. int id __attribute__((aligned(8)));
  94. cs_error_t error __attribute__((aligned(8)));
  95. } mar_res_header_t __attribute__((aligned(8)));
  96. typedef struct {
  97. uid_t euid __attribute__((aligned(8)));
  98. gid_t egid __attribute__((aligned(8)));
  99. } mar_req_priv_change __attribute__((aligned(8)));
  100. typedef struct {
  101. mar_res_header_t header __attribute__((aligned(8)));
  102. mar_uint64_t conn_info __attribute__((aligned(8)));
  103. } mar_res_lib_response_init_t __attribute__((aligned(8)));
  104. typedef struct {
  105. mar_res_header_t header __attribute__((aligned(8)));
  106. } mar_res_lib_dispatch_init_t __attribute__((aligned(8)));
  107. typedef struct {
  108. mar_uint32_t nodeid __attribute__((aligned(8)));
  109. void *conn __attribute__((aligned(8)));
  110. } mar_message_source_t __attribute__((aligned(8)));
  111. static inline void swab_mar_message_source_t (mar_message_source_t *to_swab)
  112. {
  113. swab_mar_uint32_t (&to_swab->nodeid);
  114. /*
  115. * if it is from a byteswapped machine, then we can safely
  116. * ignore its conn info data structure since this is only
  117. * local to the machine
  118. */
  119. to_swab->conn = NULL;
  120. }
  121. #endif /* IPC_GEN_H_DEFINED */