2 Unix SMB/CIFS implementation.
4 composite request interfaces
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __COMPOSITE_H__
23 #define __COMPOSITE_H__
25 #include "libcli/raw/interfaces.h"
28 this defines the structures associated with "composite"
29 requests. Composite requests are libcli requests that are internally
30 implemented as multiple async calls, but can be treated as a
31 single call via these composite calls. The composite calls are
32 particularly designed to be used in async applications.
33 you can also stack multiple level of composite call
37 a composite call moves between the following 3 states.
39 enum composite_state { COMPOSITE_STATE_INIT, /* we are creating the request */
40 COMPOSITE_STATE_IN_PROGRESS, /* the request is in the outgoing socket Q */
41 COMPOSITE_STATE_DONE, /* the request is received by the caller finished */
42 COMPOSITE_STATE_ERROR }; /* a packet or transport level error has occurred */
44 /* the context of one "composite" call */
45 struct composite_context {
46 /* the external state - will be queried by the caller */
47 enum composite_state state;
49 /* a private pointer for use by the composite function
53 /* status code when finished */
56 /* the event context we are using */
57 struct event_context *event_ctx;
59 /* information on what to do on completion */
61 void (*fn)(struct composite_context *);
69 struct smbcli_request;
72 struct nbt_name_request;
74 struct composite_context *composite_create(TALLOC_CTX *mem_ctx, struct event_context *ev);
75 bool composite_nomem(const void *p, struct composite_context *ctx);
76 void composite_continue(struct composite_context *ctx,
77 struct composite_context *new_ctx,
78 void (*continuation)(struct composite_context *),
80 void composite_continue_rpc(struct composite_context *ctx,
81 struct rpc_request *new_req,
82 void (*continuation)(struct rpc_request *),
84 void composite_continue_irpc(struct composite_context *ctx,
85 struct irpc_request *new_req,
86 void (*continuation)(struct irpc_request *),
88 void composite_continue_smb(struct composite_context *ctx,
89 struct smbcli_request *new_req,
90 void (*continuation)(struct smbcli_request *),
92 void composite_continue_smb2(struct composite_context *ctx,
93 struct smb2_request *new_req,
94 void (*continuation)(struct smb2_request *),
96 void composite_continue_nbt(struct composite_context *ctx,
97 struct nbt_name_request *new_req,
98 void (*continuation)(struct nbt_name_request *),
100 bool composite_is_ok(struct composite_context *ctx);
101 void composite_done(struct composite_context *ctx);
102 void composite_error(struct composite_context *ctx, NTSTATUS status);
103 NTSTATUS composite_wait(struct composite_context *c);
104 NTSTATUS composite_wait_free(struct composite_context *c);
107 #endif /* __COMPOSITE_H__ */