diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
commit | 6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch) | |
tree | 850c71039563c16a5d563c47e7ba2ab645baf198 /source3/include/ctdb_packet.h | |
parent | 6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff) | |
parent | 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff) | |
download | samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.gz samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.bz2 samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.zip |
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16
Diffstat (limited to 'source3/include/ctdb_packet.h')
-rw-r--r-- | source3/include/ctdb_packet.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/source3/include/ctdb_packet.h b/source3/include/ctdb_packet.h new file mode 100644 index 0000000000..026b23f90e --- /dev/null +++ b/source3/include/ctdb_packet.h @@ -0,0 +1,85 @@ +/* + Unix SMB/CIFS implementation. + CTDB Packet handling + Copyright (C) Volker Lendecke 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +/* + * A ctdb_packet context is a wrapper around a bidirectional file descriptor, + * hiding the handling of individual requests. + */ + +struct ctdb_packet_context; + +/* + * Initialize a ctdb_packet context. The fd is given to the ctdb_packet context, meaning + * that it is automatically closed when the ctdb_packet context is freed. + */ +struct ctdb_packet_context *ctdb_packet_init(TALLOC_CTX *mem_ctx, int fd); + +/* + * Pull data from the fd + */ +NTSTATUS ctdb_packet_fd_read(struct ctdb_packet_context *ctx); + +/* + * Sync read, wait for the next chunk + */ +NTSTATUS ctdb_packet_fd_read_sync_timeout(struct ctdb_packet_context *ctx, int timeout); + +/* + * Handle an incoming ctdb_packet: + * Return False if none is available + * Otherwise return True and store the callback result in *status + * Callback must either talloc_move or talloc_free buf + */ +bool ctdb_packet_handler(struct ctdb_packet_context *ctx, + bool (*full_req)(const uint8_t *buf, + size_t available, + size_t *length, + void *private_data), + NTSTATUS (*callback)(uint8_t *buf, size_t length, + void *private_data), + void *private_data, + NTSTATUS *status); + +/* + * How many bytes of outgoing data do we have pending? + */ +size_t ctdb_packet_outgoing_bytes(struct ctdb_packet_context *ctx); + +/* + * Push data to the fd + */ +NTSTATUS ctdb_packet_fd_write(struct ctdb_packet_context *ctx); + +/* + * Sync flush all outgoing bytes + */ +NTSTATUS ctdb_packet_flush(struct ctdb_packet_context *ctx); + +/* + * Send a list of DATA_BLOBs + * + * Example: ctdb_packet_send(ctx, 2, data_blob_const(&size, sizeof(size)), + * data_blob_const(buf, size)); + */ +NTSTATUS ctdb_packet_send(struct ctdb_packet_context *ctx, int num_blobs, ...); + +/* + * Get the ctdb_packet context's file descriptor + */ +int ctdb_packet_get_fd(struct ctdb_packet_context *ctx); |