This source file includes following definitions.
- pcmk__request_origin_type
- pcmk__request_origin
1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__CRM_COMMON_MESSAGES_INTERNAL__H
11 #define PCMK__CRM_COMMON_MESSAGES_INTERNAL__H
12
13 #include <stdint.h>
14 #include <libxml/tree.h>
15 #include <crm/common/ipc_internal.h>
16 #include <crm/common/results_internal.h>
17
18 enum pcmk__request_flags {
19 pcmk__request_none = UINT32_C(0),
20
21
22
23
24
25 pcmk__request_sync = (UINT32_C(1) << 0),
26
27
28
29
30 pcmk__request_reuse_options = (UINT32_C(1) << 1),
31 };
32
33
34 typedef struct {
35
36 pcmk__client_t *ipc_client;
37 uint32_t ipc_id;
38 uint32_t ipc_flags;
39
40
41 const char *peer;
42
43
44 xmlNode *xml;
45 int call_options;
46 uint32_t flags;
47 pcmk__action_result_t result;
48
49
50
51
52
53
54
55
56
57 const char *op;
58 } pcmk__request_t;
59
60 #define pcmk__set_request_flags(request, flags_to_set) do { \
61 (request)->flags = pcmk__set_flags_as(__func__, __LINE__, \
62 LOG_TRACE, "Request", "message", (request)->flags, \
63 (flags_to_set), #flags_to_set); \
64 } while (0)
65
66
67 typedef struct {
68 const char *command;
69 xmlNode *(*handler)(pcmk__request_t *request);
70 } pcmk__server_command_t;
71
72 const char *pcmk__message_name(const char *name);
73 GHashTable *pcmk__register_handlers(pcmk__server_command_t handlers[]);
74 xmlNode *pcmk__process_request(pcmk__request_t *request, GHashTable *handlers);
75
76
77
78
79
80
81
82
83
84
85 static inline const char *
86 pcmk__request_origin_type(pcmk__request_t *request)
87 {
88 if ((request != NULL) && (request->ipc_client != NULL)) {
89 return "client";
90 } else if ((request != NULL) && (request->peer != NULL)) {
91 return "peer";
92 } else {
93 return "originator";
94 }
95 }
96
97
98
99
100
101
102
103
104
105
106 static inline const char *
107 pcmk__request_origin(pcmk__request_t *request)
108 {
109 if ((request != NULL) && (request->ipc_client != NULL)) {
110 return pcmk__client_name(request->ipc_client);
111 } else if ((request != NULL) && (request->peer != NULL)) {
112 return request->peer;
113 } else {
114 return "(unspecified)";
115 }
116 }
117
118 #endif