From: John Thacker Date: Wed, 3 Jul 2024 11:56:42 +0000 (-0400) Subject: pidl: Wireshark: Convert the pidl dissector generation code to C99 types X-Git-Tag: tdb-1.4.11~155 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=00f5772874265d0cd8535cd60a76e6117ce715b5;p=thirdparty%2Fsamba.git pidl: Wireshark: Convert the pidl dissector generation code to C99 types Pick up change from Wireshark: commit 4df8d2884ddfe72a03d0b322c10ae515a8366ea4 Author: John Thacker Date: Sat Jun 22 11:21:47 2024 -0400 pidl: Convert the pidl dissector generation code to C99 types Switch the Wireshark.pm pidl dissector generation code to using C99 types, and regenerated the dcerpc pidl dissectors. Ping #19116 Signed-off-by: John Thacker Reviewed-by: Jo Sutton Reviewed-by: Stefan Metzmacher --- diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index fedc8542262..1f67b9bda0e 100644 --- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -152,7 +152,7 @@ sub Enum($$$$) } $self->pidl_hdr("extern const value_string $valsstring\[];"); - $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_);"); + $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_);"); $self->pidl_def("const value_string ".$valsstring."[] = {"); foreach (@{$e->{ELEMENTS}}) { @@ -165,7 +165,7 @@ sub Enum($$$$) $self->pidl_fn_start($dissectorname); $self->pidl_code("int"); - $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_)"); + $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_)"); $self->pidl_code("{"); $self->indent; $self->pidl_code("g$e->{BASE_TYPE} parameter=0;"); @@ -206,11 +206,11 @@ sub Bitmap($$$$) $self->register_ett("ett_$ifname\_$name"); - $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);"); + $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, uint32_t param _U_);"); $self->pidl_fn_start($dissectorname); $self->pidl_code("int"); - $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)"); + $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, uint32_t param _U_)"); $self->pidl_code("{"); $self->indent; foreach (@{$e->{ELEMENTS}}) { @@ -338,7 +338,7 @@ sub ElementLevel($$$$$$$$) my $nl = GetNextLevel($e,$l); $self->pidl_code("char *data;"); $self->pidl_code(""); - $self->pidl_code("offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, di, drep, sizeof(g$nl->{DATA_TYPE}), $hf, FALSE, &data);"); + $self->pidl_code("offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, di, drep, sizeof(g$nl->{DATA_TYPE}), $hf, false, &data);"); $self->pidl_code("proto_item_append_text(tree, \": %s\", data);"); } } @@ -351,10 +351,10 @@ sub ElementLevel($$$$$$$$) if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*") and property_matches($e, "flag", ".*LIBNDR_FLAG_STR_LEN4.*")) { $self->pidl_code("char *data;\n"); - $self->pidl_code("offset = dissect_ndr_cvstring(tvb, offset, pinfo, tree, di, drep, $bs, $hf, FALSE, &data);"); + $self->pidl_code("offset = dissect_ndr_cvstring(tvb, offset, pinfo, tree, di, drep, $bs, $hf, false, &data);"); $self->pidl_code("proto_item_append_text(tree, \": %s\", data);"); } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*")) { - $self->pidl_code("offset = dissect_ndr_vstring(tvb, offset, pinfo, tree, di, drep, $bs, $hf, FALSE, NULL);"); + $self->pidl_code("offset = dissect_ndr_vstring(tvb, offset, pinfo, tree, di, drep, $bs, $hf, false, NULL);"); } elsif (property_matches($e, "flag", ".*STR_NULLTERM.*")) { if ($bs == 2) { $self->pidl_code("offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, $hf , 0);") @@ -421,7 +421,7 @@ sub ElementLevel($$$$$$$$) # continue to dissect handmarshalled stuff with pidl $self->pidl_code("di->call_data->flags &= ~DCERPC_IS_NDR64;"); - $self->pidl_code("subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1);"); + $self->pidl_code("subtvb = tvb_new_subset_length_caplen(tvb, offset, (const int)size, -1);"); if ($param ne 0) { $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, di, drep, $param);"); } else { @@ -553,10 +553,10 @@ sub Element($$$$$$) } next if ($_->{TYPE} eq "SWITCH"); next if (defined($self->{conformance}->{noemit}->{"$dissectorname$add"})); - $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_$moreparam);"); + $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_$moreparam);"); $self->pidl_fn_start("$dissectorname$add"); $self->pidl_code("static int"); - $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_$moreparam)"); + $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_$moreparam)"); $self->pidl_code("{"); $self->indent; @@ -593,7 +593,7 @@ sub Function($$$) $self->PrintIdl(DumpFunction($fn->{ORIGINAL})); $self->pidl_fn_start("$ifname\_dissect\_$fn_name\_response"); $self->pidl_code("static int"); - $self->pidl_code("$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)"); + $self->pidl_code("$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_)"); $self->pidl_code("{"); $self->indent; if ( not defined($fn->{RETURN_TYPE})) { @@ -662,7 +662,7 @@ sub Function($$$) $self->pidl_fn_start("$ifname\_dissect\_$fn_name\_request"); $self->pidl_code("static int"); - $self->pidl_code("$ifname\_dissect\_${fn_name}_request(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)"); + $self->pidl_code("$ifname\_dissect\_${fn_name}_request(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_)"); $self->pidl_code("{"); $self->indent; $self->pidl_code("di->dcerpc_procedure_name=\"${fn_name}\";"); @@ -734,11 +734,11 @@ sub Struct($$$$) $doalign = 0; } - $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);"); + $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, uint32_t param _U_);"); $self->pidl_fn_start($dissectorname); $self->pidl_code("int"); - $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)"); + $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, uint32_t param _U_)"); $self->pidl_code("{"); $self->indent; $self->pidl_code($_) foreach (@$vars); @@ -747,7 +747,7 @@ sub Struct($$$$) $self->pidl_code("proto_tree *tree = NULL;"); } if (defined($doalign) and $doalign == 0) { - $self->pidl_code("gboolean oldalign = di->no_align;"); + $self->pidl_code("bool oldalign = di->no_align;"); } $self->pidl_code("int old_offset;"); $self->pidl_code(""); @@ -757,7 +757,7 @@ sub Struct($$$$) $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;"); } if ($doalign == 0) { - $self->pidl_code("di->no_align = TRUE;"); + $self->pidl_code("di->no_align = true;"); } $self->pidl_code(""); } @@ -829,7 +829,7 @@ sub Union($$$$) $self->pidl_fn_start($dissectorname); $self->pidl_code("static int"); - $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)"); + $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_, int hf_index _U_, uint32_t param _U_)"); $self->pidl_code("{"); $self->indent; $self->pidl_code("proto_item *item = NULL;"); @@ -1009,7 +1009,7 @@ sub ProcessInterface($$) $self->pidl_hdr("#define $define"); $self->pidl_hdr(""); - $self->pidl_def("static gint proto_dcerpc_$x->{NAME} = -1;"); + $self->pidl_def("static int proto_dcerpc_$x->{NAME} = -1;"); $self->register_ett("ett_dcerpc_$x->{NAME}"); $self->register_hf_field("hf_$x->{NAME}_opnum", "Operation", "$x->{NAME}.opnum", "FT_UINT16", "BASE_DEC", "NULL", 0, ""); @@ -1034,7 +1034,7 @@ sub ProcessInterface($$) my $maj = 0x0000FFFF & $x->{VERSION}; $maj =~ s/\.(.*)$//g; - $self->pidl_def("static guint16 ver_dcerpc_$x->{NAME} = $maj;"); + $self->pidl_def("static uint16_t ver_dcerpc_$x->{NAME} = $maj;"); $self->pidl_def(""); } @@ -1218,7 +1218,7 @@ sub register_ett($$) sub DumpEttList { my ($ett) = @_; - my $res = "\tstatic gint *ett[] = {\n"; + my $res = "\tstatic int *ett[] = {\n"; foreach (@$ett) { $res .= "\t\t&$_,\n"; } @@ -1231,7 +1231,7 @@ sub DumpEttDeclaration my ($ett) = @_; my $res = "\n/* Ett declarations */\n"; foreach (@$ett) { - $res .= "static gint $_;\n"; + $res .= "static int $_;\n"; } return "$res\n"; @@ -1297,7 +1297,7 @@ sub DumpHfDeclaration($) foreach (sort(keys %{$self->{conformance}->{header_fields}})) { - $res .= "static gint $_;\n"; + $res .= "static int $_;\n"; } return "$res\n"; diff --git a/pidl/tests/wireshark-ndr.pl b/pidl/tests/wireshark-ndr.pl index 9bc9aedce07..0edb0ec2668 100755 --- a/pidl/tests/wireshark-ndr.pl +++ b/pidl/tests/wireshark-ndr.pl @@ -204,18 +204,18 @@ $x->{conformance} = {types => { bla => "brainslug" } }; is("brainslug", $x->find_type("bla")); is(DumpEttList(["ett_t1", "ett_bla"]), - "\tstatic gint *ett[] = {\n" . + "\tstatic int *ett[] = {\n" . "\t\t&ett_t1,\n" . "\t\t&ett_bla,\n" . "\t};\n"); -is(DumpEttList(), "\tstatic gint *ett[] = {\n\t};\n"); -is(DumpEttList(["bla"]), "\tstatic gint *ett[] = {\n\t\t&bla,\n\t};\n"); +is(DumpEttList(), "\tstatic int *ett[] = {\n\t};\n"); +is(DumpEttList(["bla"]), "\tstatic int *ett[] = {\n\t\t&bla,\n\t};\n"); is(DumpEttDeclaration(["void", "zoid"]), "\n/* Ett declarations */\n" . - "static gint void;\n" . - "static gint zoid;\n" . + "static int void;\n" . + "static int zoid;\n" . "\n"); is(DumpEttDeclaration(), "\n/* Ett declarations */\n\n"); @@ -234,7 +234,7 @@ is($x->DumpHfList(), "\tstatic hf_register_info hf[] = { is($x->DumpHfDeclaration(), " /* Header field declarations */ -static gint hf_bla; +static int hf_bla; ");