ctdbd_conn: pass persistent bool instead of tdb_flags
[samba.git] / source3 / include / ctdbd_conn.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Samba3 ctdb connection handling
4    Copyright (C) Volker Lendecke 2007
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 _CTDBD_CONN_H
21 #define _CTDBD_CONN_H
22
23 #include "replace.h"
24 #include "system/filesys.h"
25 #include "system/network.h"
26 #include "lib/dbwrap/dbwrap.h"
27 #include <tdb.h>
28 #include <tevent.h>
29
30 struct ctdbd_connection;
31 struct messaging_context;
32 struct messaging_rec;
33
34 int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
35                           const char *sockname, int timeout,
36                           struct ctdbd_connection **pconn);
37 int ctdbd_reinit_connection(TALLOC_CTX *mem_ctx,
38                             const char *sockname, int timeout,
39                             struct ctdbd_connection *conn);
40 int ctdbd_setup_fde(struct ctdbd_connection *conn, struct tevent_context *ev);
41
42 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
43
44 int ctdbd_conn_get_fd(struct ctdbd_connection *conn);
45 void ctdbd_socket_readable(struct ctdbd_connection *conn);
46
47 int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
48                              uint32_t dst_vnn, uint64_t dst_srvid,
49                              const struct iovec *iov, int iovlen);
50
51 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
52                           pid_t pid);
53
54 char *ctdbd_dbpath(struct ctdbd_connection *conn,
55                    TALLOC_CTX *mem_ctx, uint32_t db_id);
56
57 int ctdbd_db_attach(struct ctdbd_connection *conn, const char *name,
58                     uint32_t *db_id, bool persistent);
59
60 int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key);
61
62 int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
63                 TDB_DATA key, bool local_copy,
64                 void (*parser)(TDB_DATA key, TDB_DATA data,
65                                void *private_data),
66                 void *private_data);
67
68 int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
69                    void (*fn)(TDB_DATA key, TDB_DATA data,
70                               void *private_data),
71                    void *private_data);
72
73 int ctdbd_register_ips(struct ctdbd_connection *conn,
74                        const struct sockaddr_storage *server,
75                        const struct sockaddr_storage *client,
76                        int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
77                                  uint64_t dst_srvid,
78                                  const uint8_t *msg, size_t msglen,
79                                  void *private_data),
80                        void *private_data);
81
82 int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
83                         uint64_t srvid, uint32_t flags, TDB_DATA data,
84                         TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
85                         int32_t *cstatus);
86 int ctdb_watch_us(struct ctdbd_connection *conn);
87 int ctdb_unwatch(struct ctdbd_connection *conn);
88
89 struct ctdb_req_message_old;
90
91 int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
92                         int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
93                                   uint64_t dst_srvid,
94                                   const uint8_t *msg, size_t msglen,
95                                   void *private_data),
96                         void *private_data);
97 int ctdbd_probe(const char *sockname, int timeout);
98
99 struct tevent_req *ctdbd_parse_send(TALLOC_CTX *mem_ctx,
100                                     struct tevent_context *ev,
101                                     struct ctdbd_connection *conn,
102                                     uint32_t db_id,
103                                     TDB_DATA key,
104                                     bool local_copy,
105                                     void (*parser)(TDB_DATA key,
106                                                    TDB_DATA data,
107                                                    void *private_data),
108                                     void *private_data,
109                                     enum dbwrap_req_state *req_state);
110 int ctdbd_parse_recv(struct tevent_req *req);
111
112 #endif /* _CTDBD_CONN_H */