ctdb-client: Add client api for using tunnels
[vlendec/samba-autobuild/.git] / ctdb / client / client_private.h
1 /*
2    CTDB client code
3
4    Copyright (C) Amitay Isaacs  2015
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __CTDB_CLIENT_PRIVATE_H__
21 #define __CTDB_CLIENT_PRIVATE_H__
22
23 #include "protocol/protocol.h"
24 #include "client/client.h"
25
26 struct ctdb_db_context {
27         struct ctdb_db_context *prev, *next;
28         uint32_t db_id;
29         uint8_t db_flags;
30         const char *db_name;
31         const char *db_path;
32         struct tdb_wrap *ltdb;
33 };
34
35 struct ctdb_client_context {
36         struct reqid_context *idr;
37         struct srvid_context *srv;
38         struct srvid_context *tunnels;
39         struct comm_context *comm;
40         ctdb_client_callback_func_t callback;
41         void *private_data;
42         int fd;
43         uint32_t pnn;
44         struct ctdb_db_context *db;
45 };
46
47 struct ctdb_record_handle {
48         struct tevent_context *ev;
49         struct ctdb_client_context *client;
50         struct ctdb_db_context *db;
51         struct ctdb_ltdb_header header;
52         TDB_DATA key;
53         TDB_DATA data; /* This is returned from tdb_fetch() */
54         bool readonly;
55 };
56
57 struct ctdb_transaction_handle {
58         struct tevent_context *ev;
59         struct ctdb_client_context *client;
60         struct ctdb_db_context *db, *db_g_lock;
61         struct ctdb_rec_buffer *recbuf;
62         struct ctdb_server_id sid;
63         const char *lock_name;
64         bool readonly;
65         bool updated;
66 };
67
68 struct ctdb_tunnel_context {
69         struct ctdb_client_context *client;
70         uint64_t tunnel_id;
71         ctdb_tunnel_callback_func_t callback;
72         void *private_data;
73 };
74
75 /* From client_call.c */
76
77 void ctdb_client_reply_call(struct ctdb_client_context *client,
78                             uint8_t *buf, size_t buflen, uint32_t reqid);
79
80 /* From client_message.c */
81
82 void ctdb_client_req_message(struct ctdb_client_context *client,
83                              uint8_t *buf, size_t buflen, uint32_t reqid);
84
85 /* From client_control.c */
86
87 void ctdb_client_reply_control(struct ctdb_client_context *client,
88                                uint8_t *buf, size_t buflen, uint32_t reqid);
89
90 /* From client_tunnel.c */
91
92 void ctdb_client_req_tunnel(struct ctdb_client_context *client,
93                             uint8_t *buf, size_t buflen, uint32_t reqid);
94
95 #endif /* __CTDB_CLIENT_PRIVATE_H__ */