mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
r3861: - Put ndr and rpc client code in seperate files
- Add some const
(This used to be commit a00bda88e1
)
This commit is contained in:
parent
be01250d1a
commit
a0fa682faa
@ -21,15 +21,11 @@ sub ParseFunction($$)
|
||||
$res .= "
|
||||
struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
|
||||
{
|
||||
|
||||
if (p->flags & DCERPC_DEBUG_PRINT_IN) {
|
||||
NDR_PRINT_IN_DEBUG($name, r);
|
||||
if (p->flags & DCERPC_DEBUG_PRINT_IN) {
|
||||
NDR_PRINT_IN_DEBUG($name, r);
|
||||
}
|
||||
|
||||
return dcerpc_ndr_request_send(p, NULL, DCERPC_$uname, mem_ctx,
|
||||
(ndr_push_flags_fn_t) ndr_push_$name,
|
||||
(ndr_pull_flags_fn_t) ndr_pull_$name,
|
||||
r, sizeof(*r));
|
||||
|
||||
return dcerpc_ndr_request_table_send(p, NULL, &dcerpc_table_$interface->{NAME}, DCERPC_$uname, mem_ctx, r);
|
||||
}
|
||||
|
||||
NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
|
||||
|
@ -195,7 +195,7 @@ sub HeaderTypedefProto($)
|
||||
}
|
||||
|
||||
if (needed::is_needed("ndr_size_$d->{NAME}")) {
|
||||
$res .= "size_t ndr_size_$d->{NAME}(int , struct $d->{NAME} *, int );\n";
|
||||
$res .= "size_t ndr_size_$d->{NAME}(int , const struct $d->{NAME} *, int );\n";
|
||||
}
|
||||
}
|
||||
if ($d->{DATA}{TYPE} eq "UNION") {
|
||||
|
@ -8,8 +8,6 @@
|
||||
package IdlParser;
|
||||
|
||||
use strict;
|
||||
use client;
|
||||
use proxy;
|
||||
use needed;
|
||||
|
||||
# the list of needed functions
|
||||
@ -853,7 +851,7 @@ sub ParseStructNdrSize($)
|
||||
my $static = fn_prefix($t);
|
||||
my $sizevar;
|
||||
|
||||
pidl $static . "size_t ndr_size_$t->{NAME}(int ret, struct $t->{NAME} *r, int flags)\n";
|
||||
pidl $static . "size_t ndr_size_$t->{NAME}(int ret, const struct $t->{NAME} *r, int flags)\n";
|
||||
pidl "{\n";
|
||||
|
||||
if (util::has_property($t->{DATA}, "flag")) {
|
||||
@ -1062,7 +1060,7 @@ sub ParseUnionNdrSize($)
|
||||
my $t = shift;
|
||||
my $static = fn_prefix($t);
|
||||
|
||||
pidl $static . "size_t ndr_size_$t->{NAME}(int ret, union $t->{NAME} *data, uint16 level, int flags)\n";
|
||||
pidl $static . "size_t ndr_size_$t->{NAME}(int ret, const union $t->{NAME} *data, uint16 level, int flags)\n";
|
||||
pidl "{\n";
|
||||
if (util::has_property($t->{DATA}, "flag")) {
|
||||
pidl "\tflags = flags | " . $t->{DATA}->{PROPERTIES}->{flag} . ";\n";
|
||||
@ -1599,13 +1597,6 @@ sub RegistrationFunction($$)
|
||||
pidl "\tif (NT_STATUS_IS_ERR(status)) {\n";
|
||||
pidl "\t\treturn status;\n";
|
||||
pidl "\t}\n\n";
|
||||
|
||||
if (util::has_property($interface, "object")) {
|
||||
pidl "\tstatus = dcom_$interface->{NAME}_init();\n";
|
||||
pidl "\tif (NT_STATUS_IS_ERR(status)) {\n";
|
||||
pidl "\t\treturn status;\n";
|
||||
pidl "\t}\n\n";
|
||||
}
|
||||
}
|
||||
pidl "\treturn status;\n";
|
||||
pidl "}\n\n";
|
||||
@ -1633,12 +1624,6 @@ sub Parse($$)
|
||||
if ($x->{TYPE} eq "INTERFACE") {
|
||||
needed::BuildNeeded($x);
|
||||
ParseInterface($x);
|
||||
|
||||
if (util::has_property($x, "object")) {
|
||||
pidl IdlProxy::ParseInterface($x);
|
||||
} else {
|
||||
pidl IdlClient::ParseInterface($x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ use idl;
|
||||
use dump;
|
||||
use header;
|
||||
use server;
|
||||
use client;
|
||||
use proxy;
|
||||
use stub;
|
||||
use parser;
|
||||
use eparser;
|
||||
@ -31,6 +33,7 @@ my($opt_dump) = 0;
|
||||
my($opt_diff) = 0;
|
||||
my($opt_header) = 0;
|
||||
my($opt_template) = 0;
|
||||
my($opt_client) = 0;
|
||||
my($opt_server) = 0;
|
||||
my($opt_parser) = 0;
|
||||
my($opt_eparser) = 0;
|
||||
@ -68,6 +71,7 @@ sub ShowHelp()
|
||||
--dump dump a pidl file back to idl
|
||||
--header create a C header file
|
||||
--parser create a C parser
|
||||
--client create a C client
|
||||
--server create server boilerplate
|
||||
--template print a template for a pipe
|
||||
--eparser create an ethereal parser
|
||||
@ -88,6 +92,7 @@ GetOptions (
|
||||
'server' => \$opt_server,
|
||||
'template' => \$opt_template,
|
||||
'parser' => \$opt_parser,
|
||||
'client' => \$opt_client,
|
||||
'eparser' => \$opt_eparser,
|
||||
'diff' => \$opt_diff,
|
||||
'keep' => \$opt_keep,
|
||||
@ -138,6 +143,30 @@ sub process_file($)
|
||||
util::FileSave($header, IdlHeader::Parse($pidl));
|
||||
}
|
||||
|
||||
if ($opt_client) {
|
||||
my ($client) = util::ChangeExtension($output, "_c.c");
|
||||
my $res = "";
|
||||
my $h_filename = util::ChangeExtension($output, ".h");
|
||||
my $need_dcom_register = 0;
|
||||
|
||||
$res .= "#include \"includes.h\"\n";
|
||||
$res .= "#include \"$h_filename\"\n\n";
|
||||
|
||||
foreach my $x (@{$pidl}) {
|
||||
if (util::has_property($x, "object")) {
|
||||
$res .= IdlProxy::ParseInterface($x);
|
||||
$need_dcom_register = 1;
|
||||
} else {
|
||||
$res .= IdlClient::ParseInterface($x);
|
||||
}
|
||||
}
|
||||
|
||||
if ($need_dcom_register) {
|
||||
$res .= IdlProxy::RegistrationFunction($pidl, $basename);
|
||||
}
|
||||
util::FileSave($client, $res);
|
||||
}
|
||||
|
||||
if ($opt_server) {
|
||||
my($server) = util::ChangeExtension($output, "_s.c");
|
||||
my $res = "";
|
||||
|
@ -105,10 +105,7 @@ static struct rpc_request *dcom_proxy_$interface->{NAME}_$name\_send(struct dcom
|
||||
NDR_PRINT_IN_DEBUG($name, r);
|
||||
}
|
||||
|
||||
return dcerpc_ndr_request_send(p, &d->ipid, DCERPC_$uname, mem_ctx,
|
||||
(ndr_push_flags_fn_t) ndr_push_$name,
|
||||
(ndr_pull_flags_fn_t) ndr_pull_$name,
|
||||
r, sizeof(*r));
|
||||
return dcerpc_ndr_request_table_send(p, &d->ipid, &dcerpc_table_$interface->{NAME}, DCERPC_$uname, mem_ctx, r);
|
||||
}
|
||||
|
||||
static NTSTATUS dcom_proxy_$interface->{NAME}_$name(struct dcom_interface_p *d, TALLOC_CTX *mem_ctx, struct $name *r)
|
||||
@ -163,4 +160,35 @@ sub ParseInterface($)
|
||||
ParseRegFunc($interface);
|
||||
}
|
||||
|
||||
sub RegistrationFunction($$)
|
||||
{
|
||||
my $idl = shift;
|
||||
my $basename = shift;
|
||||
|
||||
my $res = "NTSTATUS dcom_$basename\_init(void)\n";
|
||||
$res .= "{\n";
|
||||
$res .="\tNTSTATUS status = NT_STATUS_OK;\n";
|
||||
foreach my $interface (@{$idl}) {
|
||||
next if $interface->{TYPE} ne "INTERFACE";
|
||||
next if not util::has_property($interface, "object");
|
||||
|
||||
my $data = $interface->{INHERITED_DATA};
|
||||
my $count = 0;
|
||||
foreach my $d (@{$data}) {
|
||||
if ($d->{TYPE} eq "FUNCTION") { $count++; }
|
||||
}
|
||||
|
||||
next if ($count == 0);
|
||||
|
||||
$res .= "\tstatus = dcom_$interface->{NAME}_init();\n";
|
||||
$res .= "\tif (NT_STATUS_IS_ERR(status)) {\n";
|
||||
$res .= "\t\treturn status;\n";
|
||||
$res .= "\t}\n\n";
|
||||
}
|
||||
$res .= "\treturn status;\n";
|
||||
$res .= "}\n\n";
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -60,6 +60,7 @@ INIT_FUNCTION = \
|
||||
dcerpc_mgmt_init \
|
||||
dcerpc_protected_storage_init \
|
||||
dcerpc_dcom_init \
|
||||
dcom_dcom_init \
|
||||
dcerpc_oxidresolver_init \
|
||||
dcerpc_remact_init \
|
||||
dcerpc_wzcsvc_init \
|
||||
@ -116,7 +117,49 @@ ADD_OBJ_FILES = \
|
||||
librpc/gen_ndr/ndr_keysvc.o \
|
||||
librpc/gen_ndr/ndr_krb5pac.o \
|
||||
librpc/gen_ndr/ndr_xattr.o \
|
||||
librpc/gen_ndr/ndr_schannel.o
|
||||
librpc/gen_ndr/ndr_schannel.o \
|
||||
librpc/gen_ndr/ndr_audiosrv_c.o \
|
||||
librpc/gen_ndr/ndr_dcerpc_c.o \
|
||||
librpc/gen_ndr/ndr_echo_c.o \
|
||||
librpc/gen_ndr/ndr_exchange_c.o \
|
||||
librpc/gen_ndr/ndr_dsbackup_c.o \
|
||||
librpc/gen_ndr/ndr_efs_c.o \
|
||||
librpc/gen_ndr/ndr_misc_c.o \
|
||||
librpc/gen_ndr/ndr_lsa_c.o \
|
||||
librpc/gen_ndr/ndr_lsads_c.o \
|
||||
librpc/gen_ndr/ndr_dfs_c.o \
|
||||
librpc/gen_ndr/ndr_drsuapi_c.o \
|
||||
librpc/gen_ndr/ndr_policyagent_c.o \
|
||||
librpc/gen_ndr/ndr_samr_c.o \
|
||||
librpc/gen_ndr/ndr_spoolss_c.o \
|
||||
librpc/gen_ndr/ndr_wkssvc_c.o \
|
||||
librpc/gen_ndr/ndr_srvsvc_c.o \
|
||||
librpc/gen_ndr/ndr_svcctl_c.o \
|
||||
librpc/gen_ndr/ndr_atsvc_c.o \
|
||||
librpc/gen_ndr/ndr_eventlog_c.o \
|
||||
librpc/gen_ndr/ndr_epmapper_c.o \
|
||||
librpc/gen_ndr/ndr_dbgidl_c.o \
|
||||
librpc/gen_ndr/ndr_dssetup_c.o \
|
||||
librpc/gen_ndr/ndr_msgsvc_c.o \
|
||||
librpc/gen_ndr/ndr_wins_c.o \
|
||||
librpc/gen_ndr/ndr_winreg_c.o \
|
||||
librpc/gen_ndr/ndr_mgmt_c.o \
|
||||
librpc/gen_ndr/ndr_protected_storage_c.o \
|
||||
librpc/gen_ndr/ndr_dcom_c.o \
|
||||
librpc/gen_ndr/ndr_oxidresolver_c.o \
|
||||
librpc/gen_ndr/ndr_remact_c.o \
|
||||
librpc/gen_ndr/ndr_wzcsvc_c.o \
|
||||
librpc/gen_ndr/ndr_browser_c.o \
|
||||
librpc/gen_ndr/ndr_w32time_c.o \
|
||||
librpc/gen_ndr/ndr_scerpc_c.o \
|
||||
librpc/gen_ndr/ndr_ntsvcs_c.o \
|
||||
librpc/gen_ndr/ndr_netlogon_c.o \
|
||||
librpc/gen_ndr/ndr_trkwks_c.o \
|
||||
librpc/gen_ndr/ndr_keysvc_c.o \
|
||||
librpc/gen_ndr/ndr_krb5pac_c.o \
|
||||
librpc/gen_ndr/ndr_xattr_c.o \
|
||||
librpc/gen_ndr/ndr_schannel_c.o
|
||||
|
||||
# End SUBSYSTEM LIBNDR_GEN
|
||||
################################################
|
||||
|
||||
|
@ -1304,7 +1304,7 @@ uint32 ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags)
|
||||
return ret + data->length;
|
||||
}
|
||||
|
||||
uint32 ndr_size_string(int ret, const char **string, int flags)
|
||||
uint32 ndr_size_string(int ret, const char * const* string, int flags)
|
||||
{
|
||||
/* FIXME: Is this correct for all strings ? */
|
||||
if(!(*string)) return ret;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
Copyright (C) Tim Potter 2003
|
||||
Copyright (C) Andrew Tridgell 2003
|
||||
Copyright (C) Jelmer Vernooij 2004
|
||||
|
||||
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
|
||||
@ -856,7 +857,7 @@ static int dcerpc_req_destructor(void *ptr)
|
||||
perform the send size of a async dcerpc request
|
||||
*/
|
||||
struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p,
|
||||
struct GUID *object,
|
||||
const struct GUID *object,
|
||||
uint16_t opnum,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
DATA_BLOB *stub_data)
|
||||
@ -1152,13 +1153,29 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcerpc_pipe *p,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
send a rpc request given a dcerpc_call structure
|
||||
*/
|
||||
struct rpc_request *dcerpc_ndr_request_table_send(struct dcerpc_pipe *p,
|
||||
const struct GUID *object,
|
||||
const struct dcerpc_interface_table *table,
|
||||
uint32_t opnum,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
void *r)
|
||||
{
|
||||
const struct dcerpc_interface_call *call = &table->calls[opnum];
|
||||
|
||||
return dcerpc_ndr_request_send(p, object, opnum, mem_ctx, call->ndr_push, call->ndr_pull, r, call->struct_size);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
send a rpc request with a given set of ndr helper functions
|
||||
|
||||
call dcerpc_ndr_request_recv() to receive the answer
|
||||
*/
|
||||
struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p,
|
||||
struct GUID *object,
|
||||
const struct GUID *object,
|
||||
uint32_t opnum,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
NTSTATUS (*ndr_push)(struct ndr_push *, int, void *),
|
||||
|
@ -4,7 +4,7 @@ FULLBUILD=$1
|
||||
|
||||
[ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
|
||||
|
||||
PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server"
|
||||
PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server --client"
|
||||
EPARSERPIDL="$PERL ./build/pidl/pidl.pl --output $EPARSERPREFIX/ndr_ --parse --header --eparser"
|
||||
|
||||
if [ x$FULLBUILD = xFULL ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user