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
58
59
60 char *op;
61 } pcmk__request_t;
62
63 #define pcmk__set_request_flags(request, flags_to_set) do { \
64 (request)->flags = pcmk__set_flags_as(__func__, __LINE__, \
65 LOG_TRACE, "Request", "message", (request)->flags, \
66 (flags_to_set), #flags_to_set); \
67 } while (0)
68
69
70 typedef struct {
71 const char *command;
72 xmlNode *(*handler)(pcmk__request_t *request);
73 } pcmk__server_command_t;
74
75 const char *pcmk__message_name(const char *name);
76 GHashTable *pcmk__register_handlers(const pcmk__server_command_t handlers[]);
77 xmlNode *pcmk__process_request(pcmk__request_t *request, GHashTable *handlers);
78 void pcmk__reset_request(pcmk__request_t *request);
79
80
81
82
83
84
85
86
87
88
89 static inline const char *
90 pcmk__request_origin_type(const pcmk__request_t *request)
91 {
92 if ((request != NULL) && (request->ipc_client != NULL)) {
93 return "client";
94 } else if ((request != NULL) && (request->peer != NULL)) {
95 return "peer";
96 } else {
97 return "originator";
98 }
99 }
100
101
102
103
104
105
106
107
108
109
110 static inline const char *
111 pcmk__request_origin(const pcmk__request_t *request)
112 {
113 if ((request != NULL) && (request->ipc_client != NULL)) {
114 return pcmk__client_name(request->ipc_client);
115 } else if ((request != NULL) && (request->peer != NULL)) {
116 return request->peer;
117 } else {
118 return "(unspecified)";
119 }
120 }
121
122 #endif