Ethereal-dev: Re: [Ethereal-dev] Problems encountered writing frame-tap

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

From: Koen Smets <koen.smets@xxxxxxxxx>
Date: Tue, 2 Nov 2004 16:40:45 +0100
On Tue, 2 Nov 2004 14:16:48 +1100, ronnie sahlberg
<ronniesahlberg@xxxxxxxxx> wrote:
> error_string = register_tap_listener("frame", &the_tapinfo_struct,
>                                       NULL,
>                                       (void*)frame_reset, (void*)frame_packet,
>                                       (void*)frame_draw);
> 
> In the code above   you specify NULL as the filter  and thus tap will
> give you an unfiltered view of the packets.
> Replace this with "foo"  if you only want packets matching "foo".
> 
> Can you please create a patch for the readme files and examples if
> this behaviour was unclear so that others are not bitten by this doc
> bug.

README.tapping clearly states this already (my apologies), I used NULL
because I wanted to synchronise the packets that would be tapped and
displayed, and because *fstring (pointer to a filter string) isn't
know at the time the tap gets registered (and is likely to change
during a simulation process).

> 
> On Tue, 2 Nov 2004 14:14:26 +1100, ronnie sahlberg
> <ronniesahlberg@xxxxxxxxx> wrote:
> > The tap system is by design decoupled from  the display filters
> > applied to the main window.

Maybe I am abusing the tapsystem in a wrong way, but I really don't
know another way for handling changes in display filters, realtime
capturing....

I have tested that tapsystem gets called at the appropriate time (when
the display filter changes and also during realtime capturing), but
because the dfilter flag is set after the frame_packet() is called the
data delivered to the output are the frames corresponding to the
previous display filter.

Question changes to: is there still a way to (at runtime) put a filter
string to the tap? (so tap only packets with the current display
filter.)

> > If you want to push a filtered subset of all packets to the TAP, then
> > you have to specify the appropriate filter string to the call you use
> > when you register the tap listener.
> >
> > display filters on the main window do not affect which packets the tap
> > listener receives,  the tap listener itself controls this.
> >

I haven't sit still and I came up with a solution for the non-realtime
case, using a boolean to determine if its the first time tap gets
called (if true retap). This kind of hackery doesn't work with the
option "update list of packets in realtime". (reason: I think and the
one I try to solve is that frame_draw already gets called after all
know packets are tapped). Suggestions to solve this?



With regards,
Koen

ps: here are my advantages:

typedef struct _frame_tapinfo {
  gboolean first_time; /* first time we need to retap ! (reason:
dfilter flag is set after the first time tap gets called */
} frame_tapinfo_t;

void 
frame_draw(frame_tapinfo_t *tapinfo _U_)
{
  printf("frame_draw(frame_tapinfo_t *tapinfo _U_)\n");

  if (tapinfo->first_time){
    tapinfo->first_time = FALSE;
    retap_packets(&cfile);
    tapinfo->first_time = TRUE;
  }
}

int 
frame_packet(frame_tapinfo_t *tapinfo _U_, packet_info *pinfo,
epan_dissect_t *edt _U_, char *data _U_)
{
  if (!tapinfo->first_time && pinfo->fd->flags.passed_dfilter){
    printf("Frame number: %d\n",pinfo->fd->num);
    // printf("frame_packet(frame_tapinfo_t *tapinfo _U_, packet_info
*pinfo _U_, epan_dissect_t *edt _U_, char *data _U_)\n");
  }
  return 0;
}
-- 
Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe trying
to produce bigger and better idiots. So far, the Universe is winning.
  --Rich Cook--