aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-09-12 10:21:59 -0400
committerA Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2022-09-14 00:03:07 +0000
commit2762c64010c0eba508c586614fe5898aa52cc4a9 (patch)
tree2ddbd5f4032566701a68dc672509094c53b31f97
parent56ea9816d9bb439e62eb77fa20e7220783404b83 (diff)
follow: Have followers register their stream count function
Instead of having the UI have to know about each type of follow stream, and how to retrieve its total number of streams, have each follow type register a function that returns the total number of stream. (The function can be NULL, for protocols like SIP that do not use this.) This gets us closer to making follow stream registration generic.
-rw-r--r--epan/dissectors/packet-dccp.c2
-rw-r--r--epan/dissectors/packet-http.c3
-rw-r--r--epan/dissectors/packet-http2.c2
-rw-r--r--epan/dissectors/packet-quic.c2
-rw-r--r--epan/dissectors/packet-sip.c2
-rw-r--r--epan/dissectors/packet-tcp.c2
-rw-r--r--epan/dissectors/packet-tls.c2
-rw-r--r--epan/dissectors/packet-udp.c2
-rw-r--r--epan/follow.c9
-rw-r--r--epan/follow.h11
-rw-r--r--packaging/debian/libwireshark0.symbols1
-rw-r--r--ui/qt/follow_stream_dialog.cpp80
12 files changed, 42 insertions, 76 deletions
diff --git a/epan/dissectors/packet-dccp.c b/epan/dissectors/packet-dccp.c
index d077804ea5..1d17cbdb45 100644
--- a/epan/dissectors/packet-dccp.c
+++ b/epan/dissectors/packet-dccp.c
@@ -1733,7 +1733,7 @@ proto_register_dccp(void)
register_conversation_table(proto_dccp, FALSE, dccpip_conversation_packet, dccpip_endpoint_packet);
register_conversation_filter("dccp", "DCCP", dccp_filter_valid, dccp_build_filter);
register_follow_stream(proto_dccp, "dccp_follow", dccp_follow_conv_filter, dccp_follow_index_filter, dccp_follow_address_filter,
- dccp_port_to_display, follow_tvb_tap_listener);
+ dccp_port_to_display, follow_tvb_tap_listener, get_dccp_stream_count);
register_init_routine(dccp_init);
}
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 697a94f01e..1c9d5d5610 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -4436,7 +4436,8 @@ proto_register_http(void)
credentials_tap = register_tap("credentials"); /* credentials tap */
register_follow_stream(proto_http, "http_follow", tcp_follow_conv_filter, tcp_follow_index_filter, tcp_follow_address_filter,
- tcp_port_to_display, follow_tvb_tap_listener);
+ tcp_port_to_display, follow_tvb_tap_listener,
+ get_tcp_stream_count);
http_eo_tap = register_export_object(proto_http, http_eo_packet, NULL);
/* compile patterns, exluding "/" */
diff --git a/epan/dissectors/packet-http2.c b/epan/dissectors/packet-http2.c
index e903fa8e76..81ec3f89cb 100644
--- a/epan/dissectors/packet-http2.c
+++ b/epan/dissectors/packet-http2.c
@@ -4603,7 +4603,7 @@ proto_register_http2(void)
http2_follow_tap = register_tap("http2_follow");
register_follow_stream(proto_http2, "http2_follow", http2_follow_conv_filter, http2_follow_index_filter, tcp_follow_address_filter,
- tcp_port_to_display, follow_http2_tap_listener);
+ tcp_port_to_display, follow_http2_tap_listener, get_tcp_stream_count);
}
static void http2_stats_tree_init(stats_tree* st)
diff --git a/epan/dissectors/packet-quic.c b/epan/dissectors/packet-quic.c
index 3481ddf135..fadb62eddb 100644
--- a/epan/dissectors/packet-quic.c
+++ b/epan/dissectors/packet-quic.c
@@ -5377,7 +5377,7 @@ proto_register_quic(void)
register_cleanup_routine(quic_cleanup);
register_follow_stream(proto_quic, "quic_follow", quic_follow_conv_filter, quic_follow_index_filter, quic_follow_address_filter,
- udp_port_to_display, follow_quic_tap_listener);
+ udp_port_to_display, follow_quic_tap_listener, get_quic_connections_count);
// TODO implement custom reassembly functions that uses the QUIC Connection
// ID instead of address and port numbers.
diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c
index 2325e68be1..b52023bfd9 100644
--- a/epan/dissectors/packet-sip.c
+++ b/epan/dissectors/packet-sip.c
@@ -7755,7 +7755,7 @@ void proto_register_sip(void)
ws_mempbrk_compile(&pbrk_via_param_end, "\t;, ");
register_follow_stream(proto_sip, "sip_follow", sip_follow_conv_filter, sip_follow_index_filter, sip_follow_address_filter,
- udp_port_to_display, follow_tvb_tap_listener);
+ udp_port_to_display, follow_tvb_tap_listener, NULL);
}
void
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c
index 0ffa8f0491..d1334137ff 100644
--- a/epan/dissectors/packet-tcp.c
+++ b/epan/dissectors/packet-tcp.c
@@ -9633,7 +9633,7 @@ proto_register_tcp(void)
register_conversation_table(proto_mptcp, FALSE, mptcpip_conversation_packet, tcpip_endpoint_packet);
register_follow_stream(proto_tcp, "tcp_follow", tcp_follow_conv_filter, tcp_follow_index_filter, tcp_follow_address_filter,
- tcp_port_to_display, follow_tcp_tap_listener);
+ tcp_port_to_display, follow_tcp_tap_listener, get_tcp_stream_count);
}
void
diff --git a/epan/dissectors/packet-tls.c b/epan/dissectors/packet-tls.c
index e292c548be..03aba7601c 100644
--- a/epan/dissectors/packet-tls.c
+++ b/epan/dissectors/packet-tls.c
@@ -4597,7 +4597,7 @@ proto_register_tls(void)
"tls", tls_tap);
register_follow_stream(proto_tls, "tls", tcp_follow_conv_filter, tcp_follow_index_filter, tcp_follow_address_filter,
- tcp_port_to_display, ssl_follow_tap_listener);
+ tcp_port_to_display, ssl_follow_tap_listener, get_tcp_stream_count);
secrets_register_type(SECRETS_TYPE_TLS, tls_secrets_block_callback);
}
diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c
index 987a8929e9..7a07d5fc5b 100644
--- a/epan/dissectors/packet-udp.c
+++ b/epan/dissectors/packet-udp.c
@@ -1476,7 +1476,7 @@ proto_register_udp(void)
register_conversation_table(proto_udp, FALSE, udpip_conversation_packet, udpip_endpoint_packet);
register_conversation_filter("udp", "UDP", udp_filter_valid, udp_build_filter);
register_follow_stream(proto_udp, "udp_follow", udp_follow_conv_filter, udp_follow_index_filter, udp_follow_address_filter,
- udp_port_to_display, follow_tvb_tap_listener);
+ udp_port_to_display, follow_tvb_tap_listener, get_udp_stream_count);
register_init_routine(udp_init);
}
diff --git a/epan/follow.c b/epan/follow.c
index ebad23b26d..0b1325e01c 100644
--- a/epan/follow.c
+++ b/epan/follow.c
@@ -28,13 +28,15 @@ struct register_follow {
follow_address_filter_func address_filter; /* generate address filter to follow */
follow_port_to_display_func port_to_display; /* port to name resolution for follow type */
tap_packet_cb tap_handler; /* tap listener handler */
+ follow_stream_count_func stream_count; /* maximum stream count, used for UI */
};
static wmem_tree_t *registered_followers = NULL;
void register_follow_stream(const int proto_id, const char* tap_listener,
follow_conv_filter_func conv_filter, follow_index_filter_func index_filter, follow_address_filter_func address_filter,
- follow_port_to_display_func port_to_display, tap_packet_cb tap_handler)
+ follow_port_to_display_func port_to_display, tap_packet_cb tap_handler,
+ follow_stream_count_func stream_count)
{
register_follow_t *follower;
DISSECTOR_ASSERT(tap_listener);
@@ -53,6 +55,7 @@ void register_follow_stream(const int proto_id, const char* tap_listener,
follower->address_filter = address_filter;
follower->port_to_display = port_to_display;
follower->tap_handler = tap_handler;
+ follower->stream_count = stream_count;
if (registered_followers == NULL)
registered_followers = wmem_tree_new(wmem_epan_scope());
@@ -101,6 +104,10 @@ tap_packet_cb get_follow_tap_handler(register_follow_t* follower)
return follower->tap_handler;
}
+follow_stream_count_func get_follow_stream_count_func(register_follow_t* follower)
+{
+ return follower->stream_count;
+}
register_follow_t* get_follow_by_name(const char* proto_short_name)
{
diff --git a/epan/follow.h b/epan/follow.h
index 3a8ab0e61c..474f1e52c6 100644
--- a/epan/follow.h
+++ b/epan/follow.h
@@ -110,11 +110,13 @@ typedef gchar* (*follow_conv_filter_func)(epan_dissect_t *edt, packet_info *pinf
typedef gchar* (*follow_index_filter_func)(guint stream, guint sub_stream);
typedef gchar* (*follow_address_filter_func)(address* src_addr, address* dst_addr, int src_port, int dst_port);
typedef gchar* (*follow_port_to_display_func)(wmem_allocator_t *allocator, guint port);
+typedef guint32 (*follow_stream_count_func)(void);
WS_DLL_PUBLIC
void register_follow_stream(const int proto_id, const char* tap_listener,
follow_conv_filter_func conv_filter, follow_index_filter_func index_filter, follow_address_filter_func address_filter,
- follow_port_to_display_func port_to_display, tap_packet_cb tap_handler);
+ follow_port_to_display_func port_to_display, tap_packet_cb tap_handler,
+ follow_stream_count_func stream_count);
/** Get protocol ID from registered follower
*
@@ -172,6 +174,13 @@ WS_DLL_PUBLIC follow_port_to_display_func get_follow_port_to_display(register_fo
*/
WS_DLL_PUBLIC tap_packet_cb get_follow_tap_handler(register_follow_t* follower);
+/** Provide function that gets the total number of streams for a registered follower
+ * The function can be NULL if the follower does not count the number of streams
+ *
+ * @param follower [in] Registered follower
+ * @return A stream count handler
+ */
+WS_DLL_PUBLIC follow_stream_count_func get_follow_stream_count_func(register_follow_t* follower);
/** Tap function handler when dissector's tap provides follow data as a tvb.
* Used by TCP, UDP and HTTP followers
diff --git a/packaging/debian/libwireshark0.symbols b/packaging/debian/libwireshark0.symbols
index 9c83091c61..5b0f55085b 100644
--- a/packaging/debian/libwireshark0.symbols
+++ b/packaging/debian/libwireshark0.symbols
@@ -856,6 +856,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
get_follow_index_func@Base 2.1.0
get_follow_port_to_display@Base 2.1.0
get_follow_proto_id@Base 2.1.0
+ get_follow_stream_count_func@Base 4.1.0
get_follow_tap_handler@Base 2.1.0
get_follow_tap_string@Base 2.1.0
get_export_pdu_tap_list@Base 1.99.0
diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp
index 318c5cff2b..102eafdfe6 100644
--- a/ui/qt/follow_stream_dialog.cpp
+++ b/ui/qt/follow_stream_dialog.cpp
@@ -15,9 +15,6 @@
#include "frame_tvbuff.h"
#include "epan/follow.h"
-#include "epan/dissectors/packet-tcp.h"
-#include "epan/dissectors/packet-udp.h"
-#include "epan/dissectors/packet-dccp.h"
#include "epan/dissectors/packet-http2.h"
#include "epan/dissectors/packet-quic.h"
#include "epan/prefs.h"
@@ -434,6 +431,10 @@ void FollowStreamDialog::on_streamNumberSpinBox_valueChanged(int stream_num)
}
sub_stream_num = static_cast<gint>(sub_stream_num_new);
} else {
+ /* XXX: For HTTP and TLS, we use the TCP stream index, and really should
+ * return false if the TCP stream doesn't have HTTP or TLS. (Or we could
+ * switch to having separate HTTP and TLS stream numbers.)
+ */
ok = true;
}
@@ -948,6 +949,8 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
QString client_to_server_string;
QString both_directions_string;
gboolean is_follower = FALSE;
+ int stream_count;
+ follow_stream_count_func stream_count_func = NULL;
resetStream();
@@ -971,12 +974,6 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
}
}
- if (follow_type_ == FOLLOW_TLS || follow_type_ == FOLLOW_HTTP)
- {
- /* we got tls/http so we can follow */
- removeStreamControls();
- }
-
follow_reset_stream(&follow_info_);
/* Create a new filter that matches all packets in the TCP stream,
@@ -1032,54 +1029,24 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
ui->subStreamNumberSpinBox->setVisible(false);
ui->subStreamNumberLabel->setVisible(false);
- switch (follow_type_)
- {
- case FOLLOW_TCP:
- {
- int stream_count = get_tcp_stream_count();
- ui->streamNumberSpinBox->blockSignals(true);
- ui->streamNumberSpinBox->setMaximum(stream_count-1);
- ui->streamNumberSpinBox->setValue(stream_num);
- ui->streamNumberSpinBox->blockSignals(false);
- ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count));
- ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip());
+ stream_count_func = get_follow_stream_count_func(follower_);
- break;
- }
- case FOLLOW_UDP:
- {
- int stream_count = get_udp_stream_count();
+ if (stream_count_func == NULL) {
+ removeStreamControls();
+ } else {
+ stream_count = stream_count_func();
ui->streamNumberSpinBox->blockSignals(true);
ui->streamNumberSpinBox->setMaximum(stream_count-1);
ui->streamNumberSpinBox->setValue(stream_num);
ui->streamNumberSpinBox->blockSignals(false);
ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count));
ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip());
-
- break;
}
- case FOLLOW_DCCP:
- {
- int stream_count = get_dccp_stream_count();
- ui->streamNumberSpinBox->blockSignals(true);
- ui->streamNumberSpinBox->setMaximum(stream_count-1);
- ui->streamNumberSpinBox->setValue(stream_num);
- ui->streamNumberSpinBox->blockSignals(false);
- ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count));
- ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip());
- break;
- }
+ switch (follow_type_)
+ {
case FOLLOW_HTTP2:
{
- int stream_count = get_tcp_stream_count();
- ui->streamNumberSpinBox->blockSignals(true);
- ui->streamNumberSpinBox->setMaximum(stream_count-1);
- ui->streamNumberSpinBox->setValue(stream_num);
- ui->streamNumberSpinBox->blockSignals(false);
- ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count));
- ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip());
-
guint substream_max_id = 0;
http2_get_stream_id_le(static_cast<guint>(stream_num), G_MAXINT32, &substream_max_id);
stream_count = static_cast<gint>(substream_max_id);
@@ -1097,11 +1064,6 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
}
case FOLLOW_QUIC:
{
- int stream_count = get_quic_connections_count();
- ui->streamNumberSpinBox->blockSignals(true);
- ui->streamNumberSpinBox->setMaximum(stream_count-1);
- ui->streamNumberSpinBox->setValue(stream_num);
- ui->streamNumberSpinBox->blockSignals(false);
ui->streamNumberSpinBox->setToolTip(tr("Total number of QUIC connections: %Ln", "", stream_count));
ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip());
@@ -1120,23 +1082,9 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
break;
}
- case FOLLOW_TLS:
- case FOLLOW_HTTP:
+ default:
/* No extra handling */
break;
- case FOLLOW_SIP:
- {
- /* There are no more streams */
- ui->streamNumberSpinBox->setEnabled(false);
- ui->streamNumberSpinBox->blockSignals(true);
- ui->streamNumberSpinBox->setMaximum(0);
- ui->streamNumberSpinBox->setValue(0);
- ui->streamNumberSpinBox->blockSignals(false);
- ui->streamNumberSpinBox->setToolTip(tr("No streams"));
- ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip());
-
- break;
- }
}
beginRetapPackets();