2011-05-02 11:38:41 +10:00
/*
2007-06-10 17:02:09 +00:00
Unix SMB / CIFS implementation .
2011-05-02 11:38:41 +10:00
CTDB Packet handling
2007-06-10 17:02:09 +00:00
Copyright ( C ) Volker Lendecke 2007
2011-02-08 23:08:21 +01:00
2007-06-10 17:02:09 +00:00
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
2007-07-09 19:25:36 +00:00
the Free Software Foundation ; either version 3 of the License , or
2007-06-10 17:02:09 +00:00
( at your option ) any later version .
2011-02-08 23:08:21 +01:00
2007-06-10 17:02:09 +00:00
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 .
2011-02-08 23:08:21 +01:00
2007-06-10 17:02:09 +00:00
You should have received a copy of the GNU General Public License
2007-07-10 00:52:41 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2007-06-10 17:02:09 +00:00
*/
/*
2011-05-02 11:38:41 +10:00
* A ctdb_packet context is a wrapper around a bidirectional file descriptor ,
2007-06-10 17:02:09 +00:00
* hiding the handling of individual requests .
*/
2011-05-02 11:38:41 +10:00
struct ctdb_packet_context ;
2007-06-10 17:02:09 +00:00
/*
2011-05-02 11:38:41 +10:00
* 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 .
2007-06-10 17:02:09 +00:00
*/
2011-05-02 11:38:41 +10:00
struct ctdb_packet_context * ctdb_packet_init ( TALLOC_CTX * mem_ctx , int fd ) ;
2007-06-10 17:02:09 +00:00
/*
* Pull data from the fd
*/
2011-05-02 11:38:41 +10:00
NTSTATUS ctdb_packet_fd_read ( struct ctdb_packet_context * ctx ) ;
2007-06-10 17:02:09 +00:00
/*
* Sync read , wait for the next chunk
*/
2011-05-03 19:11:38 +10:00
NTSTATUS ctdb_packet_fd_read_sync_timeout ( struct ctdb_packet_context * ctx , int timeout ) ;
2007-06-10 17:02:09 +00:00
/*
2011-05-02 11:38:41 +10:00
* Handle an incoming ctdb_packet :
2007-06-10 17:02:09 +00:00
* Return False if none is available
* Otherwise return True and store the callback result in * status
2008-12-20 10:44:29 +01:00
* Callback must either talloc_move or talloc_free buf
2007-06-10 17:02:09 +00:00
*/
2011-05-02 11:38:41 +10:00
bool ctdb_packet_handler ( struct ctdb_packet_context * ctx ,
2008-12-20 10:44:29 +01:00
bool ( * full_req ) ( const uint8_t * buf ,
size_t available ,
2007-06-10 17:02:09 +00:00
size_t * length ,
void * private_data ) ,
2008-12-20 10:44:29 +01:00
NTSTATUS ( * callback ) ( uint8_t * buf , size_t length ,
2007-06-10 17:02:09 +00:00
void * private_data ) ,
void * private_data ,
NTSTATUS * status ) ;
/*
* How many bytes of outgoing data do we have pending ?
*/
2011-05-02 11:38:41 +10:00
size_t ctdb_packet_outgoing_bytes ( struct ctdb_packet_context * ctx ) ;
2007-06-10 17:02:09 +00:00
/*
* Push data to the fd
*/
2011-05-02 11:38:41 +10:00
NTSTATUS ctdb_packet_fd_write ( struct ctdb_packet_context * ctx ) ;
2007-06-10 17:02:09 +00:00
/*
* Sync flush all outgoing bytes
*/
2011-05-02 11:38:41 +10:00
NTSTATUS ctdb_packet_flush ( struct ctdb_packet_context * ctx ) ;
2007-06-10 17:02:09 +00:00
/*
* Send a list of DATA_BLOBs
*
2011-05-02 11:38:41 +10:00
* Example : ctdb_packet_send ( ctx , 2 , data_blob_const ( & size , sizeof ( size ) ) ,
2007-06-10 17:02:09 +00:00
* data_blob_const ( buf , size ) ) ;
*/
2011-05-02 11:38:41 +10:00
NTSTATUS ctdb_packet_send ( struct ctdb_packet_context * ctx , int num_blobs , . . . ) ;
2007-06-10 17:02:09 +00:00
/*
2011-05-02 11:38:41 +10:00
* Get the ctdb_packet context ' s file descriptor
2007-06-10 17:02:09 +00:00
*/
2011-05-02 11:38:41 +10:00
int ctdb_packet_get_fd ( struct ctdb_packet_context * ctx ) ;