[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu Oct 9 16:33:03 MDT 2014


The branch, master has been updated
       via  fa331f6 pidl-wireshark: insure that we have an entire match for the variable name
       via  5d0d45c pidl-wireshark: generate an error for the new Pipe type in typedef
       via  87fb54b pidl-wireshark: add the type dom_sid28 and call ad-hoc dissector
       via  755bc4e pidl-wireshark: add a function to change the type of a hf_field
       via  7e5048d pidl-wireshark: cosmetic reformat
       via  343db53 pidl-wireshark: Handle the case when the DATA_TYPE is not a simple type
       via  5740a06 pidl: Improve string delection in function ContainsString
       via  4986359 pidl: Make the compilation of PIDL producing the same results if the content hasn't change
      from  9ae65ba ncacn_http: fix GNUism

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fa331f64d1a40350496c7acf68c20cb3fead6eaf
Author: Matthieu Patou <mat at matws.net>
Date:   Thu Oct 3 09:45:19 2013 -0700

    pidl-wireshark: insure that we have an entire match for the variable name
    
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Oct 10 00:32:40 CEST 2014 on sn-devel-104

commit 5d0d45c9a71f137dc29ca79d49bd558f34bf1ff5
Author: Matthieu Patou <mat at matws.net>
Date:   Sun Sep 29 00:42:36 2013 -0700

    pidl-wireshark: generate an error for the new Pipe type in typedef
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 87fb54b77f4b9caaf2b25635b7813e29a448aaa6
Author: Matthieu Patou <mat at matws.net>
Date:   Tue Oct 1 12:04:02 2013 -0700

    pidl-wireshark: add the type dom_sid28 and call ad-hoc dissector
    
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 755bc4ed29c89fc15d4230ce8b828b3afcfa2912
Author: Matthieu Patou <mat at matws.net>
Date:   Thu Oct 3 01:10:48 2013 -0700

    pidl-wireshark: add a function to change the type of a hf_field
    
    We can use this to change the type FT_BYTE when we realize that the
    object dissected is an array of bytes
    
    Change-Id: I2d09c557fd050d0c279b8fff0a27db53403366ca
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 7e5048d28e86595357be399d0e55cf97a0781703
Author: Matthieu Patou <mat at matws.net>
Date:   Thu Oct 3 01:07:55 2013 -0700

    pidl-wireshark: cosmetic reformat
    
    Change-Id: I86a0d4f13575e5ef7c6968b93ce126e5df981873
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 343db5326b369cbdef4b723e3056acc2a866a887
Author: Matthieu Patou <mat at matws.net>
Date:   Tue Sep 23 01:28:40 2014 -0700

    pidl-wireshark: Handle the case when the DATA_TYPE is not a simple type
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Change-Id: If78f241333c1372c60c7d00211c1e6aeb22c9719
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 5740a06b320d56840439fb7fe3b8b27f341ddaa7
Author: Matthieu Patou <mat at matws.net>
Date:   Sat Oct 4 21:19:12 2014 -0700

    pidl: Improve string delection in function ContainsString
    
    Change-Id: I037e8b5f54fca8b512fd14edbefa34e59cb7f953
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 4986359816704f38d4fad3ddd0d07a0f0a25b335
Author: Matthieu Patou <mat at matws.net>
Date:   Mon Sep 22 21:52:14 2014 -0700

    pidl: Make the compilation of PIDL producing the same results if the content hasn't change
    
    Newer perl versions don't generate stable results anymore.
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Change-Id: I2fb1e12da392ca85bfd0fb8b50b69851076144ee
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 pidl/lib/Parse/Pidl/Dump.pm              |    4 +-
 pidl/lib/Parse/Pidl/NDR.pm               |   10 +++++
 pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm  |    2 +-
 pidl/lib/Parse/Pidl/Samba4/Header.pm     |    2 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm |    2 +-
 pidl/lib/Parse/Pidl/Samba4/Python.pm     |   48 +++++++++++++--------
 pidl/lib/Parse/Pidl/Util.pm              |    1 +
 pidl/lib/Parse/Pidl/Wireshark/NDR.pm     |   66 ++++++++++++++++++++++++------
 8 files changed, 99 insertions(+), 36 deletions(-)


Changeset truncated at 500 lines:

diff --git a/pidl/lib/Parse/Pidl/Dump.pm b/pidl/lib/Parse/Pidl/Dump.pm
index bf5811c..4e623db 100644
--- a/pidl/lib/Parse/Pidl/Dump.pm
+++ b/pidl/lib/Parse/Pidl/Dump.pm
@@ -39,7 +39,7 @@ sub DumpProperties($)
     my $res = "";
 
     foreach my $d ($props) {
-	foreach my $k (keys %{$d}) {
+	foreach my $k (sort(keys %{$d})) {
 	    if ($k eq "in") {
 		$res .= "[in] ";
 		next;
@@ -244,7 +244,7 @@ sub DumpInterfaceProperties($)
     my($res);
 
     $res .= "[\n";
-    foreach my $k (keys %{$data}) {
+    foreach my $k (sort(keys %{$data})) {
 	    $first || ($res .= ",\n"); $first = 0;
 	    $res .= "$k($data->{$k})";
     }
diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm
index 6827152..d65cbe7 100644
--- a/pidl/lib/Parse/Pidl/NDR.pm
+++ b/pidl/lib/Parse/Pidl/NDR.pm
@@ -952,9 +952,19 @@ sub ContainsString($)
 	if (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
 		return 1;
 	}
+	if (exists($e->{LEVELS}) and $e->{LEVELS}->[0]->{TYPE} eq "ARRAY" and
+		($e->{LEVELS}->[0]->{IS_FIXED} or $e->{LEVELS}->[0]->{IS_INLINE}) and
+		has_property($e, "charset"))
+	{
+		return 1;
+	}
+
 	foreach my $l (@{$e->{LEVELS}}) {
 		return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
 	}
+	if (property_matches($e, "charset", ".*DOS.*")) {
+		return 1;
+	}
 
 	return 0;
 }
diff --git a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
index 8142b35..aa913f1 100644
--- a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
+++ b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
@@ -59,7 +59,7 @@ sub HeaderProperties($$)
 	my($props,$ignores) = @_;
 	my $ret = "";
 
-	foreach my $d (keys %{$props}) {
+	foreach my $d (sort(keys %{$props})) {
 		next if (grep(/^$d$/, @$ignores));
 		if($props->{$d} ne "1") {
 			$ret.= "$d($props->{$d}),";
diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm
index 49c5afa..e9b7bee 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -38,7 +38,7 @@ sub HeaderProperties($$)
 	my($props,$ignores) = @_;
 	my $ret = "";
 
-	foreach my $d (keys %{$props}) {
+	foreach my $d (sort(keys %{$props})) {
 		next if (grep(/^$d$/, @$ignores));
 		if($props->{$d} ne "1") {
 			$ret.= "$d($props->{$d}),";
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index b4954ca..ee68090 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -259,7 +259,7 @@ sub HeaderProperties($$)
 	my($props,$ignores) = @_;
 	my $ret = "";
 
-	foreach my $d (keys %{$props}) {
+	foreach my $d (sort(keys %{$props})) {
 		next if (grep(/^$d$/, @$ignores));
 		if($props->{$d} ne "1") {
 			$ret.= "$d($props->{$d}),";
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index d603176..31cf63f 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -22,9 +22,11 @@ $VERSION = '0.01';
 
 sub new($) {
 	my ($class) = @_;
-	my $self = { res => "", res_hdr => "", tabs => "", constants => {},
+	my $self = { res => "", res_hdr => "", tabs => "",
+				 constants => [], constants_uniq => {},
 	             module_methods => [], module_objects => [], ready_types => [],
-				 module_imports => {}, type_imports => {},
+				 module_imports => [], module_imports_uniq => {},
+				 type_imports => [], type_imports_uniq => {},
 				 patch_type_calls => [], prereadycode => [],
 			 	 postreadycode => []};
 	bless($self, $class);
@@ -94,7 +96,11 @@ sub register_constant($$$$)
 {
 	my ($self, $name, $type, $value) = @_;
 
-	$self->{constants}->{$name} = [$type, $value];
+	unless (defined $self->{constants_uniq}->{$name}) {
+		my $h = {"key" => $name, "val" => [$type, $value]};
+		push @{$self->{constants}}, $h;
+		$self->{constants_uniq}->{$name} = $h;
+	}
 }
 
 sub EnumAndBitmapConsts($$$)
@@ -844,8 +850,11 @@ sub register_module_import($$)
 	$var_name =~ s/\./_/g;
 	$var_name = "dep_$var_name";
 
-	$self->{module_imports}->{$var_name} = $module_path;
-
+	unless (defined $self->{module_imports_uniq}->{$var_name}) {
+		my $h = { "key" => $var_name, "val" => $module_path};
+		push @{$self->{module_imports}}, $h;
+		$self->{module_imports_uniq}->{$var_name} = $h;
+	}
 	return $var_name;
 }
 
@@ -854,8 +863,10 @@ sub import_type_variable($$$)
 	my ($self, $module, $name) = @_;
 
 	$self->register_module_import($module);
-	unless (defined($self->{type_imports}->{$name})) {
-		$self->{type_imports}->{$name} = $module;
+	unless (defined $self->{type_imports_uniq}->{$name}) {
+		my $h = { "key" => $name, "val" => $module};
+		push @{$self->{type_imports}}, $h;
+		$self->{type_imports_uniq}->{$name} = $h;
 	}
 	return "$name\_Type";
 }
@@ -1405,25 +1416,25 @@ sub Parse($$$$$)
 	$self->pidl("{");
 	$self->indent;
 	$self->pidl("PyObject *m;");
-	foreach (keys %{$self->{module_imports}}) {
-		$self->pidl("PyObject *$_;");
+	foreach my $h (@{$self->{module_imports}}) {
+		$self->pidl("PyObject *$h->{'key'};");
 	}
 	$self->pidl("");
 
-	foreach (keys %{$self->{module_imports}}) {
-		my $var_name = $_;
-		my $module_path = $self->{module_imports}->{$var_name};
+	foreach my $h (@{$self->{module_imports}}) {
+		my $var_name = $h->{'key'};
+		my $module_path = $h->{'val'};
 		$self->pidl("$var_name = PyImport_ImportModule(\"$module_path\");");
 		$self->pidl("if ($var_name == NULL)");
 		$self->pidl("\treturn;");
 		$self->pidl("");
 	}
 
-	foreach (keys %{$self->{type_imports}}) {
-		my $type_var = "$_\_Type";
-		my $module_path = $self->{type_imports}->{$_};
+	foreach my $h (@{$self->{type_imports}}) {
+		my $type_var = "$h->{'key'}\_Type";
+		my $module_path = $h->{'val'};
 		$self->pidl_hdr("static PyTypeObject *$type_var;\n");
-		my $pretty_name = PrettifyTypeName($_, $module_path);
+		my $pretty_name = PrettifyTypeName($h->{'key'}, $module_path);
 		my $module_var = "dep_$module_path";
 		$module_var =~ s/\./_/g;
 		$self->pidl("$type_var = (PyTypeObject *)PyObject_GetAttrString($module_var, \"$pretty_name\");");
@@ -1454,9 +1465,10 @@ sub Parse($$$$$)
 	$self->pidl("if (m == NULL)");
 	$self->pidl("\treturn;");
 	$self->pidl("");
-	foreach my $name (keys %{$self->{constants}}) {
+	foreach my $h (@{$self->{constants}}) {
+		my $name = $h->{'key'};
 		my $py_obj;
-		my ($ctype, $cvar) = @{$self->{constants}->{$name}};
+		my ($ctype, $cvar) = @{$h->{'val'}};
 		if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
 			$py_obj = "PyInt_FromLong($cvar)";
 		} elsif ($cvar =~ /^".*"$/) {
diff --git a/pidl/lib/Parse/Pidl/Util.pm b/pidl/lib/Parse/Pidl/Util.pm
index 006718d..421cb8f 100644
--- a/pidl/lib/Parse/Pidl/Util.pm
+++ b/pidl/lib/Parse/Pidl/Util.pm
@@ -43,6 +43,7 @@ unless we actually need it
 sub MyDumper($)
 {
 	require Data::Dumper;
+	$Data::Dumper::Sortkeys = 1;
 	my $s = shift;
 	return Data::Dumper::Dumper($s);
 }
diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index 91ef118..10eaa6c 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -188,6 +188,13 @@ sub Enum($$$$)
 	$self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$enum_size", "BASE_DEC", "0", "VALS($valsstring)", $enum_size / 8);
 }
 
+sub Pipe($$$$)
+{
+	my ($self,$e,$name,$ifname) = @_;
+	error($e->{ORIGINAL}, "Pipe not yet supported");
+	return;
+}
+
 sub Bitmap($$$$)
 {
 	my ($self,$e,$name,$ifname) = @_;
@@ -338,17 +345,25 @@ sub ElementLevel($$$$$$$$)
 			my $call;
 
 			if ($self->{conformance}->{imports}->{$l->{DATA_TYPE}}) {
-				$call = $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{DATA};	
+				$call = $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{DATA};
 				$self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{USED} = 1;
- 		        } elsif (defined($self->{conformance}->{imports}->{"$pn.$e->{NAME}"})) {
- 			        $call = $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{DATA};
+
+			} elsif (defined($self->{conformance}->{imports}->{"$pn.$e->{NAME}"})) {
+				$call = $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{DATA};
 				$self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{USED} = 1;
-			    
+
 			} elsif (defined($self->{conformance}->{types}->{$l->{DATA_TYPE}})) {
 				$call= $self->{conformance}->{types}->{$l->{DATA_TYPE}}->{DISSECTOR_NAME};
 				$self->{conformance}->{types}->{$l->{DATA_TYPE}}->{USED} = 1;
 			} else {
-				$self->pidl_code("offset = $ifname\_dissect_struct_" . $l->{DATA_TYPE} . "(tvb,offset,pinfo,tree,drep,$hf,$param);");
+				my $t;
+				if (ref($l->{DATA_TYPE}) eq "HASH" ) {
+					$t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}";
+				} else {
+					$t = $l->{DATA_TYPE};
+				}
+
+				$self->pidl_code("offset = $ifname\_dissect_struct_" . $t . "(tvb,offset,pinfo,tree,drep,$hf,$param);");
 
 				return;
 			}
@@ -392,6 +407,8 @@ sub ElementLevel($$$$$$$$)
 		$self->pidl_code("di->call_data->flags = saved_flags;");
 		$self->deindent;
 		$self->pidl_code("}");
+	} elsif ($_->{TYPE} eq "PIPE") {
+		error($e->{ORIGINAL}, "Type PIPE not yet supported");
 	} else {
 		die("Unknown type `$_->{TYPE}'");
 	}
@@ -607,7 +624,7 @@ sub Struct($$$$)
 		my $switch_info = undef;
 
 		my $v = $_->{NAME};
-		if (scalar(grep {/$v/} keys(%$varswitchs)) == 1) {
+		if (scalar(grep {/^$v$/} keys(%$varswitchs)) == 1) {
 			# This element is one of the switch attribute
 			my $switch_dt =  getType($_->{TYPE});
 			my $switch_type;
@@ -780,13 +797,13 @@ sub Type($$$$)
 	my ($self, $e, $name, $ifname) = @_;
 
 	$self->PrintIdl(DumpType($e->{ORIGINAL}));
-
 	{
 		ENUM => \&Enum,
 		STRUCT => \&Struct,
 		UNION => \&Union,
 		BITMAP => \&Bitmap,
-		TYPEDEF => \&Typedef
+		TYPEDEF => \&Typedef,
+		PIPE    => \&Pipe
 	}->{$e->{TYPE}}->($self, $e, $name, $ifname);
 }
 
@@ -923,7 +940,7 @@ sub ProcessInterface($$)
 	$self->Interface($x);
 	$self->pidl_code("\n".DumpFunctionTable($x));
 
-	foreach (keys %{$return_types{$x->{NAME}}}) {
+	foreach (sort(keys %{$return_types{$x->{NAME}}})) {
 		my ($type, $desc) = @{$return_types{$x->{NAME}}->{$_}};
 		my $dt = $self->find_type($type);
 		$dt or die("Unable to find information about return type `$type'");
@@ -992,13 +1009,19 @@ sub Initialize($$)
 	$self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
 	$self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
 	$self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
-	$self->register_type("SID", "
+	$self->register_type("dom_sid28", "{
+		dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
+		di->hf_index = \@HF\@;
+
+		offset = dissect_ndr_nt_SID28(tvb, offset, pinfo, tree, drep);
+	}", "FT_STRING", "BASE_NONE", 0, "NULL", 4);
+	$self->register_type("SID", "{
 		dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
 
 		di->hf_index = \@HF\@;
 
 		offset = dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, drep, param);
-	","FT_STRING", "BASE_NONE", 0, "NULL", 4);
+	}", "FT_STRING", "BASE_NONE", 0, "NULL", 4);
 	$self->register_type("WERROR", 
 		"offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(WERR_errors)", 4);
 	$self->register_type("NTSTATUS", 
@@ -1156,6 +1179,23 @@ sub register_hf_field($$$$$$$$$)
 	return $index;
 }
 
+sub change_hf_field_type($$$$)
+{
+	my ($self,$index,$ft_type,$base_type) = @_;
+	if (defined ($self->{conformance}->{hf_renames}->{$index})) {
+		print "Field $index has been renamed to ".$self->{conformance}->{hf_renames}->{$index}->{NEWNAME}." you can't change it's type";
+		return 0;
+	}
+
+	if (!defined ($self->{conformance}->{header_fields}->{$index})) {
+		print "Field $index doesn't exists";
+		return 0;
+	}
+	$self->{conformance}->{header_fields}->{$index}->{FT_TYPE} = $ft_type;
+	$self->{conformance}->{header_fields}->{$index}->{BASE_TYPE} = $base_type;
+	return 1;
+}
+
 sub DumpHfDeclaration($)
 {
 	my ($self) = @_;
@@ -1163,7 +1203,7 @@ sub DumpHfDeclaration($)
 
 	$res = "\n/* Header field declarations */\n";
 
-	foreach (keys %{$self->{conformance}->{header_fields}}) 
+	foreach (sort(keys %{$self->{conformance}->{header_fields}}))
 	{
 		$res .= "static gint $_ = -1;\n";
 	}
@@ -1190,7 +1230,7 @@ sub DumpHfList($)
 	my ($self) = @_;
 	my $res = "\tstatic hf_register_info hf[] = {\n";
 
-	foreach (values %{$self->{conformance}->{header_fields}}) 
+	foreach (sort {$a->{INDEX} cmp $b->{INDEX}} values %{$self->{conformance}->{header_fields}})
 	{
 		$res .= "\t{ &$_->{INDEX},
 	  { ".make_str($_->{NAME}).", ".make_str($_->{FILTER}).", $_->{FT_TYPE}, $_->{BASE_TYPE}, $_->{VALSSTRING}, $_->{MASK}, ".make_str_or_null($_->{BLURB}).", HFILL }},


-- 
Samba Shared Repository


More information about the samba-cvs mailing list