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