use Parse::Pidl qw(warning error fatal);
use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
use Parse::Pidl::Util qw(ParseExpr has_property is_constant);
-use Parse::Pidl::NDR qw(GetNextLevel);
+use Parse::Pidl::NDR qw(GetNextLevel ContainsPipe);
use Parse::Pidl::Samba4 qw(ElementStars DeclLong);
use Parse::Pidl::Samba4::Header qw(GenerateFunctionOutEnv);
pidl "ZERO_STRUCT(r->out);" if ($hasout);
- my $proto = "_$fn->{NAME}(pipes_struct *p, struct $fn->{NAME} *r";
+ my $proto = "_$fn->{NAME}(struct pipes_struct *p, struct $fn->{NAME} *r";
my $ret = "_$fn->{NAME}($pipes_struct, r";
foreach (@{$fn->{ELEMENTS}}) {
my @dir = @{$_->{DIRECTION}};
}
foreach (@{$fn->{ELEMENTS}}) {
+ next if ContainsPipe($_, $_->{LEVELS}[0]);
my @dir = @{$_->{DIRECTION}};
if (grep(/in/, @dir) and grep(/out/, @dir)) {
# noop
if ($fn->{RETURN_TYPE}) {
$ret = "r->out.result = $ret";
- $proto = "$fn->{RETURN_TYPE} $proto";
+ $proto = mapTypeName($fn->{RETURN_TYPE})." $proto";
} else {
$proto = "void $proto";
}
my $op = "NDR_".uc($fn->{NAME});
- pidl "static bool api_$fn->{NAME}(pipes_struct *p)";
+ pidl "static bool api_$fn->{NAME}(struct pipes_struct *p)";
pidl "{";
indent;
pidl "const struct ndr_interface_call *call;";
pidl "struct ndr_pull *pull;";
pidl "struct ndr_push *push;";
pidl "enum ndr_err_code ndr_err;";
- pidl "DATA_BLOB blob;";
pidl "struct $fn->{NAME} *r;";
pidl "";
pidl "call = &ndr_table_$if->{NAME}.calls[$op];";
pidl "\treturn false;";
pidl "}";
pidl "";
- pidl "if (!prs_data_blob(&p->in_data.data, &blob, r)) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "pull = ndr_pull_init_blob(&blob, r);";
+ pidl "pull = ndr_pull_init_blob(&p->in_data.data, r);";
pidl "if (pull == NULL) {";
pidl "\ttalloc_free(r);";
pidl "\treturn false;";
pidl "}";
pidl "";
pidl "if (DEBUGLEVEL >= 10) {";
- pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, r);";
+ pidl "\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_IN, r);";
pidl "}";
pidl "";
);
pidl "";
- pidl "if (p->rng_fault_state) {";
+ pidl "if (p->fault_state) {";
pidl "\ttalloc_free(r);";
pidl "\t/* Return true here, srv_pipe_hnd.c will take care */";
pidl "\treturn true;";
pidl "}";
pidl "";
pidl "if (DEBUGLEVEL >= 10) {";
- pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);";
+ pidl "\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_OUT | NDR_SET_VALUES, r);";
pidl "}";
pidl "";
pidl "push = ndr_push_init_ctx(r);";
pidl "\treturn false;";
pidl "}";
pidl "";
+ pidl "/*";
+ pidl " * carry over the pointer count to the reply in case we are";
+ pidl " * using full pointer. See NDR specification for full pointers";
+ pidl " */";
+ pidl "push->ptr_count = pull->ptr_count;";
+ pidl "";
pidl "ndr_err = call->ndr_push(push, NDR_OUT, r);";
pidl "if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {";
pidl "\ttalloc_free(r);";
pidl "\treturn false;";
pidl "}";
pidl "";
- pidl "blob = ndr_push_blob(push);";
- pidl "if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
+ pidl "p->out_data.rdata = ndr_push_blob(push);";
+ pidl "talloc_steal(p->mem_ctx, p->out_data.rdata.data);";
pidl "";
pidl "talloc_free(r);";
pidl "";
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 "/* set opnum in fake rpc header */";
- pidl "cli->pipes_struct->hdr_req.opnum = opnum;";
- 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;";
-
- pidl "if (DEBUGLEVEL >= 10) {";
- pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, r);";
- pidl "}";
-
- CallWithStruct("cli->pipes_struct", "mem_ctx", $fn,
- sub { pidl "\treturn NT_STATUS_NO_MEMORY;"; });
-
- pidl "if (DEBUGLEVEL >= 10) {";
- pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);";
- pidl "}";
-
- 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;
pidl "}";
pidl "";
- ParseDispatchFunction($if);
-
if (not has_property($if, "no_srv_register")) {
- pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(void);";
- pidl "NTSTATUS rpc_$if->{NAME}_init(void)";
+ pidl_hdr "struct rpc_srv_callbacks;";
+ pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(const struct rpc_srv_callbacks *rpc_srv_cb);";
+ pidl "NTSTATUS rpc_$if->{NAME}_init(const struct rpc_srv_callbacks *rpc_srv_cb)";
+ 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), rpc_srv_cb);";
+ pidl "}";
+
+ pidl "";
+
+ pidl_hdr "NTSTATUS rpc_$if->{NAME}_shutdown(void);";
+ pidl "NTSTATUS rpc_$if->{NAME}_shutdown(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 "\treturn rpc_srv_unregister(\&ndr_table_$if->{NAME});";
pidl "}";
}
pidl_hdr "#endif /* __SRV_$uif\__ */";
pidl " */";
pidl "";
pidl "#include \"includes.h\"";
+ pidl "#include \"ntdomain.h\"";
pidl "#include \"$header\"";
pidl_hdr "#include \"$ndr_header\"";
pidl "";