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>
Mon, 4 Nov 2013 11:19:23 +0000 (12:19 +0100)
We can use this to change the type FT_BYTE when we realize that the
object dissected is an array of bytes

Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Wireshark/NDR.pm

index e86bfc5f12ceb061390e7b3898f0242c7aff6c56..99e358b482757364fbe53711e5bb0ba8eaf0de1b 100644 (file)
@@ -1166,6 +1166,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) = @_;