root/include/crm/common/remote_internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pcmk__is_pacemaker_remote_node
  2. pcmk__is_remote_node
  3. pcmk__is_guest_or_bundle_node

   1 /*
   2  * Copyright 2008-2024 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef PCMK__CRM_COMMON_REMOTE_INTERNAL__H
  11 #define PCMK__CRM_COMMON_REMOTE_INTERNAL__H
  12 
  13 #include <stdbool.h>                    // bool
  14 
  15 #include <crm/common/nodes.h>           // pcmk_node_variant_remote
  16 #include <crm/common/scheduler_types.h> // pcmk_node_t
  17 
  18 // internal functions from remote.c
  19 
  20 typedef struct pcmk__remote_s pcmk__remote_t;
  21 
  22 int pcmk__remote_send_xml(pcmk__remote_t *remote, const xmlNode *msg);
  23 int pcmk__remote_ready(const pcmk__remote_t *remote, int timeout_ms);
  24 int pcmk__read_available_remote_data(pcmk__remote_t *remote);
  25 int pcmk__read_remote_message(pcmk__remote_t *remote, int timeout_ms);
  26 xmlNode *pcmk__remote_message_xml(pcmk__remote_t *remote);
  27 int pcmk__connect_remote(const char *host, int port, int timeout_ms,
  28                          int *timer_id, int *sock_fd, void *userdata,
  29                          void (*callback) (void *userdata, int rc, int sock));
  30 int pcmk__accept_remote_connection(int ssock, int *csock);
  31 void pcmk__sockaddr2str(const void *sa, char *s);
  32 
  33 /*!
  34  * \internal
  35  * \brief Check whether a node is a Pacemaker Remote node of any kind
  36  *
  37  * \param[in] node  Node to check
  38  *
  39  * \return true if \p node is a remote, guest, or bundle node, otherwise false
  40  */
  41 static inline bool
  42 pcmk__is_pacemaker_remote_node(const pcmk_node_t *node)
     /* [previous][next][first][last][top][bottom][index][help] */
  43 {
  44     return (node != NULL) && (node->details->type == pcmk_node_variant_remote);
  45 }
  46 
  47 /*!
  48  * \internal
  49  * \brief Check whether a node is a remote node
  50  *
  51  * \param[in] node  Node to check
  52  *
  53  * \return true if \p node is a remote node, otherwise false
  54  */
  55 static inline bool
  56 pcmk__is_remote_node(const pcmk_node_t *node)
     /* [previous][next][first][last][top][bottom][index][help] */
  57 {
  58     return pcmk__is_pacemaker_remote_node(node)
  59            && ((node->details->remote_rsc == NULL)
  60                || (node->details->remote_rsc->container == NULL));
  61 }
  62 
  63 /*!
  64  * \internal
  65  * \brief Check whether a node is a guest or bundle node
  66  *
  67  * \param[in] node  Node to check
  68  *
  69  * \return true if \p node is a guest or bundle node, otherwise false
  70  */
  71 static inline bool
  72 pcmk__is_guest_or_bundle_node(const pcmk_node_t *node)
     /* [previous][next][first][last][top][bottom][index][help] */
  73 {
  74     return pcmk__is_pacemaker_remote_node(node)
  75            && (node->details->remote_rsc != NULL)
  76            && (node->details->remote_rsc->container != NULL);
  77 }
  78 
  79 #ifdef HAVE_GNUTLS_GNUTLS_H
  80 #include <gnutls/gnutls.h>
  81 
  82 gnutls_session_t *pcmk__new_tls_session(int csock, unsigned int conn_type,
  83                                         gnutls_credentials_type_t cred_type,
  84                                         void *credentials);
  85 int pcmk__init_tls_dh(gnutls_dh_params_t *dh_params);
  86 int pcmk__read_handshake_data(const pcmk__client_t *client);
  87 
  88 /*!
  89  * \internal
  90  * \brief Make a single attempt to perform the client TLS handshake
  91  *
  92  * \param[in,out] remote       Newly established remote connection
  93  * \param[out]    gnutls_rc    If this is non-NULL, it will be set to the GnuTLS
  94  *                             rc (for logging) if this function returns EPROTO,
  95  *                             otherwise GNUTLS_E_SUCCESS
  96  *
  97  * \return Standard Pacemaker return code
  98  */
  99 int pcmk__tls_client_try_handshake(pcmk__remote_t *remote, int *gnutls_rc);
 100 
 101 /*!
 102  * \internal
 103  * \brief Perform client TLS handshake after establishing TCP socket
 104  *
 105  * \param[in,out] remote       Newly established remote connection
 106  * \param[in]     timeout_sec  Abort handshake if not completed within this time
 107  * \param[out]    gnutls_rc    If this is non-NULL, it will be set to the GnuTLS
 108  *                             rc (for logging) if this function returns EPROTO,
 109  *                             otherwise GNUTLS_E_SUCCESS
 110  *
 111  * \return Standard Pacemaker return code
 112  */
 113 int pcmk__tls_client_handshake(pcmk__remote_t *remote, int timeout_sec,
 114                                int *gnutls_rc);
 115 
 116 #endif    // HAVE_GNUTLS_GNUTLS_H
 117 #endif      // PCMK__CRM_COMMON_REMOTE_INTERNAL__H

/* [previous][next][first][last][top][bottom][index][help] */