[go: up one dir, main page]

Menu

[0a8e4a]: / src / flom_client.h  Maximize  Restore  History

Download this file

167 lines (115 with data), 4.2 kB

  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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) 2013-2014, Christian Ferrari <tiian@users.sourceforge.net>
* All rights reserved.
*
* This file is part of FLOM.
*
* FLOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* FLOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FLOM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLIENT_H
# define CLIENT_H
#include <config.h>
#include "flom_config.h"
#include "flom_conns.h"
#include "flom_trace.h"
/* save old FLOM_TRACE_MODULE and set a new value */
#ifdef FLOM_TRACE_MODULE
# define FLOM_TRACE_MODULE_SAVE FLOM_TRACE_MODULE
# undef FLOM_TRACE_MODULE
#else
# undef FLOM_TRACE_MODULE_SAVE
#endif /* FLOM_TRACE_MODULE */
#define FLOM_TRACE_MODULE FLOM_TRACE_MOD_CLIENT
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* Try to connect to flom daemon
* @param cd OUT connection data
* @result a reason code
*/
int flom_client_connect(struct flom_conn_data_s *cd);
/**
* Try to connect to flom daemon using local (AF_LOCAL) socket
* @param cd OUT connection data
* @result a reason code
*/
int flom_client_connect_local(struct flom_conn_data_s *cd);
/**
* Try to connect to flom daemon using network (TCP/IP) socket
* @param cd OUT connection data
* @result a reason code
*/
int flom_client_connect_tcp(struct flom_conn_data_s *cd);
/**
* A TCP/IP connection chance: it can be reapeted after daemon start-up
* @param gai IN result obtained by getaddrinfo function
* @param fd OUT file descriptor associated to the connected socket
* @return the pointer to the element successfully connected, NULL if no
* element is available
*/
const struct addrinfo *flom_client_connect_tcp_try(
const struct addrinfo *gai, int *fd);
/**
* Discover flom daemon address using multicast UDP
* @param cd IN/OUT connection data
* @return a reason code
*/
int flom_client_discover_udp(struct flom_conn_data_s *cd);
/**
* Connect to a daemon using TCP/IP; daemon was previously discovered
* using multicast UDP/IP
* @param cd IN/OUT connection data
* @param soin IN address and port of daemon
* @return a reason code
*/
int flom_client_discover_udp_connect(struct flom_conn_data_s *cd,
const struct sockaddr_in *soin);
/**
* Disconnect from lock daemon
* @param cd IN/OUT connection data
* @result a reason code
*/
int flom_client_disconnect(struct flom_conn_data_s *cd);
/**
* Send lock command to the daemon
* @param cd IN connection data
* @param timeout IN maximum wait time for lock acquisition
* @return a reason code
*/
int flom_client_lock(struct flom_conn_data_s *cd, int timeout);
/**
* Wait while the desired resource is busy, then go on
* @param cd IN connection data
* @param msg IN/OUT message used to deserialize the replies
* @param timeout IN maximum wait time for lock acquisition
* @return a reason code
*/
int flom_client_wait_lock(struct flom_conn_data_s *cd,
struct flom_msg_s *msg, int timeout);
/**
* Send unlock command to the daemon
* @param cd IN connection data
* @return a reason code
*/
int flom_client_unlock(struct flom_conn_data_s *cd);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* restore old value of FLOM_TRACE_MODULE */
#ifdef FLOM_TRACE_MODULE_SAVE
# undef FLOM_TRACE_MODULE
# define FLOM_TRACE_MODULE FLOM_TRACE_MODULE_SAVE
# undef FLOM_TRACE_MODULE_SAVE
#endif /* FLOM_TRACE_MODULE_SAVE */
#endif /* CLIENT_H */