diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-28 03:47:45 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-28 03:47:45 +0000 |
commit | 07fdc2c73e03dad5b6030db0e8e488a3834796f5 (patch) | |
tree | 572ab828b52cfa9cf6887acd5049c41f279ece2c | |
parent | df5949efb425668f8e7ae38c0c858bd90529255a (diff) | |
download | samba-07fdc2c73e03dad5b6030db0e8e488a3834796f5.tar.gz samba-07fdc2c73e03dad5b6030db0e8e488a3834796f5.tar.bz2 samba-07fdc2c73e03dad5b6030db0e8e488a3834796f5.zip |
* support multiple interfaces in one IDL file in pidl
* make far more generated functions static
* get rid of gen_rpc, and include the client calls in ndr_*.c
* added placeholder IDL for a number of intefaces (dcom, wzcsvc, browser etc)
(This used to be commit a2bdf0be0119023df3c2b9ea515ed355020f2625)
-rw-r--r-- | source4/Makefile.in | 12 | ||||
-rw-r--r-- | source4/build/pidl/client.pm | 1 | ||||
-rw-r--r-- | source4/build/pidl/idl.gram | 13 | ||||
-rw-r--r-- | source4/build/pidl/parser.pm | 40 | ||||
-rwxr-xr-x | source4/build/pidl/pidl.pl | 12 | ||||
-rw-r--r-- | source4/librpc/idl/atsvc.idl | 2 | ||||
-rw-r--r-- | source4/librpc/idl/dcerpc.idl | 2 | ||||
-rwxr-xr-x | source4/script/build_idl.sh | 6 | ||||
-rw-r--r-- | source4/torture/rpc/scanner.c | 33 |
9 files changed, 63 insertions, 58 deletions
diff --git a/source4/Makefile.in b/source4/Makefile.in index d9124e80c3..a1f9fb158f 100644 --- a/source4/Makefile.in +++ b/source4/Makefile.in @@ -197,17 +197,13 @@ LIBRAW_NDR_OBJ = librpc/ndr/ndr.o librpc/ndr/ndr_basic.o librpc/ndr/ndr_sec.o \ librpc/gen_ndr/ndr_wkssvc.o librpc/gen_ndr/ndr_srvsvc.o \ librpc/gen_ndr/ndr_atsvc.o librpc/gen_ndr/ndr_eventlog.o \ librpc/gen_ndr/ndr_epmapper.o librpc/gen_ndr/ndr_winreg.o \ - librpc/gen_ndr/ndr_mgmt.o + librpc/gen_ndr/ndr_mgmt.o librpc/gen_ndr/ndr_protected_storage.o \ + librpc/gen_ndr/ndr_dcom.o librpc/gen_ndr/ndr_wzcsvc.o \ + librpc/gen_ndr/ndr_browser.o LIBRAW_RPC_OBJ = librpc/rpc/dcerpc.o librpc/rpc/dcerpc_auth.o \ librpc/rpc/dcerpc_util.o \ - librpc/rpc/dcerpc_smb.o librpc/rpc/dcerpc_tcp.o \ - librpc/gen_rpc/rpc_echo.o librpc/gen_rpc/rpc_lsa.o \ - librpc/gen_rpc/rpc_dfs.o librpc/gen_rpc/rpc_spoolss.o \ - librpc/gen_rpc/rpc_samr.o librpc/gen_rpc/rpc_wkssvc.o \ - librpc/gen_rpc/rpc_srvsvc.o librpc/gen_rpc/rpc_atsvc.o \ - librpc/gen_rpc/rpc_eventlog.o librpc/gen_rpc/rpc_epmapper.o \ - librpc/gen_rpc/rpc_winreg.o librpc/gen_rpc/rpc_mgmt.o + librpc/rpc/dcerpc_smb.o librpc/rpc/dcerpc_tcp.o LIBRAW_OBJ = libcli/raw/rawfile.o libcli/raw/smb_signing.o \ libcli/raw/clisocket.o libcli/raw/clitransport.o \ diff --git a/source4/build/pidl/client.pm b/source4/build/pidl/client.pm index b0c78d7b3a..495fe3dd7c 100644 --- a/source4/build/pidl/client.pm +++ b/source4/build/pidl/client.pm @@ -67,7 +67,6 @@ sub Parse($) { my($idl) = shift; $res = "/* dcerpc client calls generated by pidl */\n\n"; - $res .= "#include \"includes.h\"\n\n"; foreach my $x (@{$idl}) { ($x->{TYPE} eq "INTERFACE") && ParseInterface($x); diff --git a/source4/build/pidl/idl.gram b/source4/build/pidl/idl.gram index 897a5ad769..b354b9772a 100644 --- a/source4/build/pidl/idl.gram +++ b/source4/build/pidl/idl.gram @@ -2,7 +2,11 @@ use util; } -idl: cpp_prefix(s?) module_header interface +idl: idl_interface(s?) + {{ util::FlattenArray($item[1]) }} + | <error> + +idl_interface: module_header interface { [$item{module_header}, $item{interface}] } | <error> @@ -25,8 +29,7 @@ interface: 'interface' <commit> identifier '{' definition(s?) '}' }} | <error?> -definition : cpp_prefix - | typedef { $item[1] } +definition : typedef { $item[1] } | function { $item[1] } | const { $item[1] } @@ -148,11 +151,12 @@ identifier: /[\w?]+/ expression: /[\w.?\/+*-_]+/ -function : type identifier '(' <commit> element_list2 ');' +function : property_list(s?) type identifier '(' <commit> element_list2 ');' {{ "TYPE" => "FUNCTION", "NAME" => $item{identifier}, "RETURN_TYPE" => $item{type}, + "PROPERTIES" => util::FlattenArray($item[1]), "DATA" => $item{element_list2} }} | <error?> @@ -177,4 +181,3 @@ anytext: text2 '(' <commit> anytext ')' anytext constant: /-?[\dx]+/ | '*' -cpp_prefix: '#' /.*/ diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index 5c80812ec1..a10058a160 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -8,6 +8,7 @@ package IdlParser; use strict; use Data::Dumper; +use client; # the list of needed functions my %needed; @@ -15,7 +16,7 @@ my %structs; sub pidl($) { - print IDL shift; + print OUT shift; } ##################################################################### @@ -111,11 +112,19 @@ sub find_size_var($$$) # work out is a parse function should be declared static or not sub fn_prefix($) { - my $e = shift; - if (util::has_property($e, "public")) { - return "static "; + my $fn = shift; + if ($fn->{TYPE} eq "TYPEDEF") { + if (util::has_property($fn->{DATA}, "public")) { + return ""; + } } - return ""; + + if ($fn->{TYPE} eq "FUNCTION") { + if (util::has_property($fn, "public")) { + return ""; + } + } + return "static "; } @@ -997,7 +1006,7 @@ sub ParseTypedefPush($) } if ($e->{DATA}->{TYPE} eq "STRUCT") { - pidl "$static" . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, struct $e->{NAME} *r)"; + pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, struct $e->{NAME} *r)"; pidl "\n{\n"; ParseTypePush($e->{DATA}); pidl "\treturn NT_STATUS_OK;\n"; @@ -1005,7 +1014,7 @@ sub ParseTypedefPush($) } if ($e->{DATA}->{TYPE} eq "UNION") { - pidl "$static" . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)"; + pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)"; pidl "\n{\n"; ParseTypePush($e->{DATA}); pidl "\treturn NT_STATUS_OK;\n"; @@ -1027,7 +1036,7 @@ sub ParseTypedefPull($) } if ($e->{DATA}->{TYPE} eq "STRUCT") { - pidl "$static" . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, struct $e->{NAME} *r)"; + pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, struct $e->{NAME} *r)"; pidl "\n{\n"; ParseTypePull($e->{DATA}); pidl "\treturn NT_STATUS_OK;\n"; @@ -1035,7 +1044,7 @@ sub ParseTypedefPull($) } if ($e->{DATA}->{TYPE} eq "UNION") { - pidl "$static" . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)"; + pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)"; pidl "\n{\n"; ParseTypePull($e->{DATA}); pidl "\treturn NT_STATUS_OK;\n"; @@ -1139,8 +1148,9 @@ sub ParseFunctionElementPush($$) sub ParseFunctionPush($) { my($fn) = shift; + my $static = fn_prefix($fn); - pidl "NTSTATUS ndr_push_$fn->{NAME}(struct ndr_push *ndr, int flags, struct $fn->{NAME} *r)\n{\n"; + pidl $static . "NTSTATUS ndr_push_$fn->{NAME}(struct ndr_push *ndr, int flags, struct $fn->{NAME} *r)\n{\n"; pidl "\n\tif (!(flags & NDR_IN)) goto ndr_out;\n\n"; foreach my $e (@{$fn->{DATA}}) { @@ -1205,9 +1215,10 @@ sub ParseFunctionElementPull($$) sub ParseFunctionPull($) { my($fn) = shift; + my $static = fn_prefix($fn); # pull function args - pidl "NTSTATUS ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, int flags, struct $fn->{NAME} *r)\n{\n"; + pidl $static . "NTSTATUS ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, int flags, struct $fn->{NAME} *r)\n{\n"; # declare any internal pointers we need foreach my $e (@{$fn->{DATA}}) { @@ -1384,7 +1395,7 @@ sub Parse($$) my($idl) = shift; my($filename) = shift; - open(IDL, ">$filename") || die "can't open $filename"; + open(OUT, ">$filename") || die "can't open $filename"; pidl "/* parser auto-generated by pidl */\n\n"; pidl "#include \"includes.h\"\n\n"; @@ -1394,7 +1405,10 @@ sub Parse($$) ParseInterface($x); } } - close(IDL); + + pidl IdlClient::Parse($idl); + + close(OUT); } 1; diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl index edeab1564e..77b80d8bfd 100755 --- a/source4/build/pidl/pidl.pl +++ b/source4/build/pidl/pidl.pl @@ -18,7 +18,6 @@ use dump; use header; use parser; use eparser; -use client; use validator; use util; @@ -29,7 +28,6 @@ my($opt_diff) = 0; my($opt_header) = 0; my($opt_parser) = 0; my($opt_eparser) = 0; -my($opt_client); my($opt_keep) = 0; my($opt_output); @@ -73,7 +71,6 @@ sub ShowHelp() --header create a C header file --parser create a C parser --eparser create an ethereal parser - --client FILENAME create client calls in FILENAME --diff run diff on the idl and dumped output --keep keep the .pidl file \n"; @@ -89,7 +86,6 @@ GetOptions ( 'header' => \$opt_header, 'parser' => \$opt_parser, 'eparser' => \$opt_eparser, - 'client=s' => \$opt_client, 'diff' => \$opt_diff, 'keep' => \$opt_keep ); @@ -149,14 +145,6 @@ sub process_file($) util::FileSave($parser, IdlEParser::Parse($idl)); } - if ($opt_client) { - my($idl) = util::LoadStructure($pidl_file); - my($client) = $opt_client . $basename; - $client = util::ChangeExtension($client, "c"); - print "Generating $client client calls\n"; - util::FileSave($client, IdlClient::Parse($idl)); - } - if ($opt_diff) { my($idl) = util::LoadStructure($pidl_file); my($tempfile) = util::ChangeExtension($output, "tmp"); diff --git a/source4/librpc/idl/atsvc.idl b/source4/librpc/idl/atsvc.idl index 39add81b09..e221875f9f 100644 --- a/source4/librpc/idl/atsvc.idl +++ b/source4/librpc/idl/atsvc.idl @@ -59,7 +59,7 @@ /******************/ /* Function: 0x03 */ - NTSTATUS atsvc_JobGetInfo( + [public] NTSTATUS atsvc_JobGetInfo( [in] unistr *servername, [in] uint32 job_id, [out] atsvc_JobInfo *job_info diff --git a/source4/librpc/idl/dcerpc.idl b/source4/librpc/idl/dcerpc.idl index b00396e787..32850b90cf 100644 --- a/source4/librpc/idl/dcerpc.idl +++ b/source4/librpc/idl/dcerpc.idl @@ -11,7 +11,7 @@ [] interface dcerpc { - typedef struct { + typedef [public] struct { GUID uuid; uint16 major_version; uint16 minor_version; diff --git a/source4/script/build_idl.sh b/source4/script/build_idl.sh index b31d26c23d..8c04db6f37 100755 --- a/source4/script/build_idl.sh +++ b/source4/script/build_idl.sh @@ -3,11 +3,10 @@ FULLBUILD=$1 [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1 -[ -d librpc/gen_rpc ] || mkdir -p librpc/gen_rpc || exit 1 ( cd build/pidl && make ) || exit 1 -PIDL="build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --client librpc/gen_rpc/rpc_" +PIDL="build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser" TABLES="build/pidl/tables.pl --output librpc/gen_ndr/tables" if [ x$FULLBUILD = xFULL ]; then @@ -15,7 +14,7 @@ if [ x$FULLBUILD = xFULL ]; then $PIDL librpc/idl/*.idl || exit 1 echo Rebuilding IDL tables - $TABLES librpc/gen_ndr/ndr_*.h + $TABLES librpc/gen_ndr/ndr_*.h || exit 1 exit 0 fi @@ -30,6 +29,7 @@ done if [ "x$list" != x ]; then $PIDL $list || exit 1 + $TABLES librpc/gen_ndr/ndr_*.h || exit 1 fi exit 0 diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c index 9c94515ea3..3469294552 100644 --- a/source4/torture/rpc/scanner.c +++ b/source4/torture/rpc/scanner.c @@ -47,27 +47,32 @@ static BOOL test_num_calls(const struct dcerpc_interface_table *iface, } /* make null calls */ - stub_in = data_blob(NULL, 0); - - status = dcerpc_request(p, 10000, mem_ctx, &stub_in, &stub_out); - if (NT_STATUS_IS_OK(status) || - p->last_fault_code != DCERPC_FAULT_OP_RNG_ERROR) { - printf("\tunable to determine call count - %s %08x\n", - nt_errstr(status), p->last_fault_code); - goto done; - } + stub_in = data_blob(NULL, 1000); + memset(stub_in.data, 0xFF, stub_in.length); - for (i=128;i>=0;i--) { + for (i=0;i<200;i++) { status = dcerpc_request(p, i, mem_ctx, &stub_in, &stub_out); - if (NT_STATUS_IS_OK(status) || - p->last_fault_code != DCERPC_FAULT_OP_RNG_ERROR) break; + if (!NT_STATUS_IS_OK(status) && + p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) { + break; + } + + if (!NT_STATUS_IS_OK(status) && p->last_fault_code == 5) { + printf("\tpipe disconnected at %d\n", i); + goto done; + } + + if (!NT_STATUS_IS_OK(status) && p->last_fault_code == 0x80010111) { + printf("\terr 0x80010111 at %d\n", i); + goto done; + } } - printf("\t%d calls available\n", i+1); + printf("\t%d calls available\n", i); idl_calls = idl_num_calls(uuid, id->major_version); if (idl_calls == -1) { printf("\tinterface not known in local IDL\n"); - } else if (i+1 != idl_calls) { + } else if (i != idl_calls) { printf("\tWARNING: local IDL defines %u calls\n", idl_calls); } else { printf("\tOK: matches num_calls in local IDL\n"); |