Problem solved !!!
Maybe not the cleanest solution, but your remark on filter string did the trick:
(if ethereal is quiting, still one final tap is registered (reason:
frame_reset is called one final time) Hopefully that doesn't create a
memory leak, but for now I take the risc, until somebody proposes a
better solution.
For others who encouter the same problem in the future (hopefully they
don't), here's my solution:
static void
frame_reset(frame_tapinfo_t *tapinfo _U_)
{
printf("frame_reset(frame_tapinfo_t *tapinfo _U_)\n");
/* re-register tap : with dfilter extracted from main_display_filter_widget */
frame_init_tap(NULL);
}
static void
frame_init_tap(char *optarg _U_)
{
printf("frame_init_tap(char *optarg _U_)\n");
char* filter;
filter = (char*)gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
printf("$$$ filter: %s\n", filter);
if(the_tapinfo_struct.is_registered){
remove_tap_listener_frame();
the_tapinfo_struct.is_registered = FALSE;
}
GString* error_string = register_tap_listener("frame",
&the_tapinfo_struct,
filter,
(void*)frame_reset,
(void*)frame_packet,
(void*)frame_draw);
if(error_string){
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
g_string_free(error_string, TRUE);
return;
}
the_tapinfo_struct.is_registered = TRUE;
}
void
register_tap_listener_frame(void)
{
printf("register_tap_listener_frame(void)\n");
GString *error_string;
register_ethereal_tap("frame", frame_init_tap);
if(!the_tapinfo_struct.is_registered){
error_string = register_tap_listener("frame", &the_tapinfo_struct,
NULL,
(void*)frame_reset, (void*)frame_packet, (void*)frame_draw);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
error_string->str);
g_string_free(error_string, TRUE);
return;
}
the_tapinfo_struct.is_registered = TRUE;
}
register_tap_menu_item("FRAME-TAP...", REGISTER_TAP_GROUP_NONE,
gtk_frame_cb, NULL, NULL, NULL);
}
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.
--
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--