1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 #ifndef PMIX_PSEC_H
29 #define PMIX_PSEC_H
30
31 #include <src/include/pmix_config.h>
32
33 #include "src/mca/mca.h"
34 #include "src/mca/base/pmix_mca_base_var.h"
35 #include "src/mca/base/pmix_mca_base_framework.h"
36 #include "src/mca/ptl/ptl_types.h"
37
38 BEGIN_C_DECLS
39
40
41 struct pmix_peer_t;
42
43
44
45
46
47
48
49 typedef pmix_status_t (*pmix_psec_base_module_init_fn_t)(void);
50
51
52
53
54
55 typedef void (*pmix_psec_base_module_fini_fn_t)(void);
56
57
58
59
60
61
62
63
64
65
66
67 typedef pmix_status_t (*pmix_psec_base_module_create_cred_fn_t)(struct pmix_peer_t *peer,
68 const pmix_info_t directives[], size_t ndirs,
69 pmix_info_t **info, size_t *ninfo,
70 pmix_byte_object_t *cred);
71
72
73
74
75
76
77 typedef pmix_status_t (*pmix_psec_base_module_client_hndshk_fn_t)(int sd);
78
79
80
81
82
83
84
85
86
87
88
89
90
91 typedef pmix_status_t (*pmix_psec_base_module_validate_cred_fn_t)(struct pmix_peer_t *peer,
92 const pmix_info_t directives[], size_t ndirs,
93 pmix_info_t **info, size_t *ninfo,
94 const pmix_byte_object_t *cred);
95
96
97
98
99
100
101 typedef pmix_status_t (*pmix_psec_base_module_server_hndshk_fn_t)(int sd);
102
103
104
105
106 typedef struct {
107 char *name;
108
109 pmix_psec_base_module_init_fn_t init;
110 pmix_psec_base_module_fini_fn_t finalize;
111
112 pmix_psec_base_module_create_cred_fn_t create_cred;
113 pmix_psec_base_module_client_hndshk_fn_t client_handshake;
114
115 pmix_psec_base_module_validate_cred_fn_t validate_cred;
116 pmix_psec_base_module_server_hndshk_fn_t server_handshake;
117 } pmix_psec_module_t;
118
119
120
121
122
123
124 PMIX_EXPORT char* pmix_psec_base_get_available_modules(void);
125
126
127 PMIX_EXPORT pmix_psec_module_t* pmix_psec_base_assign_module(const char *options);
128
129
130
131 #define PMIX_PSEC_CREATE_CRED(r, p, d, nd, in, nin, c) \
132 (r) = (p)->nptr->compat.psec->create_cred((struct pmix_peer_t*)(p), \
133 (d), (nd), (in), (nin), c)
134
135 #define PMIX_PSEC_CLIENT_HANDSHAKE(r, p, sd) \
136 (r) = (p)->nptr->compat.psec->client_handshake(sd)
137
138 #define PMIX_PSEC_VALIDATE_CRED(r, p, d, nd, in, nin, c) \
139 (r) = (p)->nptr->compat.psec->validate_cred((struct pmix_peer_t*)(p), \
140 (d), (nd), \
141 (in), (nin), c)
142
143 #define PMIX_PSEC_VALIDATE_CONNECTION(r, p, d, nd, in, nin, c) \
144 do { \
145 int _r; \
146 \
147 if (NULL != (p)->nptr->compat.psec->validate_cred) { \
148 _r = (p)->nptr->compat.psec->validate_cred((struct pmix_peer_t*)(p), \
149 (d), (nd), (in), (nin), c); \
150 if (PMIX_SUCCESS != _r) { \
151 pmix_output_verbose(2, pmix_globals.debug_output, \
152 "validation of credential failed: %s", \
153 PMIx_Error_string(_r)); \
154 } else { \
155 pmix_output_verbose(2, pmix_globals.debug_output, \
156 "credential validated"); \
157 } \
158 \
159 if (PMIX_SUCCESS != (_r = pmix_ptl_base_send_blocking((p)->sd, (char*)&(_r), sizeof(int)))) { \
160 PMIX_ERROR_LOG(_r); \
161 } \
162 (r) = _r; \
163 } else if (NULL != (p)->nptr->compat.psec->server_handshake) { \
164 \
165 pmix_output_verbose(2, pmix_globals.debug_output, \
166 "executing handshake"); \
167 _r = PMIX_ERR_READY_FOR_HANDSHAKE; \
168 if (PMIX_SUCCESS != (_r = pmix_ptl_base_send_blocking((p)->sd, (char*)&(_r), sizeof(int)))) { \
169 PMIX_ERROR_LOG(_r); \
170 } else { \
171 if (PMIX_SUCCESS != (_r = p->nptr->compat.psec->server_handshake((p)->sd))) { \
172 PMIX_ERROR_LOG(_r); \
173 } \
174 } \
175 (r) = _r; \
176 } else { \
177 \
178 (r) = PMIX_ERR_NOT_SUPPORTED; \
179 } \
180 } while(0)
181
182
183
184
185 typedef pmix_status_t (*pmix_psec_base_component_init_fn_t)(void);
186
187
188 typedef void (*pmix_psec_base_component_finalize_fn_t)(void);
189
190
191 typedef pmix_psec_module_t* (*pmix_psec_base_component_assign_module_fn_t)(void);
192
193
194
195
196 struct pmix_psec_base_component_t {
197 pmix_mca_base_component_t base;
198 pmix_mca_base_component_data_t data;
199 int priority;
200 pmix_psec_base_component_init_fn_t init;
201 pmix_psec_base_component_finalize_fn_t finalize;
202 pmix_psec_base_component_assign_module_fn_t assign_module;
203 };
204 typedef struct pmix_psec_base_component_t pmix_psec_base_component_t;
205
206
207
208
209 #define PMIX_PSEC_BASE_VERSION_1_0_0 \
210 PMIX_MCA_BASE_VERSION_1_0_0("psec", 1, 0, 0)
211
212 END_C_DECLS
213
214 #endif