Ethereal-dev: RE: [Ethereal-dev] dissector handoff boolean

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jeff Foster <jfoste@xxxxxxxxxxxx>
Date: Fri, 23 Feb 2001 09:10:46 -0600
From: Hartmut Mueller [mailto:hartmut@xxxxxxxxxxxxxxxxx]
Sent: Friday, February 23, 2001 8:09 AM

> is it possible to refer to a boolean in a dissector call? Using the code 
> below results in the following error:
> 
> packet-bacnet.c: In function `dissect_bacnet':
> packet-bacnet.c:473: `bacnet' undeclared (first use in this function)

> in packet-bacnet.c: --------------
> if (!dissector_try_port(bacnet_dissector_table,
>         bacnet.control_net, next_tvb, pinfo, tree)) {  /* line 473 */
>                 dissect_data(next_tvb, offset, pinfo, tree);
> 
> static hf_register_info hf[] = {
>                 { &hf_bacnet_control,
>                         { "Control",           "bacnet.control",
>                         FT_UINT8, BASE_HEX, NULL, 0xff,
>                         "BACnet Control" }
>                 },
>                 { &hf_bacnet_control_net,
>                         { "NSDU contains",
>                         "bacnet.control_net",
>                         FT_BOOLEAN, 8, TFS(&control_net_set_high),
>                         BAC_CONTROL_NET, "BACnet Control" }
>                 },

The second parameter to the dissector_try_port is a guint32. You can
use a boolean value, you just have to convert it to an guint32. 
Before this dissector_try_port call you have to extract this value
from the packet data.  A possible example for your code -

	guint8 bacnet_control_net;

	bacnet_control_net = guint8( tvb, offset, 1);
or
	bacnet_control_net = guint8( tvb, offset, 1) & bac_control_net_mask;

then the call would become -

	dissector_try_port(bacnet_dissector_table,
	if (!dissector_try_port(bacnet_dissector_table,
      	  bacnet_control_net, next_tvb, pinfo, tree)) {  /* line 473 */
            	     dissect_data(next_tvb, offset, pinfo, tree);


Jeff Foster
jfoste@xxxxxxxxxxxx