add do_async_ndr()/do_async_ndr_domain() similar to
authorStefan Metzmacher <metze@sernet.de>
Thu, 6 Sep 2007 16:09:10 +0000 (18:09 +0200)
committerStefan Metzmacher <metze@sernet.de>
Thu, 11 Oct 2007 15:21:46 +0000 (17:21 +0200)
do_async()/do_async_domain()

metze

source/winbindd/winbindd_async.c

index 00c2052..a5f4c4d 100644 (file)
@@ -111,6 +111,99 @@ void do_async_domain(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
                             &state->response, do_async_recv, state);
 }
 
+struct do_async_ndr_state {
+       TALLOC_CTX *mem_ctx;
+       struct winbindd_ndr_call call;
+       void (*cont)(TALLOC_CTX *mem_ctx, BOOL success,
+                    struct winbindd_ndr_call *call,
+                    void *private_data,
+                    void *caller_cont,
+                    void *caller_private);
+       void *private_data;
+       void *caller_cont;
+       void *caller_private;
+};
+
+static void do_async_ndr_recv(void *private_data, BOOL success)
+{
+       struct do_async_ndr_state *state =
+               talloc_get_type_abort(private_data, struct do_async_ndr_state);
+
+       state->cont(state->mem_ctx, success,
+                   &state->call, state->private_data,
+                   state->caller_cont, state->caller_private);
+}
+
+void do_async_ndr(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
+                 uint32 opnum, void *r,
+                 void (*cont)(TALLOC_CTX *mem_ctx, BOOL success,
+                              struct winbindd_ndr_call *call,
+                              void *private_data,
+                              void *caller_cont,
+                              void *caller_private),
+                 void *private_data,
+                 void *caller_cont,
+                 void *caller_private)
+{
+       struct do_async_ndr_state *state;
+
+       SMB_ASSERT(opnum < ndr_table_winbind_protocol.num_calls);
+
+       state = TALLOC_ZERO_P(mem_ctx, struct do_async_ndr_state);
+       if (state == NULL) {
+               DEBUG(0, ("talloc failed\n"));
+               cont(mem_ctx, False, NULL, private_data,
+                    caller_cont, caller_private);
+               return;
+       }
+
+       state->mem_ctx = mem_ctx;
+       state->call.ndr.call = &ndr_table_winbind_protocol.calls[opnum];
+       state->call.ndr.r = r;
+       state->cont = cont;
+       state->private_data = private_data;
+       state->caller_cont = caller_cont;
+       state->caller_private = caller_private;
+
+       async_ndr_call(mem_ctx, child, &state->call,
+                      do_async_ndr_recv, state);
+}
+
+void do_async_ndr_domain(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
+                        uint32 opnum, void *r,
+                        void (*cont)(TALLOC_CTX *mem_ctx, BOOL success,
+                                     struct winbindd_ndr_call *call,
+                                     void *private_data,
+                                     void *caller_cont,
+                                     void *caller_private),
+                        void *private_data,
+                        void *caller_cont,
+                        void *caller_private)
+{
+       struct do_async_ndr_state *state;
+
+       SMB_ASSERT(opnum < ndr_table_winbind_protocol.num_calls);
+
+       state = TALLOC_ZERO_P(mem_ctx, struct do_async_ndr_state);
+       if (state == NULL) {
+               DEBUG(0, ("talloc failed\n"));
+               cont(mem_ctx, False, NULL, private_data,
+                    caller_cont, caller_private);
+               return;
+       }
+
+       state->mem_ctx = mem_ctx;
+       state->call.ndr.call = &ndr_table_winbind_protocol.calls[opnum];
+       state->call.ndr.r = r;
+       state->cont = cont;
+       state->private_data = private_data;
+       state->caller_cont = caller_cont;
+       state->caller_private = caller_private;
+
+       async_ndr_domain_call(mem_ctx, domain, &state->call,
+                             do_async_ndr_recv, state);
+}
+
 struct lookupsid_state {
        DOM_SID sid;    
        void *caller_private_data;