s3: Fix a typo
[Samba/gebeck_regimport.git] / source3 / include / ctdb_packet.h
blob026b23f90e428c6f1d7f74fc030ef68a9002d87f
1 /*
2 Unix SMB/CIFS implementation.
3 CTDB Packet handling
4 Copyright (C) Volker Lendecke 2007
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.
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.
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/>.
21 * A ctdb_packet context is a wrapper around a bidirectional file descriptor,
22 * hiding the handling of individual requests.
25 struct ctdb_packet_context;
28 * Initialize a ctdb_packet context. The fd is given to the ctdb_packet context, meaning
29 * that it is automatically closed when the ctdb_packet context is freed.
31 struct ctdb_packet_context *ctdb_packet_init(TALLOC_CTX *mem_ctx, int fd);
34 * Pull data from the fd
36 NTSTATUS ctdb_packet_fd_read(struct ctdb_packet_context *ctx);
39 * Sync read, wait for the next chunk
41 NTSTATUS ctdb_packet_fd_read_sync_timeout(struct ctdb_packet_context *ctx, int timeout);
44 * Handle an incoming ctdb_packet:
45 * Return False if none is available
46 * Otherwise return True and store the callback result in *status
47 * Callback must either talloc_move or talloc_free buf
49 bool ctdb_packet_handler(struct ctdb_packet_context *ctx,
50 bool (*full_req)(const uint8_t *buf,
51 size_t available,
52 size_t *length,
53 void *private_data),
54 NTSTATUS (*callback)(uint8_t *buf, size_t length,
55 void *private_data),
56 void *private_data,
57 NTSTATUS *status);
60 * How many bytes of outgoing data do we have pending?
62 size_t ctdb_packet_outgoing_bytes(struct ctdb_packet_context *ctx);
65 * Push data to the fd
67 NTSTATUS ctdb_packet_fd_write(struct ctdb_packet_context *ctx);
70 * Sync flush all outgoing bytes
72 NTSTATUS ctdb_packet_flush(struct ctdb_packet_context *ctx);
75 * Send a list of DATA_BLOBs
77 * Example: ctdb_packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
78 * data_blob_const(buf, size));
80 NTSTATUS ctdb_packet_send(struct ctdb_packet_context *ctx, int num_blobs, ...);
83 * Get the ctdb_packet context's file descriptor
85 int ctdb_packet_get_fd(struct ctdb_packet_context *ctx);