diff options
Diffstat (limited to 'ui/gtk')
-rw-r--r-- | ui/gtk/follow_http.c | 10 | ||||
-rw-r--r-- | ui/gtk/follow_ssl.c | 11 | ||||
-rw-r--r-- | ui/gtk/follow_stream.c | 32 | ||||
-rw-r--r-- | ui/gtk/follow_stream.h | 15 | ||||
-rw-r--r-- | ui/gtk/follow_tcp.c | 10 | ||||
-rw-r--r-- | ui/gtk/follow_udp.c | 10 |
6 files changed, 47 insertions, 41 deletions
diff --git a/ui/gtk/follow_http.c b/ui/gtk/follow_http.c index dced654025..5362bfc4de 100644 --- a/ui/gtk/follow_http.c +++ b/ui/gtk/follow_http.c @@ -40,6 +40,9 @@ #include "ui/gtk/main.h" #include "ui/gtk/follow_http.h" +static frs_return_t +follow_read_http_stream(follow_info_t *follow_info, follow_print_line_func follow_print, void *arg); + static gboolean http_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data) @@ -103,6 +106,7 @@ follow_http_stream_cb(GtkWidget *w _U_, gpointer data _U_) follow_info = g_new0(follow_info_t, 1); follow_info->follow_type = FOLLOW_HTTP; + follow_info->read_stream = follow_read_http_stream; /* Create a new filter that matches all packets in the HTTP stream, and set the display filter entry accordingly */ @@ -248,9 +252,9 @@ follow_http_stream_cb(GtkWidget *w _U_, gpointer data _U_) * This might or might not be the reason why C arrays display * correctly but get extra blank lines very other line when printed. */ -frs_return_t +static frs_return_t follow_read_http_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + follow_print_line_func follow_print, void *arg) { guint32 global_client_pos = 0, global_server_pos = 0; @@ -283,7 +287,7 @@ follow_read_http_stream(follow_info_t *follow_info, buffer = (char *)g_memdup(follow_record->data->data, follow_record->data->len); - frs_return = follow_show(follow_info, print_line_fcn_p, + frs_return = follow_show(follow_info, follow_print, buffer, follow_record->data->len, follow_record->is_server, arg, diff --git a/ui/gtk/follow_ssl.c b/ui/gtk/follow_ssl.c index 7c30b94f41..c0235dc40e 100644 --- a/ui/gtk/follow_ssl.c +++ b/ui/gtk/follow_ssl.c @@ -61,6 +61,10 @@ #include <epan/dissectors/packet-ssl-utils.h> #endif +static frs_return_t +follow_read_ssl_stream(follow_info_t *follow_info, follow_print_line_func follow_print, void *arg); + + static gboolean ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *ssl) { @@ -156,6 +160,7 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) follow_info = g_new0(follow_info_t, 1); follow_info->follow_type = FOLLOW_SSL; + follow_info->read_stream = follow_read_ssl_stream; /* Create a new filter that matches all packets in the SSL stream, and set the display filter entry accordingly */ @@ -300,9 +305,9 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) * This might or might not be the reason why C arrays display * correctly but get extra blank lines very other line when printed. */ -frs_return_t +static frs_return_t follow_read_ssl_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + follow_print_line_func follow_print, void *arg) { guint32 global_client_pos = 0, global_server_pos = 0; @@ -330,7 +335,7 @@ follow_read_ssl_stream(follow_info_t *follow_info, size_t nchars = rec->data.data_len; gchar *buffer = (gchar *)g_memdup(rec->data.data, (guint) nchars); - frs_return = follow_show(follow_info, print_line_fcn_p, buffer, nchars, + frs_return = follow_show(follow_info, follow_print, buffer, nchars, rec->is_from_server, arg, global_pos, &server_packet_count, &client_packet_count); g_free(buffer); diff --git a/ui/gtk/follow_stream.c b/ui/gtk/follow_stream.c index 4a8d4e7b91..79ae6c7c09 100644 --- a/ui/gtk/follow_stream.c +++ b/ui/gtk/follow_stream.c @@ -76,24 +76,12 @@ follow_read_stream(follow_info_t *follow_info, gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), void *arg) { - switch(follow_info->follow_type) { - - case FOLLOW_TCP : - return follow_read_tcp_stream(follow_info, print_line_fcn_p, arg); - - case FOLLOW_UDP : - return follow_read_udp_stream(follow_info, print_line_fcn_p, arg); - - case FOLLOW_SSL : - return follow_read_ssl_stream(follow_info, print_line_fcn_p, arg); - - case FOLLOW_HTTP : - return follow_read_http_stream(follow_info, print_line_fcn_p, arg); - - default : + if (follow_info->read_stream == NULL) { g_assert_not_reached(); return (frs_return_t)0; } + + return follow_info->read_stream(follow_info, print_line_fcn_p, arg); } gboolean @@ -903,7 +891,7 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_) frs_return_t follow_show(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + follow_print_line_func follow_print, char *buffer, size_t nchars, gboolean is_from_server, void *arg, guint32 *global_pos, guint32 *server_packet_count, guint32 *client_packet_count) @@ -917,7 +905,7 @@ follow_show(follow_info_t *follow_info, case SHOW_EBCDIC: /* If our native arch is ASCII, call: */ EBCDIC_to_ASCII(buffer, (guint) nchars); - if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) + if (!follow_print(buffer, nchars, is_from_server, arg)) return FRS_PRINT_ERROR; break; @@ -925,7 +913,7 @@ follow_show(follow_info_t *follow_info, /* If our native arch is EBCDIC, call: * ASCII_TO_EBCDIC(buffer, nchars); */ - if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) + if (!follow_print(buffer, nchars, is_from_server, arg)) return FRS_PRINT_ERROR; break; @@ -933,7 +921,7 @@ follow_show(follow_info_t *follow_info, /* Don't translate, no matter what the native arch * is. */ - if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) + if (!follow_print(buffer, nchars, is_from_server, arg)) return FRS_PRINT_ERROR; break; @@ -980,7 +968,7 @@ follow_show(follow_info_t *follow_info, (*global_pos) += i; *cur++ = '\n'; *cur = 0; - if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_from_server, arg)) + if (!follow_print(hexbuf, strlen(hexbuf), is_from_server, arg)) return FRS_PRINT_ERROR; } break; @@ -990,7 +978,7 @@ follow_show(follow_info_t *follow_info, g_snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = {\n", is_from_server ? 1 : 0, is_from_server ? (*server_packet_count)++ : (*client_packet_count)++); - if (!(*print_line_fcn_p) (initbuf, strlen(initbuf), is_from_server, arg)) + if (!follow_print(initbuf, strlen(initbuf), is_from_server, arg)) return FRS_PRINT_ERROR; while (current_pos < nchars) { @@ -1022,7 +1010,7 @@ follow_show(follow_info_t *follow_info, (*global_pos) += i; hexbuf[cur++] = '\n'; hexbuf[cur] = 0; - if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_from_server, arg)) + if (!follow_print(hexbuf, strlen(hexbuf), is_from_server, arg)) return FRS_PRINT_ERROR; } break; diff --git a/ui/gtk/follow_stream.h b/ui/gtk/follow_stream.h index df8c77da46..cb5252b612 100644 --- a/ui/gtk/follow_stream.h +++ b/ui/gtk/follow_stream.h @@ -27,7 +27,12 @@ #include <gtk/gtk.h> #include <ui/follow.h> -typedef struct { +struct _follow_info; + +typedef gboolean (*follow_print_line_func)(char *, size_t, gboolean, void *); +typedef frs_return_t (*follow_read_stream_func)(struct _follow_info *follow_info, follow_print_line_func follow_print, void *arg); + +typedef struct _follow_info { follow_type_t follow_type; show_stream_t show_stream; show_type_t show_type; @@ -47,6 +52,7 @@ typedef struct { guint bytes_written[2]; /* Index with FROM_CLIENT or FROM_SERVER for readability. */ guint client_port; address client_ip; + follow_read_stream_func read_stream; } follow_info_t; #define E_FOLLOW_INFO_KEY "follow_info_key" @@ -62,7 +68,7 @@ void follow_stream(const gchar *title, follow_info_t *follow_info, gchar *server_to_client_string, gchar *client_to_server_string); frs_return_t follow_show(follow_info_t *follow_info, - gboolean (*print_line)(char *, size_t, gboolean, void *), + follow_print_line_func follow_print, char *buffer, size_t nchars, gboolean is_server, void *arg, guint32 *global_pos, guint32 *server_packet_count, @@ -70,11 +76,6 @@ frs_return_t follow_show(follow_info_t *follow_info, gboolean follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_server, void *arg); -frs_return_t follow_read_http_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); -frs_return_t follow_read_tcp_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); -frs_return_t follow_read_udp_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); -frs_return_t follow_read_ssl_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); - #endif /* __FOLLOW_STREAM_H__ */ /* diff --git a/ui/gtk/follow_tcp.c b/ui/gtk/follow_tcp.c index 111b5de0f1..c8683c0f62 100644 --- a/ui/gtk/follow_tcp.c +++ b/ui/gtk/follow_tcp.c @@ -56,6 +56,9 @@ #include "ui/gtk/follow_stream.h" #include "ws_symbol_export.h" +static frs_return_t +follow_read_tcp_stream(follow_info_t *follow_info, follow_print_line_func follow_print, void *arg); + /* With MSVC and a libwireshark.dll, we need a special declaration. */ WS_DLL_PUBLIC FILE *data_out_file; @@ -108,6 +111,7 @@ follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_) follow_info = g_new0(follow_info_t, 1); follow_info->follow_type = FOLLOW_TCP; + follow_info->read_stream = follow_read_tcp_stream; /* Create a new filter that matches all packets in the TCP stream, and set the display filter entry accordingly */ @@ -328,9 +332,9 @@ follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_) * This might or might not be the reason why C arrays display * correctly but get extra blank lines very other line when printed. */ -frs_return_t +static frs_return_t follow_read_tcp_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + follow_print_line_func follow_print, void *arg) { tcp_stream_chunk sc; @@ -401,7 +405,7 @@ follow_read_tcp_stream(follow_info_t *follow_info, bytes_read += nchars; if (!skip) { - frs_return = follow_show(follow_info, print_line_fcn_p, buffer, + frs_return = follow_show(follow_info, follow_print, buffer, nchars, is_server, arg, global_pos, &server_packet_count, &client_packet_count); diff --git a/ui/gtk/follow_udp.c b/ui/gtk/follow_udp.c index 960fb2a662..968fa5aeec 100644 --- a/ui/gtk/follow_udp.c +++ b/ui/gtk/follow_udp.c @@ -40,6 +40,9 @@ #include "ui/gtk/main.h" #include "ui/gtk/follow_udp.h" +static frs_return_t +follow_read_udp_stream(follow_info_t *follow_info, follow_print_line_func follow_print, void *arg); + static gboolean udp_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data) @@ -103,6 +106,7 @@ follow_udp_stream_cb(GtkWidget *w _U_, gpointer data _U_) follow_info = g_new0(follow_info_t, 1); follow_info->follow_type = FOLLOW_UDP; + follow_info->read_stream = follow_read_udp_stream; /* Create a new filter that matches all packets in the UDP stream, and set the display filter entry accordingly */ @@ -248,9 +252,9 @@ follow_udp_stream_cb(GtkWidget *w _U_, gpointer data _U_) * This might or might not be the reason why C arrays display * correctly but get extra blank lines very other line when printed. */ -frs_return_t +static frs_return_t follow_read_udp_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + follow_print_line_func follow_print, void *arg) { guint32 global_client_pos = 0, global_server_pos = 0; @@ -283,7 +287,7 @@ follow_read_udp_stream(follow_info_t *follow_info, buffer = (char *)g_memdup(follow_record->data->data, follow_record->data->len); - frs_return = follow_show(follow_info, print_line_fcn_p, + frs_return = follow_show(follow_info, follow_print, buffer, follow_record->data->len, follow_record->is_server, arg, |