File: remote_internal.h

package info (click to toggle)
pacemaker 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 68,576 kB
  • sloc: xml: 160,564; ansic: 143,744; python: 5,670; sh: 2,969; makefile: 2,426
file content (92 lines) | stat: -rw-r--r-- 2,817 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright 2008-2024 the Pacemaker project contributors
 *
 * The version control history for this file may have further details.
 *
 * This source code is licensed under the GNU Lesser General Public License
 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
 */

#ifndef PCMK__CRM_COMMON_REMOTE_INTERNAL__H
#define PCMK__CRM_COMMON_REMOTE_INTERNAL__H

#include <stdio.h>          // NULL
#include <stdbool.h>        // bool
#include <libxml/tree.h>    // xmlNode

#include <crm/common/ipc_internal.h>        // pcmk__client_t
#include <crm/common/nodes_internal.h>      // pcmk__node_variant_remote, etc.
#include <crm/common/resources_internal.h>  // struct pcmk__remote_private
#include <crm/common/scheduler_types.h>     // pcmk_node_t

#ifdef __cplusplus
extern "C" {
#endif

// internal functions from remote.c

typedef struct pcmk__remote_s pcmk__remote_t;

int pcmk__remote_send_xml(pcmk__remote_t *remote, const xmlNode *msg);
int pcmk__remote_ready(const pcmk__remote_t *remote, int timeout_ms);
int pcmk__read_available_remote_data(pcmk__remote_t *remote);
int pcmk__read_remote_message(pcmk__remote_t *remote, int timeout_ms);
xmlNode *pcmk__remote_message_xml(pcmk__remote_t *remote);
int pcmk__connect_remote(const char *host, int port, int timeout_ms,
                         int *timer_id, int *sock_fd, void *userdata,
                         void (*callback) (void *userdata, int rc, int sock));
int pcmk__accept_remote_connection(int ssock, int *csock);
void pcmk__sockaddr2str(const void *sa, char *s);

/*!
 * \internal
 * \brief Check whether a node is a Pacemaker Remote node of any kind
 *
 * \param[in] node  Node to check
 *
 * \return true if \p node is a remote, guest, or bundle node, otherwise false
 */
static inline bool
pcmk__is_pacemaker_remote_node(const pcmk_node_t *node)
{
    return (node != NULL)
            && (node->priv->variant == pcmk__node_variant_remote);
}

/*!
 * \internal
 * \brief Check whether a node is a remote node
 *
 * \param[in] node  Node to check
 *
 * \return true if \p node is a remote node, otherwise false
 */
static inline bool
pcmk__is_remote_node(const pcmk_node_t *node)
{
    return pcmk__is_pacemaker_remote_node(node)
           && ((node->priv->remote == NULL)
               || (node->priv->remote->priv->launcher == NULL));
}

/*!
 * \internal
 * \brief Check whether a node is a guest or bundle node
 *
 * \param[in] node  Node to check
 *
 * \return true if \p node is a guest or bundle node, otherwise false
 */
static inline bool
pcmk__is_guest_or_bundle_node(const pcmk_node_t *node)
{
    return pcmk__is_pacemaker_remote_node(node)
           && (node->priv->remote != NULL)
           && (node->priv->remote->priv->launcher != NULL);
}

#ifdef __cplusplus
}
#endif

#endif      // PCMK__CRM_COMMON_REMOTE_INTERNAL__H