On Fri, 04 Aug 2000 10:31:09 Jochen Friedrich wrote: > > Hi there, > > this is a first version of a Zebra protocol dissector. It dissects the > protocol internally used by zebra (see http://www.zebra.org) for the > communication between the main zebra daemon and the various routing > protocol deamons. Nice to have when debugging zebra itself :-) > > Cheers, > Jochen In this section of dissect_zebra(): if ((command == ZEBRA_REDISTRIBUTE_DEFAULT_ADD) && (!request)) ti = proto_tree_add_string(zebra_tree, hf_zebra_command, NullTVB, offset, len, "Interface Up"); else if ((command == ZEBRA_REDISTRIBUTE_DEFAULT_DELETE) && (!request)) ti = proto_tree_add_string(zebra_tree, hf_zebra_command, NullTVB, offset, len, "Interface Down"); else ti = proto_tree_add_string(zebra_tree, hf_zebra_command, NullTVB, offset, len, val_to_str(command, messages, "Unknown command: %d")); I see why you made hf_zebra_command an FT_STRING instead of an FT_UINT8 with a value_string -- because of the different intepretation of the command if !request. However, you might want to consider makeing hf_zebra_command an FT_UINT8, registered with a value_string, and do something like: if ((command == ZEBRA_REDISTRIBUTE_DEFAULT_ADD) && (!request)) proto_tree_add_uint_format(zebra_tree, hf_zebra_command ...) else if ((command == ZEBRA_REDISTRIBUTE_DEFAULT_DELETE) && (!request)) proto_tree_add_uint_format(zebra_tree, hf_zebra_command ...) else proto_tree_add_uint(zebra_tree, hf_zebra_command ...) That way you get to see your guint8 for your message type, instead of just the string. Also, in the series like this: index = tvb_get_ntohs(tvb, offset); proto_tree_add_uint(tree, hf_zebra_index, NullTVB, offset, 2, index); offset += 2; flags = tvb_get_ntohl(tvb, offset); proto_tree_add_uint(tree, hf_zebra_flags, NullTVB, offset, 4, flags); offset += 4; metric = tvb_get_ntohl(tvb, offset); proto_tree_add_uint(tree, hf_zebra_metric, NullTVB, offset, 4, metric); offset += 4; mtu = tvb_get_ntohl(tvb, offset); proto_tree_add_uint(tree, hf_zebra_mtu, NullTVB, offset, 4, mtu); offset += 4; We can now use proto_tree_add_item() to get the value from the tvbuff directly. It avoids a line of code in your dissector, which is not bad at all. You're creating your tvbuff incorrectly. You're recreating the top-level tvbuff instead of making a new tvbuff which starts at your offset. You should use the example in doc/README.tvbuff: tvbuff_t *tvb; packet_info *pinfo = π tvb = tvb_create_from_top(offset); Then, in all your proto_tree_add*() calls, replace NullTVB with tvb. In the near future I'll change the dissectors that get called via dissector tables to be callable directly with tvbuffs. That is, there will be two handoff tables, one for non-tvbuff dissectors, and another for tvbuff dissectors. The tvbuff that you'll get handed will start at your protocol header's offset --- it's a virtual packet... you only see your data. --gilbert
Powered by MHonArc 2.6.10