Ethereal-dev: Re: [Ethereal-dev] Dissector of the RTPS protocol for the Ethereal

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

From: Guy Harris <gharris@xxxxxxxxx>
Date: Sat, 17 Apr 2004 15:11:51 -0700
On Thu, Apr 15, 2004 at 12:04:22PM +0200, Luká¹ Pokorný wrote:
> I've sent you new dissection module for RTPS (Real-Time
> Publish-Subscribe) communication protocol.

Checked in.

This code:

    //read value in littlendian format
    next_submsg  = tvb_get_guint8(tvb, (offset+2))+
                   tvb_get_guint8(tvb, (offset+3))*0x100;
    #if WORDS_BIGENDIAN
       bswap_16(next_submsg);
    #endif

would probably be best done as

    next_submsg  = tvb_get_letohs(tvb, offset+2);

I.e., use Ethereal's native routines to fetch little-endian values. 
(The comment should also be a C comment, not a C++ comment, as not all C
compilers allow C++ comments; I'll change the C++ comments to C
comments.)

Similarly, "get_guint16()" should probably just do

  guint16   value;

  if (e_bit)
    value = tvb_get_ntohs(tvb, offset);
  else
    value = tvb_get_letohs(tvb, offset);

Also, LITTLE_ENDIAN and BIG_ENDIAN aren't defined by Ethereal itself -
and not all platforms will necessarily define them for you - so "e_bit"
should probably be converted to a gboolean "little_endian".

I've checked in changes to do those things.