From 3d0e6b3835379d545189563ce25ffe37ed340703 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Nov 2003 13:44:19 +0000 Subject: added a tool called 'ndrdump' that allows you to dump NDR data according to the current IDL taking the data from a file. In combination with a little hack to ethereal to extract data this is a quite powerful IDL development tool. (This used to be commit 229a325c3cf0d4dc1e910ed32e1d7391040aeba1) --- source4/build/pidl/header.pm | 2 ++ source4/build/pidl/parser.pm | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'source4/build') diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm index d6584a05ad..5a75e4c9b4 100644 --- a/source4/build/pidl/header.pm +++ b/source4/build/pidl/header.pm @@ -240,6 +240,8 @@ sub HeaderInterface($) $res .= "#define DCERPC_$name\_NAME \"$interface->{NAME}\"\n\n"; } + $res .= "extern struct dcerpc_interface_table dcerpc_table_$interface->{NAME};\n\n"; + foreach my $d (@{$data}) { if ($d->{TYPE} eq "FUNCTION") { my $u_name = uc $d->{NAME}; diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index 59ff73b8e6..b92729a80a 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -406,7 +406,12 @@ sub ParseElementPullSwitch($$$$) pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n"; pidl "\t\t $e2->{TYPE} _level;\n"; pidl "\t\tNDR_CHECK(ndr_pull_$e2->{TYPE}(ndr, &_level));\n"; - pidl "\t\tif (_level != $switch_var) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u in $e->{NAME}\");\n"; + if ($switch_var =~ /r->in/) { + pidl "\t\tif (!(ndr->flags & LIBNDR_FLAG_REF_ALLOC) && _level != $switch_var) {\n"; + } else { + pidl "\t\tif (_level != $switch_var) {\n"; + } + pidl "\t\t\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u in $e->{NAME}\");\t\t} else { $switch_var = _level; }\n"; pidl "\t}\n"; } @@ -1210,6 +1215,37 @@ sub ParseFunctionPull($) pidl "\n\treturn NT_STATUS_OK;\n}\n\n"; } +##################################################################### +# produce a function call table +sub FunctionTable($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + my $count = 0; + + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { $count++; } + } + + + pidl "static const struct dcerpc_interface_call calls[] = {\n"; + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { + pidl "\t{\n"; + pidl "\t\t\"$d->{NAME}\",\n"; + pidl "\t\tsizeof(struct $d->{NAME}),\n"; + pidl "\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},\n"; + pidl "\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},\n"; + pidl "\t\t(ndr_print_function_t) ndr_print_$d->{NAME}\n"; + pidl "\t},\n"; + } + } + pidl "\t{ NULL, 0, NULL, NULL }\n};\n\n"; + + pidl "\nstruct dcerpc_interface_table dcerpc_table_$interface->{NAME} = {\"$interface->{NAME}\", $count,calls};\n\n"; +} + + ##################################################################### # parse the interface definitions sub ParseInterface($) @@ -1247,6 +1283,9 @@ sub ParseInterface($) ParseFunctionPrint($d); } } + + FunctionTable($interface); + } sub NeededFunction($) @@ -1310,7 +1349,6 @@ sub BuildNeeded($) } } - ##################################################################### # parse a parsed IDL structure back into an IDL file sub Parse($$) -- cgit