diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-05-16 22:25:13 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:08:03 -0500 |
commit | 76aa75abc6dde74d1d8d382fe8d1fa07750a90da (patch) | |
tree | aecfe05feeea187722c78d16d0633a39f2576d01 /source4/pidl/lib | |
parent | 392e4b383c35ba9befd396a99f6f27608efb9862 (diff) | |
download | samba-76aa75abc6dde74d1d8d382fe8d1fa07750a90da.tar.gz samba-76aa75abc6dde74d1d8d382fe8d1fa07750a90da.tar.bz2 samba-76aa75abc6dde74d1d8d382fe8d1fa07750a90da.zip |
r15651: 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.
(This used to be commit a3dbab619bf8fdef002b8e31956e99226bc20e94)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm | 19 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm | 35 |
2 files changed, 50 insertions, 4 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm index e3296c1629..02319a0aa9 100644 --- a/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm +++ b/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm @@ -74,6 +74,13 @@ Code to insert when generating the specified dissector. @HF@ and 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_strip_prefix($$$) 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_noemit($$$) } } +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 @@ sub handle_import 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, diff --git a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm index 371c35b374..685cb5a12a 100644 --- a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm @@ -72,9 +72,24 @@ sub field2name($) 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 @@ sub Enum($$$) return if (defined($conformance->{noemit}->{StripPrefixes($name)})); - foreach (@{$e->{ELEMENTS}}) { + foreach (@{$e->{ELEMENTS}}) { if (/([^=]*)=(.*)/) { pidl_hdr "#define $1 ($2)"; } @@ -142,6 +157,7 @@ sub Enum($$$) 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 @@ sub Enum($$$) 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 @@ sub Bitmap($$$) 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 @@ sub Bitmap($$$) 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 @@ sub Element($$$) 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 @@ sub Element($$$) 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 @@ sub Function($$$) $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 @@ sub Function($$$) 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 @@ sub Function($$$) pidl_code "return offset;"; deindent; pidl_code "}\n"; + pidl_fn_end "$ifname\_dissect\_$fn_name\_request"; } sub Struct($$$) @@ -473,6 +498,7 @@ sub Struct($$$) 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 @@ sub Struct($$$) pidl_code "return offset;"; deindent; pidl_code "}\n"; + pidl_fn_end $dissectorname; register_type($name, "offset = $dissectorname(tvb,offset,pinfo,tree,drep,\@HF\@,\@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0); } @@ -536,6 +563,7 @@ sub Union($$$) $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 @@ sub Union($$$) pidl_code "return offset;"; deindent; pidl_code "}"; + pidl_fn_end $dissectorname; register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0); } @@ -602,6 +631,7 @@ sub RegisterInterface($) { 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 @@ sub RegisterInterface($) deindent; pidl_code "}\n"; + pidl_fn_end "proto_register_dcerpc_$x->{NAME}"; } sub RegisterInterfaceHandoff($) @@ -646,6 +677,7 @@ sub RegisterInterfaceHandoff($) 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 @@ sub RegisterInterfaceHandoff($) 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; } |