s4:torture: Initialize struct cldap_netlogon
[Samba.git] / libcli / util / tstream.h
blobcf66abe942bbc2cd6c1e46495be3ac09ecd45b19
1 /*
2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Stefan Metzmacher 2009
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/>.
20 #ifndef _LIBCLI_UTIL_TSTREAM_H_
21 #define _LIBCLI_UTIL_TSTREAM_H_
23 /**
24 * @brief The function which will report the size of the full pdu.
26 * @param[in] stream The tstream_context to operate on
28 * @param[in] private_data Some private data which could be used.
30 * @param[in] blob The received blob to get the size from.
32 * @param[out] packet_size The pointer to store the size of the full pdu.
34 * @return NT_STATUS_OK on success, STATUS_MORE_ENTRIES if there
35 * are more entries.
37 typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(struct tstream_context *stream,
38 void *private_data,
39 DATA_BLOB blob,
40 size_t *packet_size);
42 /**
43 * @brief A helper function to read a full PDU from a stream
45 * This function is designed for simple PDUs and as compat layer
46 * for the Samba4 packet interface.
48 * tstream_readv_pdu_send() is a more powerful interface,
49 * which is part of the main (non samba specific) tsocket code.
51 * @param[in] mem_ctx The memory context for the result.
53 * @param[in] ev The event context the operation should work on.
55 * @param[in] stream The stream to read data from.
57 * @param[in] initial_read_size The initial byte count that is needed to workout
58 * the full pdu size.
60 * @param[in] full_fn The callback function that will report the size
61 * of the full pdu.
63 * @param[in] full_private The private data for the callback function.
65 * @return The async request handle. NULL on fatal error.
67 * @see tstream_read_pdu_blob_recv()
68 * @see tstream_readv_pdu_send()
69 * @see tstream_readv_pdu_queue_send()
72 struct tevent_req *tstream_read_pdu_blob_send(TALLOC_CTX *mem_ctx,
73 struct tevent_context *ev,
74 struct tstream_context *stream,
75 size_t initial_read_size,
76 tstream_read_pdu_blob_full_fn_t *full_fn,
77 void *full_private);
78 /**
79 * @brief Receive the result of the tstream_read_pdu_blob_send() call.
81 * @param[in] req The tevent request from tstream_read_pdu_blob_send().
83 * @param[in] mem_ctx The memory context for returned pdu DATA_BLOB.
85 * @param[in] pdu_blob The DATA_BLOB with the full pdu.
87 * @return The NTSTATUS result, NT_STATUS_OK on success
88 * and others on failure.
90 * @see tstream_read_pdu_blob_send()
92 NTSTATUS tstream_read_pdu_blob_recv(struct tevent_req *req,
93 TALLOC_CTX *mem_ctx,
94 DATA_BLOB *pdu_blob);
96 /**
97 * @brief Get a PDU size with a 32 bit size header field
99 * Work out if a packet is complete for protocols that use a 32 bit
100 * network byte order length.
102 * @see tstream_read_pdu_blob_send()
103 * @see tstream_read_pdu_blob_recv()
105 NTSTATUS tstream_full_request_u32(struct tstream_context *stream,
106 void *private_data,
107 DATA_BLOB blob, size_t *size);
110 * @brief Get a PDU size with a 16 bit size header field
112 * Work out if a packet is complete for protocols that use a 16 bit
113 * network byte order length.
115 * @see tstream_read_pdu_blob_send()
116 * @see tstream_read_pdu_blob_recv()
118 NTSTATUS tstream_full_request_u16(struct tstream_context *stream,
119 void *private_data,
120 DATA_BLOB blob, size_t *size);
123 #endif /* _LIBCLI_UTIL_TSTREAM_H_ */