On Wed, Jun 07, 2000 at 02:52:41PM -0500, Heikki Vatiainen wrote:
>
>
> Here is a preliminary dissector for RFC 2748, The COPS (Common
> Open Policy Service) Protocol. The dissector is done using tvbuffs
> and tries to use the new tvbuff related calls as I understood they
> should be used. I am planning to add code to dissect the COPS object
> contents later, but maybe this could already be used as an example of
> programming with tvbuffs.
Thanks! I'm going to release 0.8.9 tonight; I'll go ahead and include
this dissector, unless you feel it's not ready yet.
> In case someone wants to see if the dissector works, I'm enclosing
> a slightly modified capture file. The Message Integrity Object in
> the very first COPS message has been modified so that the object
> length is now 25 instead of 24. This causes an exception handled by
> tvbuffs.
Nice! :-)
>
> /* Code to actually dissect the packets */
> #if 0
> static void dissect_cops(tvbuff_t *tvb, packet_info *pinfo, proto_tree
> *tree)
> {
> guint8 op_code;
> #else
> static void dissect_cops(const u_char *pd, int o, frame_data *fd,
> proto_tree *tree)
> {
> tvbuff_t *real_tvb, *tvb;
> packet_info *pinfo = π
> guint8 op_code;
> real_tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
> tvb = tvb_new_subset(real_tvb, o, fd->cap_len - o, fd->pkt_len -
> o);
> #endif
I need to document this, but a slightly cleaner solution would be the
one employed in packet-ppp.c in dissect_payload_ppp(). Instead of creating
a new TVBUFF_REAL_DATA, you can create just a TVBUFF_SUBSET because the top-most
tvbuff is provided in the packet_info struct. It will only be there until
all the dissectors are converted to use tvbuffs:
#else
static void dissect_cops(const u_char *pd, int o, frame_data *fd,
proto_tree *tree)
{
tvbuff_t *tvb;
packet_info *pinfo = π
guint8 op_code;
tvb = tvb_new_subset(pinfo->compat_top_tvb, offset, -1, -1);
}
#endif
The -1 arguments let the tvbuff constructor know to use all the bytes
that are available, both for the length and for the reported_length.
Everything else looks great.
--gilbert