The branch, master has been updated
       via  b342090... s4:librpc/rpc: make struct dcerpc_binding_handle private
       via  51fb4c3... pidl:Samba4/NDR/Client: add sync dcerpc_pipe based stubs 
as compat for OpenChange
       via  719981a... pidl:Samba4/NDR/Client: add non struct base 
dcerpc_binding_handle client stubs
       via  62297df... pidl:Samba4/NDR/Client: convert code to $self->pidl()
       via  570eefc... pidl:Samba4/NDR/Client: s/interface/if/
       via  76691e9... pidl:Samba4/NDR/Client: make use of the new 
dcerpc_binding_handle_call() infrastructure
       via  db89fda... pidl:Samba4/NDR/Client: remove old dcerpc_pipe based 
sync stubs
       via  7eef08c... s4:librpc/rpc: add dcerpc_binding_handle dcerpc_pipe 
backend
       via  4030bc9... librpc/rpc: add dcerpc_binding_handle abstration
      from  2828318... s4:librpc/rpc: fix dcerpc_log_packet() prototype

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b34209006fd75533b22e77c77d8fde3e4cb1506a
Author: Stefan Metzmacher <[email protected]>
Date:   Sat Aug 7 14:48:57 2010 +0200

    s4:librpc/rpc: make struct dcerpc_binding_handle private
    
    metze

commit 51fb4c386040c9fdc44f4473025c9d83e628b5e6
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Aug 10 13:27:12 2010 +0200

    pidl:Samba4/NDR/Client: add sync dcerpc_pipe based stubs as compat for 
OpenChange
    
    This will activate the compat wrappers for all functions of an interface:
     #define DCERPC_IFACE_MYPROTO_COMPAT 1
     #include <ndr_myproto_c.h>
    
    This will activates the compat wrappers just for specific functions:
     #define DCERPC_CALL_MYFN1_COMPAT 1
     #define DCERPC_CALL_MYFN2_COMPAT 1
     #include <ndr_myproto_c.h>
    
    metze

commit 719981adfdd6d828ec0a78ca2be2776502751674
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 5 16:10:52 2010 +0200

    pidl:Samba4/NDR/Client: add non struct base dcerpc_binding_handle client 
stubs
    
    metze

commit 62297dff8f64de8ffa3fe4d2a7cd99d45173561d
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 5 13:29:56 2010 +0200

    pidl:Samba4/NDR/Client: convert code to $self->pidl()
    
    metze

commit 570eefc57a051166d99445a830b8d7e5ffbd86f7
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 5 12:59:46 2010 +0200

    pidl:Samba4/NDR/Client: s/interface/if/
    
    metze

commit 76691e9eaf9520429c7ea0ef6b2955c143b068e5
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 5 18:22:02 2010 +0200

    pidl:Samba4/NDR/Client: make use of the new dcerpc_binding_handle_call() 
infrastructure
    
    metze

commit db89fdac7329d02bf08f705443b62369bb23081e
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Mar 10 17:56:10 2010 +0100

    pidl:Samba4/NDR/Client: remove old dcerpc_pipe based sync stubs
    
    They're unused in Samba and only used by OpenChange.
    I'll add a compat functions for OpenChange later.
    
    metze

commit 7eef08cc63ed231b54dd2a5936579ffc60a0c087
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 5 18:18:30 2010 +0200

    s4:librpc/rpc: add dcerpc_binding_handle dcerpc_pipe backend
    
    metze

commit 4030bc9b2df3f2a1c18b373a94c53e48ba80cfc1
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 5 18:14:04 2010 +0200

    librpc/rpc: add dcerpc_binding_handle abstration
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 librpc/rpc/binding_handle.c              |  479 ++++++++++++++++
 pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm |  919 ++++++++++++++++++++++--------
 pidl/pidl                                |    3 +-
 source4/librpc/rpc/dcerpc.c              |  411 +++++++++++++-
 source4/librpc/rpc/dcerpc.h              |  112 ++++-
 source4/librpc/rpc/dcerpc_util.c         |    3 +-
 source4/librpc/wscript_build             |    6 +-
 7 files changed, 1675 insertions(+), 258 deletions(-)
 create mode 100644 librpc/rpc/binding_handle.c


Changeset truncated at 500 lines:

diff --git a/librpc/rpc/binding_handle.c b/librpc/rpc/binding_handle.c
new file mode 100644
index 0000000..153d7d1
--- /dev/null
+++ b/librpc/rpc/binding_handle.c
@@ -0,0 +1,479 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   dcerpc binding handle functions
+
+   Copyright (C) Stefan Metzmacher 2010
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include <tevent.h>
+#include "../lib/util/tevent_ntstatus.h"
+#include "librpc/rpc/dcerpc.h"
+
+struct dcerpc_binding_handle {
+       void *private_data;
+       const struct dcerpc_binding_handle_ops *ops;
+       const char *location;
+       const struct GUID *object;
+       const struct ndr_interface_table *table;
+       struct tevent_context *sync_ev;
+};
+
+static int dcerpc_binding_handle_destructor(struct dcerpc_binding_handle *b)
+{
+       return 0;
+}
+
+struct dcerpc_binding_handle *_dcerpc_binding_handle_create(TALLOC_CTX 
*mem_ctx,
+                                       const struct dcerpc_binding_handle_ops 
*ops,
+                                       const struct GUID *object,
+                                       const struct ndr_interface_table *table,
+                                       void *pstate,
+                                       size_t psize,
+                                       const char *type,
+                                       const char *location)
+{
+       struct dcerpc_binding_handle *h;
+       void **ppstate = (void **)pstate;
+       void *state;
+
+       h = talloc_zero(mem_ctx, struct dcerpc_binding_handle);
+       if (h == NULL) {
+               return NULL;
+       }
+       h->ops          = ops;
+       h->location     = location;
+       h->object       = object;
+       h->table        = table;
+
+       state = talloc_zero_size(h, psize);
+       if (state == NULL) {
+               talloc_free(h);
+               return NULL;
+       }
+       talloc_set_name_const(state, type);
+
+       h->private_data = state;
+
+       talloc_set_destructor(h, dcerpc_binding_handle_destructor);
+
+       *ppstate = state;
+       return h;
+}
+
+void *_dcerpc_binding_handle_data(struct dcerpc_binding_handle *h)
+{
+       return h->private_data;
+}
+
+void dcerpc_binding_handle_set_sync_ev(struct dcerpc_binding_handle *h,
+                                      struct tevent_context *ev)
+{
+       h->sync_ev = ev;
+}
+
+bool dcerpc_binding_handle_is_connected(struct dcerpc_binding_handle *h)
+{
+       return h->ops->is_connected(h);
+}
+
+struct dcerpc_binding_handle_raw_call_state {
+       const struct dcerpc_binding_handle_ops *ops;
+       uint8_t *out_data;
+       size_t out_length;
+       uint32_t out_flags;
+};
+
+static void dcerpc_binding_handle_raw_call_done(struct tevent_req *subreq);
+
+struct tevent_req *dcerpc_binding_handle_raw_call_send(TALLOC_CTX *mem_ctx,
+                                               struct tevent_context *ev,
+                                               struct dcerpc_binding_handle *h,
+                                               const struct GUID *object,
+                                               uint32_t opnum,
+                                               uint32_t in_flags,
+                                               const uint8_t *in_data,
+                                               size_t in_length)
+{
+       struct tevent_req *req;
+       struct dcerpc_binding_handle_raw_call_state *state;
+       struct tevent_req *subreq;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct dcerpc_binding_handle_raw_call_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->ops = h->ops;
+       state->out_data = NULL;
+       state->out_length = 0;
+       state->out_flags = 0;
+
+       subreq = state->ops->raw_call_send(state, ev, h,
+                                          object, opnum,
+                                          in_flags, in_data, in_length);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, dcerpc_binding_handle_raw_call_done, 
req);
+
+       return req;
+}
+
+static void dcerpc_binding_handle_raw_call_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(subreq,
+                                struct tevent_req);
+       struct dcerpc_binding_handle_raw_call_state *state =
+               tevent_req_data(req,
+               struct dcerpc_binding_handle_raw_call_state);
+       NTSTATUS error;
+
+       error = state->ops->raw_call_recv(subreq, state,
+                                         &state->out_data,
+                                         &state->out_length,
+                                         &state->out_flags);
+       TALLOC_FREE(subreq);
+       if (!NT_STATUS_IS_OK(error)) {
+               tevent_req_nterror(req, error);
+               return;
+       }
+
+       tevent_req_done(req);
+}
+
+NTSTATUS dcerpc_binding_handle_raw_call_recv(struct tevent_req *req,
+                                            TALLOC_CTX *mem_ctx,
+                                            uint8_t **out_data,
+                                            size_t *out_length,
+                                            uint32_t *out_flags)
+{
+       struct dcerpc_binding_handle_raw_call_state *state =
+               tevent_req_data(req,
+               struct dcerpc_binding_handle_raw_call_state);
+       NTSTATUS error;
+
+       if (tevent_req_is_nterror(req, &error)) {
+               tevent_req_received(req);
+               return error;
+       }
+
+       *out_data = talloc_move(mem_ctx, &state->out_data);
+       *out_length = state->out_length;
+       *out_flags = state->out_flags;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
+struct dcerpc_binding_handle_disconnect_state {
+       const struct dcerpc_binding_handle_ops *ops;
+};
+
+static void dcerpc_binding_handle_disconnect_done(struct tevent_req *subreq);
+
+struct tevent_req *dcerpc_binding_handle_disconnect_send(TALLOC_CTX *mem_ctx,
+                                               struct tevent_context *ev,
+                                               struct dcerpc_binding_handle *h)
+{
+       struct tevent_req *req;
+       struct dcerpc_binding_handle_disconnect_state *state;
+       struct tevent_req *subreq;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct dcerpc_binding_handle_disconnect_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       state->ops = h->ops;
+
+       subreq = state->ops->disconnect_send(state, ev, h);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, dcerpc_binding_handle_disconnect_done, 
req);
+
+       return req;
+}
+
+static void dcerpc_binding_handle_disconnect_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(subreq,
+                                struct tevent_req);
+       struct dcerpc_binding_handle_disconnect_state *state =
+               tevent_req_data(req,
+               struct dcerpc_binding_handle_disconnect_state);
+       NTSTATUS error;
+
+       error = state->ops->disconnect_recv(subreq);
+       TALLOC_FREE(subreq);
+       if (!NT_STATUS_IS_OK(error)) {
+               tevent_req_nterror(req, error);
+               return;
+       }
+
+       tevent_req_done(req);
+}
+
+NTSTATUS dcerpc_binding_handle_disconnect_recv(struct tevent_req *req)
+{
+       NTSTATUS error;
+
+       if (tevent_req_is_nterror(req, &error)) {
+               tevent_req_received(req);
+               return error;
+       }
+
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
+struct dcerpc_binding_handle_call_state {
+       struct dcerpc_binding_handle *h;
+       const struct ndr_interface_call *call;
+       TALLOC_CTX *r_mem;
+       void *r_ptr;
+       struct ndr_push *push;
+       DATA_BLOB request;
+       DATA_BLOB response;
+       struct ndr_pull *pull;
+};
+
+static void dcerpc_binding_handle_call_done(struct tevent_req *subreq);
+
+struct tevent_req *dcerpc_binding_handle_call_send(TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       struct dcerpc_binding_handle *h,
+                                       const struct GUID *object,
+                                       const struct ndr_interface_table *table,
+                                       uint32_t opnum,
+                                       TALLOC_CTX *r_mem,
+                                       void *r_ptr)
+{
+       struct tevent_req *req;
+       struct dcerpc_binding_handle_call_state *state;
+       struct tevent_req *subreq;
+       enum ndr_err_code ndr_err;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct dcerpc_binding_handle_call_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+#if 0 /* TODO: activate this when the callers are fixed */
+       if (table != h->table) {
+               tevent_req_nterror(req, NT_STATUS_INVALID_HANDLE);
+               return tevent_req_post(req, ev);
+       }
+#endif
+
+       if (opnum >= table->num_calls) {
+               tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+               return tevent_req_post(req, ev);
+       }
+
+       state->h = h;
+       state->call = &table->calls[opnum];
+
+       state->r_mem = r_mem;
+       state->r_ptr = r_ptr;
+
+       /* setup for a ndr_push_* call */
+       state->push = ndr_push_init_ctx(state);
+       if (tevent_req_nomem(state->push, req)) {
+               return tevent_req_post(req, ev);
+       }
+
+       if (h->ops->ref_alloc && h->ops->ref_alloc(h)) {
+               state->push->flags |= LIBNDR_FLAG_REF_ALLOC;
+       }
+
+       if (h->ops->push_bigendian && h->ops->push_bigendian(h)) {
+               state->push->flags |= LIBNDR_FLAG_BIGENDIAN;
+       }
+
+       if (h->ops->use_ndr64 && h->ops->use_ndr64(h)) {
+               state->push->flags |= LIBNDR_FLAG_NDR64;
+       }
+
+       /* push the structure into a blob */
+       ndr_err = state->call->ndr_push(state->push, NDR_IN, state->r_ptr);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               NTSTATUS error;
+               error = ndr_map_error2ntstatus(ndr_err);
+               if (h->ops->ndr_push_failed) {
+                       h->ops->ndr_push_failed(h, error,
+                                               state->r_ptr,
+                                               state->call);
+               }
+               tevent_req_nterror(req, error);
+               return tevent_req_post(req, ev);
+       }
+
+       /* retrieve the blob */
+       state->request = ndr_push_blob(state->push);
+
+       if (h->ops->ndr_validate_in) {
+               NTSTATUS error;
+               error = h->ops->ndr_validate_in(h, state,
+                                               &state->request,
+                                               state->call);
+               if (!NT_STATUS_IS_OK(error)) {
+                       tevent_req_nterror(req, error);
+                       return tevent_req_post(req, ev);
+               }
+       }
+
+       subreq = dcerpc_binding_handle_raw_call_send(state, ev,
+                                                    h, object, opnum,
+                                                    state->push->flags,
+                                                    state->request.data,
+                                                    state->request.length);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, dcerpc_binding_handle_call_done, req);
+
+       return req;
+}
+
+static void dcerpc_binding_handle_call_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(subreq,
+                                struct tevent_req);
+       struct dcerpc_binding_handle_call_state *state =
+               tevent_req_data(req,
+               struct dcerpc_binding_handle_call_state);
+       struct dcerpc_binding_handle *h = state->h;
+       NTSTATUS error;
+       uint32_t out_flags = 0;
+       enum ndr_err_code ndr_err;
+
+       error = dcerpc_binding_handle_raw_call_recv(subreq, state,
+                                                   &state->response.data,
+                                                   &state->response.length,
+                                                   &out_flags);
+       TALLOC_FREE(subreq);
+       if (!NT_STATUS_IS_OK(error)) {
+               tevent_req_nterror(req, error);
+               return;
+       }
+
+       state->pull = ndr_pull_init_blob(&state->response, state);
+       if (tevent_req_nomem(state->pull, req)) {
+               return;
+       }
+       state->pull->flags = state->push->flags;
+
+       if (out_flags & LIBNDR_FLAG_BIGENDIAN) {
+               state->pull->flags |= LIBNDR_FLAG_BIGENDIAN;
+       } else {
+               state->pull->flags &= ~LIBNDR_FLAG_BIGENDIAN;
+       }
+
+       state->pull->current_mem_ctx = state->r_mem;
+
+       /* pull the structure from the blob */
+       ndr_err = state->call->ndr_pull(state->pull, NDR_OUT, state->r_ptr);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               error = ndr_map_error2ntstatus(ndr_err);
+               if (h->ops->ndr_pull_failed) {
+                       h->ops->ndr_pull_failed(h, error,
+                                               &state->response,
+                                               state->call);
+               }
+               tevent_req_nterror(req, error);
+               return;
+       }
+
+       if (h->ops->ndr_validate_out) {
+               error = h->ops->ndr_validate_out(h,
+                                                state->pull,
+                                                state->r_ptr,
+                                                state->call);
+               if (!NT_STATUS_IS_OK(error)) {
+                       tevent_req_nterror(req, error);
+                       return;
+               }
+       }
+
+       tevent_req_done(req);
+}
+
+NTSTATUS dcerpc_binding_handle_call_recv(struct tevent_req *req)
+{
+       NTSTATUS error;
+
+       if (tevent_req_is_nterror(req, &error)) {
+               tevent_req_received(req);
+               return error;
+       }
+
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
+NTSTATUS dcerpc_binding_handle_call(struct dcerpc_binding_handle *h,
+                                   const struct GUID *object,
+                                   const struct ndr_interface_table *table,
+                                   uint32_t opnum,
+                                   TALLOC_CTX *r_mem,
+                                   void *r_ptr)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct tevent_context *ev;
+       struct tevent_req *subreq;
+       NTSTATUS status;
+
+       /*
+        * TODO: allow only one sync call
+        */
+
+       if (h->sync_ev) {
+               ev = h->sync_ev;
+       } else {
+               ev = tevent_context_init(frame);
+       }
+       if (ev == NULL) {
+               talloc_free(frame);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       subreq = dcerpc_binding_handle_call_send(frame, ev,
+                                                h, object, table,
+                                                opnum, r_mem, r_ptr);
+       if (subreq == NULL) {
+               talloc_free(frame);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       if (!tevent_req_poll(subreq, ev)) {
+               status = map_nt_error_from_unix(errno);
+               talloc_free(frame);
+               return status;
+       }
+
+       status = dcerpc_binding_handle_call_recv(subreq);
+       if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(frame);
+               return status;
+       }
+
+       TALLOC_FREE(frame);
+       return NT_STATUS_OK;
+}
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm 
b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index 81f8477..299dfae 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -6,390 +6,815 @@
 
 package Parse::Pidl::Samba4::NDR::Client;
 
-use Parse::Pidl::Samba4 qw(choose_header is_intree);
-use Parse::Pidl::Util qw(has_property);
+use Exporter;
+...@isa = qw(Exporter);
+...@export_ok = qw(Parse);
+
+use Parse::Pidl qw(fatal warning error);


-- 
Samba Shared Repository

Reply via email to