[740] | 1 | /*
|
---|
| 2 | * Unix SMB/CIFS implementation.
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) Stefan Metzmacher 2009
|
---|
| 5 | *
|
---|
| 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.
|
---|
| 10 | *
|
---|
| 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.
|
---|
| 15 | *
|
---|
| 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/>.
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 | #ifndef _LIBCLI_UTIL_TSTREAM_H_
|
---|
| 21 | #define _LIBCLI_UTIL_TSTREAM_H_
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * @brief The function which will report the size of the full pdu.
|
---|
| 25 | *
|
---|
| 26 | * @param[in] private_data Some private data which could be used.
|
---|
| 27 | *
|
---|
| 28 | * @param[in] blob The received blob to get the size from.
|
---|
| 29 | *
|
---|
| 30 | * @param[out] packet_size The pointer to store the size of the full pdu.
|
---|
| 31 | *
|
---|
| 32 | * @return NT_STATUS_OK on success, STATUS_MORE_ENTRIES if there
|
---|
| 33 | * are more entries.
|
---|
| 34 | */
|
---|
| 35 | typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(void *private_data,
|
---|
| 36 | DATA_BLOB blob,
|
---|
| 37 | size_t *packet_size);
|
---|
| 38 |
|
---|
| 39 | /**
|
---|
| 40 | * @brief A helper function to read a full PDU from a stream
|
---|
| 41 | *
|
---|
| 42 | * This function is designed for simple PDUs and as compat layer
|
---|
| 43 | * for the Samba4 packet interface.
|
---|
| 44 | *
|
---|
| 45 | * tstream_readv_pdu_send() is a more powerful interface,
|
---|
| 46 | * which is part of the main (non samba specific) tsocket code.
|
---|
| 47 | *
|
---|
| 48 | * @param[in] mem_ctx The memory context for the result.
|
---|
| 49 | *
|
---|
| 50 | * @param[in] ev The event context the operation should work on.
|
---|
| 51 | *
|
---|
| 52 | * @param[in] stream The stream to read data from.
|
---|
| 53 | *
|
---|
| 54 | * @param[in] inital_read_size The initial byte count that is needed to workout
|
---|
| 55 | * the full pdu size.
|
---|
| 56 | *
|
---|
| 57 | * @param[in] full_fn The callback function that will report the size
|
---|
| 58 | * of the full pdu.
|
---|
| 59 | *
|
---|
| 60 | * @param[in] full_private The private data for the callback function.
|
---|
| 61 | *
|
---|
| 62 | * @return The async request handle. NULL on fatal error.
|
---|
| 63 | *
|
---|
| 64 | * @see tstream_read_pdu_blob_recv()
|
---|
| 65 | * @see tstream_readv_pdu_send()
|
---|
| 66 | * @see tstream_readv_pdu_queue_send()
|
---|
| 67 | *
|
---|
| 68 | */
|
---|
| 69 | struct tevent_req *tstream_read_pdu_blob_send(TALLOC_CTX *mem_ctx,
|
---|
| 70 | struct tevent_context *ev,
|
---|
| 71 | struct tstream_context *stream,
|
---|
| 72 | size_t inital_read_size,
|
---|
| 73 | tstream_read_pdu_blob_full_fn_t *full_fn,
|
---|
| 74 | void *full_private);
|
---|
| 75 | /**
|
---|
| 76 | * @brief Receive the result of the tstream_read_pdu_blob_send() call.
|
---|
| 77 | *
|
---|
| 78 | * @param[in] req The tevent request from tstream_read_pdu_blob_send().
|
---|
| 79 | *
|
---|
| 80 | * @param[in] mem_ctx The memory context for returned pdu DATA_BLOB.
|
---|
| 81 | *
|
---|
| 82 | * @param[in] pdu_blob The DATA_BLOB with the full pdu.
|
---|
| 83 | *
|
---|
| 84 | * @return The NTSTATUS result, NT_STATUS_OK on success
|
---|
| 85 | * and others on failure.
|
---|
| 86 | *
|
---|
| 87 | * @see tstream_read_pdu_blob_send()
|
---|
| 88 | */
|
---|
| 89 | NTSTATUS tstream_read_pdu_blob_recv(struct tevent_req *req,
|
---|
| 90 | TALLOC_CTX *mem_ctx,
|
---|
| 91 | DATA_BLOB *pdu_blob);
|
---|
| 92 |
|
---|
| 93 | #endif /* _LIBCLI_UTIL_TSTREAM_H_ */
|
---|