#ifndef PMIX_PSEC_H
#define PMIX_PSEC_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
#include "src/mca/ptl/ptl_types.h"
BEGIN_C_DECLS
struct pmix_peer_t;
typedef pmix_status_t (*pmix_psec_base_module_init_fn_t)(void);
typedef void (*pmix_psec_base_module_fini_fn_t)(void);
typedef pmix_status_t (*pmix_psec_base_module_create_cred_fn_t)(struct pmix_peer_t *peer,
const pmix_info_t directives[],
size_t ndirs, pmix_info_t **info,
size_t *ninfo,
pmix_byte_object_t *cred);
typedef pmix_status_t (*pmix_psec_base_module_client_hndshk_fn_t)(int sd);
typedef pmix_status_t (*pmix_psec_base_module_validate_cred_fn_t)(struct pmix_peer_t *peer,
const pmix_info_t directives[],
size_t ndirs, pmix_info_t **info,
size_t *ninfo,
const pmix_byte_object_t *cred);
typedef pmix_status_t (*pmix_psec_base_module_server_hndshk_fn_t)(int sd);
typedef struct {
char *name;
pmix_psec_base_module_init_fn_t init;
pmix_psec_base_module_fini_fn_t finalize;
pmix_psec_base_module_create_cred_fn_t create_cred;
pmix_psec_base_module_client_hndshk_fn_t client_handshake;
pmix_psec_base_module_validate_cred_fn_t validate_cred;
pmix_psec_base_module_server_hndshk_fn_t server_handshake;
} pmix_psec_module_t;
PMIX_EXPORT char *pmix_psec_base_get_available_modules(void);
PMIX_EXPORT pmix_psec_module_t *pmix_psec_base_assign_module(const char *options);
#define PMIX_PSEC_CREATE_CRED(r, p, d, nd, in, nin, c) \
(r) = (p)->nptr->compat.psec->create_cred((struct pmix_peer_t *) (p), (d), (nd), (in), (nin), c)
#define PMIX_PSEC_CLIENT_HANDSHAKE(r, p, sd) (r) = (p)->nptr->compat.psec->client_handshake(sd)
#define PMIX_PSEC_VALIDATE_CRED(r, p, d, nd, in, nin, c) \
(r) = (p)->nptr->compat.psec->validate_cred((struct pmix_peer_t *) (p), (d), (nd), (in), \
(nin), c)
#define PMIX_PSEC_VALIDATE_CONNECTION(r, p, d, nd, in, nin, c) \
do { \
int _r; \
\
if (NULL != (p)->nptr->compat.psec->validate_cred) { \
_r = (p)->nptr->compat.psec->validate_cred((struct pmix_peer_t *) (p), (d), (nd), \
(in), (nin), c); \
if (PMIX_SUCCESS != _r) { \
pmix_output_verbose(2, pmix_globals.debug_output, \
"validation of credential failed: %s", PMIx_Error_string(_r)); \
} else { \
pmix_output_verbose(2, pmix_globals.debug_output, "credential validated"); \
} \
(r) = _r; \
} else if (NULL != (p)->nptr->compat.psec->server_handshake) { \
\
pmix_output_verbose(2, pmix_globals.debug_output, "requesting handshake"); \
_r = PMIX_ERR_READY_FOR_HANDSHAKE; \
(r) = _r; \
} else { \
\
(r) = PMIX_ERR_NOT_SUPPORTED; \
} \
} while (0)
#define PMIX_PSEC_SERVER_HANDSHAKE_IFNEED(r, p) \
if (PMIX_ERR_READY_FOR_HANDSHAKE == r) { \
int _r; \
\
pmix_output_verbose(2, pmix_globals.debug_output, "executing handshake"); \
if (PMIX_SUCCESS != (_r = p->nptr->compat.psec->server_handshake((p)->sd))) { \
PMIX_ERROR_LOG(_r); \
} \
\
(r) = _r; \
}
typedef pmix_status_t (*pmix_psec_base_component_init_fn_t)(void);
typedef void (*pmix_psec_base_component_finalize_fn_t)(void);
typedef pmix_psec_module_t *(*pmix_psec_base_component_assign_module_fn_t)(void);
struct pmix_psec_base_component_t {
pmix_mca_base_component_t base;
int priority;
pmix_psec_base_component_init_fn_t init;
pmix_psec_base_component_finalize_fn_t finalize;
pmix_psec_base_component_assign_module_fn_t assign_module;
};
typedef struct pmix_psec_base_component_t pmix_psec_base_component_t;
#define PMIX_PSEC_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("psec", 1, 0, 0)
END_C_DECLS
#endif