r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / include / packet.h
blob9f364827051bfa9f1a1ddf459bfe159fd13b52c7
1 /*
2 Unix SMB/CIFS implementation.
3 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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * A packet context is a wrapper around a bidirectional file descriptor,
23 * hiding the handling of individual requests.
26 struct packet_context;
29 * Initialize a packet context. The fd is given to the packet context, meaning
30 * that it is automatically closed when the packet context is freed.
32 struct packet_context *packet_init(TALLOC_CTX *mem_ctx, int fd);
35 * Pull data from the fd
37 NTSTATUS packet_fd_read(struct packet_context *ctx);
40 * Sync read, wait for the next chunk
42 NTSTATUS packet_fd_read_sync(struct packet_context *ctx);
45 * Handle an incoming packet:
46 * Return False if none is available
47 * Otherwise return True and store the callback result in *status
49 BOOL packet_handler(struct packet_context *ctx,
50 BOOL (*full_req)(const struct data_blob *data,
51 size_t *length,
52 void *private_data),
53 NTSTATUS (*callback)(const struct data_blob *data,
54 void *private_data),
55 void *private_data,
56 NTSTATUS *status);
59 * How many bytes of outgoing data do we have pending?
61 size_t packet_outgoing_bytes(struct packet_context *ctx);
64 * Push data to the fd
66 NTSTATUS packet_fd_write(struct packet_context *ctx);
69 * Sync flush all outgoing bytes
71 NTSTATUS packet_flush(struct packet_context *ctx);
74 * Send a list of DATA_BLOBs
76 * Example: packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
77 * data_blob_const(buf, size));
79 NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...);
82 * Get the packet context's file descriptor
84 int packet_get_fd(struct packet_context *ctx);