On Mon, Feb 19, 2001 at 03:12:55PM -0600, Jeff Foster wrote:
> From: Martin Thomas [mailto:martin_a_thomas@xxxxxxxxx]
> Sent: Monday, February 19, 2001 3:11 PM
>
> > Like this?
> >
> > pinfo->current_proto = "RFC1006";
> > if ( check_col( pinfo->fd, COL_PROTOCOL ) ) {
> > col_set_str( pinfo->fd, COL_PROTOCOL, "RFC1006" );
> >
> > I'll take out the check_col and try it again..
>
> No. You want the column check.
>
> What I mean is something like this..
>
> if ( tree) {
> pinfo->current_proto = "RFC1006";
> if ( check_col( pinfo->fd, COL_PROTOCOL ) ) {
> col_set_str( pinfo->fd, COL_PROTOCOL, "RFC1006" );
>
> In that case you will see your problem.
Actually, as his problem was, as I remember, that the Protocol column
was showing "RFC1006", not that it wasn't showing "RFC1006", the
incorrect code is probably more like the following:
if (tree) {
new_tvb = tvb_new_subset(tvb, offset, -1, -1);
dissect_ositp(new_tvb, pinfo, tree);
}
That code should not be put inside an "if".
Note that, if the code looks like that, this means that "offset" must
*NOT* be modified, prior to that, inside an "if" checking "tree":
if (tree) {
proto_tree_add_item(tree, hf_whatever, tvb, offset, FALSE);
offset += 2;
}
Instead, the code must do
if (tree)
proto_tree_add_item(tree, hf_whatever, tvb, offset, FALSE);
offset += 2;
so that "offset" has the correct value regardless of whether "tree" is
set.
See "packet-gre.c" for an example of how to step an "offset" variable in
a non-leaf-node dissector (that being one dissector I fixed to call the
sub-dissector regardless of whether "tree" is null or not).