Author: jelmer
Date: 2006-05-16 22:25:13 +0000 (Tue, 16 May 2006)
New Revision: 15651

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15651

Log:
Add 'MANUAL' command in Ethereal conformance files. This allows overriding 
individual functions for specific element levels without losing the other 
functions for an element or the hf/ett fields allocated.

Fixes #3738.

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm       
2006-05-16 22:21:44 UTC (rev 15650)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm       
2006-05-16 22:25:13 UTC (rev 15651)
@@ -74,6 +74,13 @@
 
 Override the text shown when a bitmap boolean value is enabled or disabled.
 
+=item I<MANUAL> fn_name
+
+Force pidl to not generate a particular function but allow the user 
+to write a function manually. This can be used to remove the function 
+for only one level for a particular element rather then all the functions and 
+ett/hf variables for a particular element as the NOEMIT command does.
+
 =back
 
 =head1 EXAMPLE
@@ -232,9 +239,7 @@
 
 sub handle_noemit($$$)
 {
-       my $pos = shift;
-       my $data = shift;
-       my $type = shift;
+       my ($pos,$data,$type) = @_;
 
        if (defined($type)) {
            $data->{noemit}->{$type} = 1;
@@ -243,6 +248,13 @@
        }
 }
 
+sub handle_manual($$$)
+{
+       my ($pos,$data,$fn) = @_;
+
+    $data->{manual}->{$fn} = 1;
+}
+
 sub handle_protocol($$$$$$)
 {
        my ($pos, $data, $name, $longname, $shortname, $filtername) = @_;
@@ -287,6 +299,7 @@
 my %field_handlers = (
        TYPE => \&handle_type,
        NOEMIT => \&handle_noemit, 
+       MANUAL => \&handle_manual,
        PARAM_VALUE => \&handle_param_value, 
        HF_FIELD => \&handle_hf_field, 
        HF_RENAME => \&handle_hf_rename, 

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm       
2006-05-16 22:21:44 UTC (rev 15650)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm       
2006-05-16 22:25:13 UTC (rev 15651)
@@ -72,9 +72,24 @@
 
 my %res = ();
 my $tabs = "";
+my $cur_fn = undef;
+sub pidl_fn_start($)
+{
+       my $fn = shift;
+       $cur_fn = $fn;
+}
+sub pidl_fn_end($)
+{
+       my $fn = shift;
+       die("Inconsistent state: $fn != $cur_fn") if ($fn ne $cur_fn);
+       $cur_fn = undef;
+}
+
 sub pidl_code($)
 {
        my $d = shift;
+       return if (defined($cur_fn) and 
defined($conformance->{manual}->{$cur_fn}));
+ 
        if ($d) {
                $res{code} .= $tabs;
                $res{code} .= $d;
@@ -124,7 +139,7 @@
 
        return if (defined($conformance->{noemit}->{StripPrefixes($name)}));
 
-       foreach (@{$e->{ELEMENTS}}) {
+       foreach (@{$e->{ELEMENTS}}) {
                if (/([^=]*)=(.*)/) {
                        pidl_hdr "#define $1 ($2)";
                }
@@ -142,6 +157,7 @@
        pidl_def "{ 0, NULL }";
        pidl_def "};";
 
+       pidl_fn_start $dissectorname;
        pidl_code "int";
        pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info 
*pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)";
        pidl_code "{";
@@ -150,6 +166,7 @@
        pidl_code "return offset;";
        deindent;
        pidl_code "}\n";
+       pidl_fn_end $dissectorname;
 
        my $enum_size = $e->{BASE_TYPE};
        $enum_size =~ s/uint//g;
@@ -165,6 +182,7 @@
 
        pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info 
*pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param);";
 
+       pidl_fn_start $dissectorname;
        pidl_code "int";
        pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info 
*pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param 
_U_)";
        pidl_code "{";
@@ -230,6 +248,7 @@
        pidl_code "return offset;";
        deindent;
        pidl_code "}\n";
+       pidl_fn_end $dissectorname;
 
        my $size = $e->{BASE_TYPE};
        $size =~ s/uint//g;
@@ -376,6 +395,7 @@
        foreach (@{$e->{LEVELS}}) {
                next if ($_->{TYPE} eq "SWITCH");
                pidl_def "static int $dissectorname$add(tvbuff_t *tvb, int 
offset, packet_info *pinfo, proto_tree *tree, guint8 *drep);";
+               pidl_fn_start "$dissectorname$add";
                pidl_code "static int";
                pidl_code "$dissectorname$add(tvbuff_t *tvb, int offset, 
packet_info *pinfo, proto_tree *tree, guint8 *drep)";
                pidl_code "{";
@@ -387,6 +407,7 @@
                pidl_code "return offset;";
                deindent;
                pidl_code "}\n";
+               pidl_fn_end "$dissectorname$add";
                $add.="_";
                last if ($_->{TYPE} eq "ARRAY" and $_->{IS_ZERO_TERMINATED});
        }
@@ -408,6 +429,7 @@
        $fn_name =~ s/^${ifname}_//;
 
        PrintIdl DumpFunction($fn->{ORIGINAL});
+       pidl_fn_start "$ifname\_dissect\_$fn_name\_response";
        pidl_code "static int";
        pidl_code "$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int 
offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)";
        pidl_code "{";
@@ -441,7 +463,9 @@
        pidl_code "return offset;";
        deindent;
        pidl_code "}\n";
+       pidl_fn_end "$ifname\_dissect\_$fn_name\_response";
 
+       pidl_fn_start "$ifname\_dissect\_$fn_name\_request";
        pidl_code "static int";
        pidl_code "$ifname\_dissect\_${fn_name}_request(tvbuff_t *tvb _U_, int 
offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)";
        pidl_code "{";
@@ -457,6 +481,7 @@
        pidl_code "return offset;";
        deindent;
        pidl_code "}\n";
+       pidl_fn_end "$ifname\_dissect\_$fn_name\_request";
 }
 
 sub Struct($$$)
@@ -473,6 +498,7 @@
 
        pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info 
*pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param 
_U_);";
 
+       pidl_fn_start $dissectorname;
        pidl_code "int";
        pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info 
*pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param 
_U_)";
        pidl_code "{";
@@ -502,6 +528,7 @@
        pidl_code "return offset;";
        deindent;
        pidl_code "}\n";
+       pidl_fn_end $dissectorname;
 
        register_type($name, "offset = 
$dissectorname(tvb,offset,pinfo,tree,drep,[EMAIL PROTECTED]@,[EMAIL 
PROTECTED]@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
 }
@@ -536,6 +563,7 @@
                $switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
        }
 
+       pidl_fn_start $dissectorname;
        pidl_code "static int";
        pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info 
*pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param 
_U_)";
        pidl_code "{";
@@ -569,6 +597,7 @@
        pidl_code "return offset;";
        deindent;
        pidl_code "}";
+       pidl_fn_end $dissectorname;
 
        register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, 
drep, [EMAIL PROTECTED]@, [EMAIL PROTECTED]@);", "FT_NONE", "BASE_NONE", 0, 
"NULL", 0);
 }
@@ -602,6 +631,7 @@
 {
        my ($x) = @_;
 
+       pidl_fn_start "proto_register_dcerpc_$x->{NAME}";
        pidl_code "void proto_register_dcerpc_$x->{NAME}(void)";
        pidl_code "{";
        indent;
@@ -639,6 +669,7 @@
            
        deindent;
        pidl_code "}\n";
+       pidl_fn_end "proto_register_dcerpc_$x->{NAME}";
 }
 
 sub RegisterInterfaceHandoff($)
@@ -646,6 +677,7 @@
        my $x = shift;
 
        if (defined($x->{UUID})) {
+               pidl_fn_start "proto_reg_handoff_dcerpc_$x->{NAME}";
            pidl_code "void proto_reg_handoff_dcerpc_$x->{NAME}(void)";
            pidl_code "{";
            indent;
@@ -654,6 +686,7 @@
            pidl_code "\t$x->{NAME}_dissectors, hf_$x->{NAME}_opnum);";
            deindent;
            pidl_code "}";
+               pidl_fn_end "proto_reg_handoff_dcerpc_$x->{NAME}";
 
                $hf_used{"hf_$x->{NAME}_opnum"} = 1;
        }

Reply via email to