pidl-wireshark: add a function to change the type of a hf_field
authorMatthieu Patou <mat@matws.net>
Thu, 3 Oct 2013 08:10:48 +0000 (01:10 -0700)
committerStefan Metzmacher <metze@samba.org>
Thu, 9 Oct 2014 20:06:47 +0000 (22:06 +0200)
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@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Wireshark/NDR.pm

index e7c1a407e2bcbe5f41c640f0ec1ac9704a099b23..efc617bb008ee66f69856e583e3fc8357b77e1e4 100644 (file)
@@ -1164,6 +1164,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) = @_;