WRONG! pidl-wireshark: generate NDR64 enabled code for enums
[metze/samba/wip.git] / pidl / lib / Parse / Pidl / Wireshark / NDR.pm
index e86bfc5f12ceb061390e7b3898f0242c7aff6c56..0c5340fb20e03b3a036d709206ebc0fd444d3fc9 100644 (file)
@@ -166,13 +166,15 @@ sub Enum($$$$)
        $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_)");
        $self->pidl_code("{");
        $self->indent;
-       $self->pidl_code("g$e->{BASE_TYPE} parameter=0;");
+       my $type = $e->{BASE_TYPE};
+       $type = "uint1632" if ($e->{BASE_TYPE} eq "uint16");
+       $self->pidl_code("g${type} parameter=0;");
        $self->pidl_code("if(param){");
        $self->indent;
-       $self->pidl_code("parameter=(g$e->{BASE_TYPE})*param;");
+       $self->pidl_code("parameter=(g${type})*param;");
        $self->deindent;
        $self->pidl_code("}");
-       $self->pidl_code("offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, drep, hf_index, &parameter);");
+       $self->pidl_code("offset = dissect_ndr_${type}(tvb, offset, pinfo, tree, drep, hf_index, &parameter);");
        $self->pidl_code("if(param){");
        $self->indent;
        $self->pidl_code("*param=(guint32)parameter;");
@@ -1166,6 +1168,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) = @_;