tshark/RTP: GUI dependency removed from register_tap_listener_rtpstream. As consequence of it a few functions were moved from ui/rtp_stream to ui/tap-rtp-common.

Change-Id: I9dd0603a9742eb374e71e84d1380083d6c861166
Reviewed-on: https://code.wireshark.org/review/28368
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Jiri Novak 2018-06-20 23:32:56 +02:00 committed by Anders Broman
parent eee4f44e9d
commit db6d8ae80c
6 changed files with 98 additions and 92 deletions

View File

@ -38,14 +38,17 @@
#include "ui/tap-rtp-common.h"
void register_tap_listener_rtp_streams(void);
static void rtp_streams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo);
/* The one and only global rtpstream_tapinfo_t structure for tshark and wireshark.
*/
static rtpstream_tapinfo_t the_tapinfo_struct =
{NULL, NULL, NULL, NULL, 0, NULL, 0, TAP_ANALYSE, NULL, NULL, NULL, FALSE};
{ NULL, rtp_streams_stat_draw_cb, NULL,
NULL, 0, NULL, 0, TAP_ANALYSE, NULL, NULL, NULL, FALSE
};
static void
rtp_streams_stat_draw_cb(void *arg _U_)
rtp_streams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo _U_)
{
GList *list;
rtpstream_info_t *strinfo;
@ -99,20 +102,7 @@ rtp_streams_stat_draw_cb(void *arg _U_)
static void
rtp_streams_stat_init(const char *opt_arg _U_, void *userdata _U_)
{
GString *err_p;
err_p =
register_tap_listener("rtp", &the_tapinfo_struct, NULL, 0,
rtpstream_reset_cb,
rtpstream_packet_cb,
rtp_streams_stat_draw_cb);
if (err_p != NULL)
{
g_string_free(err_p, TRUE);
exit(1);
}
register_tap_listener_rtpstream(&the_tapinfo_struct, NULL, NULL);
}
static stat_tap_ui rtp_streams_stat_ui = {

View File

@ -244,7 +244,7 @@ RtpStreamDialog::RtpStreamDialog(QWidget &parent, CaptureFile &cf) :
tapinfo_.tap_data = this;
tapinfo_.mode = TAP_ANALYSE;
register_tap_listener_rtpstream(&tapinfo_, NULL);
register_tap_listener_rtpstream(&tapinfo_, NULL, show_tap_registration_error);
/* Scan for RTP streams (redissect all packets) */
rtpstream_scan(&tapinfo_, cf.capFile(), NULL);

View File

@ -32,21 +32,14 @@
/****************************************************************************/
/* redraw the output */
static void rtpstream_draw_cb(void *ti_ptr)
/* scan for RTP streams */
void
show_tap_registration_error(GString *error_string)
{
rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)ti_ptr;
/* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
g_signal_emit_by_name(top_level, "signal_rtpstream_update");
*/
if (tapinfo && tapinfo->tap_draw) {
/* RTP_STREAM_DEBUG("streams: %d packets: %d", tapinfo->nstreams, tapinfo->npackets); */
tapinfo->tap_draw(tapinfo);
}
return;
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
}
/****************************************************************************/
/* scan for RTP streams */
void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring)
@ -59,7 +52,7 @@ void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const
was_registered = tapinfo->is_registered;
if (!tapinfo->is_registered)
register_tap_listener_rtpstream(tapinfo, fstring);
register_tap_listener_rtpstream(tapinfo, fstring, show_tap_registration_error);
/* RTP_STREAM_DEBUG("scanning %s, filter: %s", cap_file->filename, fstring); */
tapinfo->mode = TAP_ANALYSE;
@ -97,7 +90,7 @@ gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rt
}
if (!tapinfo->is_registered)
register_tap_listener_rtpstream(tapinfo, NULL);
register_tap_listener_rtpstream(tapinfo, NULL, show_tap_registration_error);
tapinfo->mode = TAP_SAVE;
tapinfo->filter_stream_fwd = stream;
@ -133,7 +126,7 @@ void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstr
was_registered = tapinfo->is_registered;
if (!tapinfo->is_registered)
register_tap_listener_rtpstream(tapinfo, NULL);
register_tap_listener_rtpstream(tapinfo, NULL, show_tap_registration_error);
tapinfo->mode = TAP_MARK;
tapinfo->filter_stream_fwd = stream_fwd;
@ -146,47 +139,6 @@ void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstr
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
/****************************************************************************/
void
remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo)
{
if (tapinfo && tapinfo->is_registered) {
remove_tap_listener(tapinfo);
tapinfo->is_registered = FALSE;
}
}
/****************************************************************************/
void
register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring)
{
GString *error_string;
if (!tapinfo) {
return;
}
if (!tapinfo->is_registered) {
error_string = register_tap_listener("rtp", tapinfo,
fstring, 0, rtpstream_reset_cb, rtpstream_packet_cb,
rtpstream_draw_cb);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
tapinfo->is_registered = TRUE;
}
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*

View File

@ -75,6 +75,7 @@ typedef struct _rtpstream_tapinfo rtpstream_tapinfo_t;
typedef void (*rtpstream_tap_reset_cb)(rtpstream_tapinfo_t *tapinfo);
typedef void (*rtpstream_tap_draw_cb)(rtpstream_tapinfo_t *tapinfo);
typedef void (*tap_mark_packet_cb)(rtpstream_tapinfo_t *tapinfo, frame_data *fd);
typedef void (*rtpstream_tap_error_cb)(GString *error_string);
/* structure that holds the information about all detected streams */
/** struct holding all information of the tap */
@ -107,25 +108,7 @@ struct _rtpstream_tapinfo {
/****************************************************************************/
/* INTERFACE */
/**
* Registers the rtp_streams tap listener (if not already done).
* From that point on, the RTP streams list will be updated with every redissection.
* This function is also the entry point for the initialization routine of the tap system.
* So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
* If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
*/
void register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring);
/**
* Removes the rtp_streams tap listener (if not already done)
* From that point on, the RTP streams list won't be updated any more.
*/
void remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo);
/**
* Cleans up memory of rtp streams tap.
*/
void rtpstream_reset(rtpstream_tapinfo_t *tapinfo);
void show_tap_registration_error(GString *error_string);
/**
* Scans all packets for RTP streams and updates the RTP streams list.

View File

@ -110,6 +110,64 @@ void rtpstream_reset_cb(void *arg)
rtpstream_reset(ti);
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
/****************************************************************************/
/* redraw the output */
static void rtpstream_draw_cb(void *ti_ptr)
{
rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)ti_ptr;
/* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
g_signal_emit_by_name(top_level, "signal_rtpstream_update");
*/
if (tapinfo && tapinfo->tap_draw) {
/* RTP_STREAM_DEBUG("streams: %d packets: %d", tapinfo->nstreams, tapinfo->npackets); */
tapinfo->tap_draw(tapinfo);
}
return;
}
/****************************************************************************/
void
remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo)
{
if (tapinfo && tapinfo->is_registered) {
remove_tap_listener(tapinfo);
tapinfo->is_registered = FALSE;
}
}
/****************************************************************************/
void
register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring, rtpstream_tap_error_cb tap_error)
{
GString *error_string;
if (!tapinfo) {
return;
}
if (!tapinfo->is_registered) {
error_string = register_tap_listener("rtp", tapinfo,
fstring, 0, rtpstream_reset_cb, rtpstream_packet_cb,
rtpstream_draw_cb);
if (error_string != NULL) {
if (tap_error) {
tap_error(error_string);
}
g_string_free(error_string, TRUE);
exit(1);
}
tapinfo->is_registered = TRUE;
}
}
/*
* rtpdump file format
*

View File

@ -84,6 +84,29 @@ gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb);
*/
gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b);
/****************************************************************************/
/* INTERFACE */
/**
* Registers the rtp_streams tap listener (if not already done).
* From that point on, the RTP streams list will be updated with every redissection.
* This function is also the entry point for the initialization routine of the tap system.
* So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
* If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
*/
void register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring, rtpstream_tap_error_cb tap_error);
/**
* Removes the rtp_streams tap listener (if not already done)
* From that point on, the RTP streams list won't be updated any more.
*/
void remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo);
/**
* Cleans up memory of rtp streams tap.
*/
void rtpstream_reset(rtpstream_tapinfo_t *tapinfo);
void rtpstream_reset_cb(void*);
void rtp_write_header(rtpstream_info_t*, FILE*);
int rtpstream_packet_cb(void*, packet_info*, epan_dissect_t *, const void *);