s3-rpc: when using rpc_pipe_open_internal, make sure to go through NDR.
[kamenim/samba.git] / pidl / lib / Parse / Pidl / Samba3 / ServerNDR.pm
index 7c9091ea94ef6ff6b805ffaa2d165df74eb966ed..a25d12bfea4ea627a2e5b96028c7cfa436773c44 100644 (file)
@@ -160,13 +160,16 @@ sub ParseFunction($$)
        pidl "\treturn false;";
        pidl "}";
        pidl "";
-       pidl "pull = ndr_pull_init_blob(&blob, r, NULL);";
+       pidl "pull = ndr_pull_init_blob(&blob, r);";
        pidl "if (pull == NULL) {";
        pidl "\ttalloc_free(r);";
        pidl "\treturn false;";
        pidl "}";
        pidl "";
        pidl "pull->flags |= LIBNDR_FLAG_REF_ALLOC;";
+       pidl "if (p->endian) {";
+       pidl "\tpull->flags |= LIBNDR_FLAG_BIGENDIAN;";
+       pidl "}";
        pidl "ndr_err = call->ndr_pull(pull, NDR_IN, r);";
        pidl "if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {";
        pidl "\ttalloc_free(r);";
@@ -196,7 +199,7 @@ sub ParseFunction($$)
        pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);";
        pidl "}";
        pidl "";
-       pidl "push = ndr_push_init_ctx(r, NULL);";
+       pidl "push = ndr_push_init_ctx(r);";
        pidl "if (push == NULL) {";
        pidl "\ttalloc_free(r);";
        pidl "\treturn false;";
@@ -222,45 +225,6 @@ sub ParseFunction($$)
        pidl "";
 }
 
-sub ParseDispatchFunction($)
-{
-       my ($if) = @_;
-
-       pidl_hdr "NTSTATUS rpc_$if->{NAME}_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r);";
-       pidl "NTSTATUS rpc_$if->{NAME}_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *_r)";
-       pidl "{";
-       indent;
-       pidl "if (cli->pipes_struct == NULL) {";
-       pidl "\treturn NT_STATUS_INVALID_PARAMETER;";
-       pidl "}";
-       pidl "";
-       pidl "switch (opnum)";
-       pidl "{";
-       indent;
-       foreach my $fn (@{$if->{FUNCTIONS}}) {
-               next if ($fn->{PROPERTIES}{noopnum});
-               my $op = "NDR_".uc($fn->{NAME});
-               pidl "case $op: {";
-               indent;
-               pidl "struct $fn->{NAME} *r = (struct $fn->{NAME} *)_r;";
-               CallWithStruct("cli->pipes_struct", "mem_ctx", $fn, 
-                       sub { pidl "\treturn NT_STATUS_NO_MEMORY;"; });
-               pidl "return NT_STATUS_OK;";
-               deindent;
-               pidl "}";
-               pidl "";
-       }
-
-       pidl "default:";
-       pidl "\treturn NT_STATUS_NOT_IMPLEMENTED;";
-       deindent;
-       pidl "}";
-       deindent;
-       pidl "}";
-
-       pidl "";
-}
-
 sub ParseInterface($)
 {
        my $if = shift;
@@ -301,14 +265,13 @@ sub ParseInterface($)
        pidl "}";
        pidl "";
 
-       ParseDispatchFunction($if);
-
-       pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(void);";
-       pidl "NTSTATUS rpc_$if->{NAME}_init(void)";
-       pidl "{";
-       pidl "\treturn rpc_srv_register(SMB_RPC_INTERFACE_VERSION, \"$if->{NAME}\", \"$if->{NAME}\", \&ndr_table_$if->{NAME}, api_$if->{NAME}_cmds, sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct));";
-       pidl "}";
-
+       if (not has_property($if, "no_srv_register")) {
+           pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(void);";
+           pidl "NTSTATUS rpc_$if->{NAME}_init(void)";
+           pidl "{";
+           pidl "\treturn rpc_srv_register(SMB_RPC_INTERFACE_VERSION, \"$if->{NAME}\", \"$if->{NAME}\", \&ndr_table_$if->{NAME}, api_$if->{NAME}_cmds, sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct));";
+           pidl "}";
+       }
        pidl_hdr "#endif /* __SRV_$uif\__ */";
 }