mirror of
https://github.com/samba-team/samba.git
synced 2025-02-21 01:59:07 +03:00
r602: Autogenerated packet-dcerpc-samr.c now compiles!
(This used to be commit 0c1069b56e7c80e2b428f6a6b550eacd5ac3d762)
This commit is contained in:
parent
54a695f7ed
commit
0221717a62
@ -10,6 +10,8 @@ use strict;
|
||||
use dump;
|
||||
use Data::Dumper;
|
||||
|
||||
my($name);
|
||||
|
||||
sub ParamSimpleNdrType($)
|
||||
{
|
||||
my($p) = shift;
|
||||
@ -25,7 +27,7 @@ sub ParamPolicyHandle($)
|
||||
my($p) = shift;
|
||||
my($res);
|
||||
|
||||
$res .= "\toffset = dissect_nt_policy_handle(tvb, offset, pinfo, tree, drep, hf_policy_hnd, NULL, NULL, FALSE, FALSE);\n";
|
||||
$res .= "\toffset = dissect_nt_policy_hnd(tvb, offset, pinfo, tree, drep, hf_policy_hnd, NULL, NULL, FALSE, FALSE);\n";
|
||||
|
||||
return $res;
|
||||
}
|
||||
@ -89,7 +91,7 @@ sub ParseFunction($)
|
||||
$res .= ParseParameter($d), if defined($d->{PROPERTIES}{out});
|
||||
}
|
||||
|
||||
|
||||
$res .= "\n";
|
||||
$res .= "\treturn offset;\n";
|
||||
$res .= "}\n\n";
|
||||
|
||||
@ -98,7 +100,7 @@ sub ParseFunction($)
|
||||
|
||||
#####################################################################
|
||||
# parse the interface definitions
|
||||
sub ParseInterface($)
|
||||
sub Pass2Interface($)
|
||||
{
|
||||
my($interface) = shift;
|
||||
my($data) = $interface->{DATA};
|
||||
@ -111,19 +113,157 @@ sub ParseInterface($)
|
||||
return $res;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# Pass 1: Stuff required before structs and functions
|
||||
|
||||
sub Pass1ModuleHeader($)
|
||||
{
|
||||
my($d) = shift;
|
||||
my($res) = "";
|
||||
|
||||
$res .= << "EOF";
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "packet-dcerpc.h"
|
||||
#include "packet-dcerpc-nt.h"
|
||||
|
||||
EOF
|
||||
|
||||
# UUID
|
||||
|
||||
if ($d->{TYPE} eq "MODULEHEADER" and defined($d->{PROPERTIES}->{uuid})) {
|
||||
my $uuid = $d->{PROPERTIES}->{uuid};
|
||||
$res .= "static e_uuid_t uuid_dcerpc_$name = {\n";
|
||||
$res .= "\t0x" . substr($uuid, 0, 8);
|
||||
$res .= ", 0x" . substr($uuid, 9, 4);
|
||||
$res .= ", 0x" . substr($uuid, 14, 4) . ",\n";
|
||||
$res .= "\t{ 0x" . substr($uuid, 19, 2);
|
||||
$res .= ", 0x" . substr($uuid, 21, 2);
|
||||
$res .= ", 0x" . substr($uuid, 24, 2);
|
||||
$res .= ", 0x" . substr($uuid, 26, 2);
|
||||
$res .= ", 0x" . substr($uuid, 28, 2);
|
||||
$res .= ", 0x" . substr($uuid, 30, 2);
|
||||
$res .= ", 0x" . substr($uuid, 32, 2);
|
||||
$res .= ", 0x" . substr($uuid, 34, 2) . " }\n";
|
||||
$res .= "};\n\n";
|
||||
|
||||
$res .= "static guint16 ver_dcerpc_samr = " .
|
||||
$d->{PROPERTIES}->{version} . ";\n\n";
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
sub Pass1Interface($)
|
||||
{
|
||||
my($interface) = shift;
|
||||
my($res) = "";
|
||||
|
||||
$res .= << "EOF";
|
||||
static int proto_dcerpc_$name = -1;
|
||||
|
||||
static int hf_${name}_opnum = -1;
|
||||
static int hf_${name}_rc = -1;
|
||||
static int hf_policy_hnd = -1;
|
||||
|
||||
static gint ett_dcerpc_$name = -1;
|
||||
|
||||
EOF
|
||||
|
||||
my %p = ();
|
||||
|
||||
foreach my $fn (@{$interface->{DATA}}) {
|
||||
next, if $fn->{TYPE} ne "FUNCTION";
|
||||
foreach my $args ($fn->{DATA}) {
|
||||
foreach my $params (@{$args}) {
|
||||
$res .= "static int hf_$params->{NAME} = -1;\n",
|
||||
if not defined $p{$params->{NAME}};
|
||||
$p{$params->{NAME}} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res .= "\n";
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# Pass 3: trailing stuff
|
||||
|
||||
sub Pass3Interface($)
|
||||
{
|
||||
my($interface) = shift;
|
||||
my($res) = "";
|
||||
|
||||
$res .= "static dcerpc_sub_dissector dcerpc_${name}_dissectors[] = {\n";
|
||||
|
||||
my $num = 0;
|
||||
|
||||
foreach my $d (@{$interface->{DATA}}) {
|
||||
if ($d->{TYPE} eq "FUNCTION") {
|
||||
# Strip module name from function name, if present
|
||||
my $n = $d->{NAME};
|
||||
$n = substr($d->{NAME}, length($name) + 1),
|
||||
if $name eq substr($d->{NAME}, 0, length($name));
|
||||
|
||||
$res .= "\t{ $num, \"$n\",\n";
|
||||
$res .= "\t\t$d->{NAME}_rqst,\n";
|
||||
$res .= "\t\t$d->{NAME}_resp },\n";
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
$res .= "};\n\n";
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# parse a parsed IDL structure back into an IDL file
|
||||
sub Parse($)
|
||||
{
|
||||
my($idl) = shift;
|
||||
my($res);
|
||||
my($res) = "/* parser auto-generated by pidl */\n\n";
|
||||
my($d);
|
||||
|
||||
$res = "/* parser auto-generated by pidl */\n\n";
|
||||
foreach my $d (@{$idl}) {
|
||||
$res .= ParseInterface($d), if $d->{TYPE} eq "INTERFACE";
|
||||
# Pass 0: set module name
|
||||
|
||||
foreach $d (@{$idl}) {
|
||||
$name = $d->{NAME}, if ($d->{TYPE} eq "INTERFACE");
|
||||
}
|
||||
|
||||
# Pass 1: header stuff
|
||||
|
||||
foreach $d (@{$idl}) {
|
||||
$res .= Pass1ModuleHeader($d), if $d->{TYPE} eq "MODULEHEADER";
|
||||
$res .= Pass1Interface($d), if $d->{TYPE} eq "INTERFACE";
|
||||
}
|
||||
|
||||
# Pass 2: typedefs and functions
|
||||
|
||||
foreach $d (@{$idl}) {
|
||||
$res .= Pass2Interface($d), if $d->{TYPE} eq "INTERFACE";
|
||||
}
|
||||
|
||||
# Pass 3: trailing stuff
|
||||
|
||||
foreach $d (@{$idl}) {
|
||||
$res .= Pass3Interface($d), if $d->{TYPE} eq "INTERFACE";
|
||||
}
|
||||
|
||||
$res .= << "EOF";
|
||||
void
|
||||
proto_reg_handoff_dcerpc_$name(void)
|
||||
{
|
||||
dcerpc_init_uuid(proto_dcerpc_$name, ett_dcerpc_$name,
|
||||
&uuid_dcerpc_$name, ver_dcerpc_$name,
|
||||
dcerpc_${name}_dissectors, hf_${name}_opnum);
|
||||
}
|
||||
EOF
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ sub process_file($)
|
||||
}
|
||||
|
||||
if ($opt_eparser) {
|
||||
my($parser) = util::ChangeExtension($output, "_ethereal.c");
|
||||
my($parser) = dirname($output) . "/packet-dcerpc-$basename.c";
|
||||
util::FileSave($parser, IdlEParser::Parse($pidl));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user