ipc_gen.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. enum req_init_types {
  55. MESSAGE_REQ_RESPONSE_INIT = 0,
  56. MESSAGE_REQ_DISPATCH_INIT = 1
  57. };
  58. #define MESSAGE_REQ_CHANGE_EUID 1
  59. #define MESSAGE_REQ_OUTQ_FLUSH 2
  60. #define REQ_SIZE 1000000
  61. #define RES_SIZE 1000000
  62. #define DISPATCH_SIZE 1000000
  63. struct shared_memory {
  64. unsigned char req_buffer[REQ_SIZE];
  65. unsigned char res_buffer[RES_SIZE];
  66. unsigned char dispatch_buffer[DISPATCH_SIZE];
  67. unsigned int read;
  68. unsigned int write;
  69. };
  70. enum res_init_types {
  71. MESSAGE_RES_INIT
  72. };
  73. typedef struct {
  74. int size __attribute__((aligned(8)));
  75. int id __attribute__((aligned(8)));
  76. } mar_req_header_t __attribute__((aligned(8)));
  77. typedef struct {
  78. int service __attribute__((aligned(8)));
  79. unsigned long long shmkey __attribute__((aligned(8)));
  80. unsigned long long semkey __attribute__((aligned(8)));
  81. } mar_req_setup_t __attribute__((aligned(8)));
  82. typedef struct {
  83. int error __attribute__((aligned(8)));
  84. } mar_res_setup_t __attribute__((aligned(8)));
  85. static inline void swab_mar_req_header_t (mar_req_header_t *to_swab)
  86. {
  87. swab_mar_int32_t (&to_swab->size);
  88. swab_mar_int32_t (&to_swab->id);
  89. }
  90. typedef struct {
  91. int size; __attribute__((aligned(8)))
  92. int id __attribute__((aligned(8)));
  93. cs_error_t error __attribute__((aligned(8)));
  94. } mar_res_header_t __attribute__((aligned(8)));
  95. typedef struct {
  96. uid_t euid __attribute__((aligned(8)));
  97. gid_t egid __attribute__((aligned(8)));
  98. } mar_req_priv_change __attribute__((aligned(8)));
  99. typedef struct {
  100. mar_res_header_t header __attribute__((aligned(8)));
  101. mar_uint64_t conn_info __attribute__((aligned(8)));
  102. } mar_res_lib_response_init_t __attribute__((aligned(8)));
  103. typedef struct {
  104. mar_res_header_t header __attribute__((aligned(8)));
  105. } mar_res_lib_dispatch_init_t __attribute__((aligned(8)));
  106. typedef struct {
  107. mar_uint32_t nodeid __attribute__((aligned(8)));
  108. void *conn __attribute__((aligned(8)));
  109. } mar_message_source_t __attribute__((aligned(8)));
  110. static inline void swab_mar_message_source_t (mar_message_source_t *to_swab)
  111. {
  112. swab_mar_uint32_t (&to_swab->nodeid);
  113. /*
  114. * if it is from a byteswapped machine, then we can safely
  115. * ignore its conn info data structure since this is only
  116. * local to the machine
  117. */
  118. to_swab->conn = NULL;
  119. }
  120. #endif /* IPC_GEN_H_DEFINED */