From f4167c32e0f8d93c369b4641c4caf6d172a64c24 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 1 Mar 2019 15:20:22 +0100 Subject: [PATCH] Support unsigned stream identifiers for Follow Stream tcp.stream and udp.stream are already unsigned identifiers. An upcoming http2.hashed_stream identifier can exercise the full unsigned 32-bit number space, so be sure not to treat the stream identifier as signed integer. Change-Id: Ic5d398b2bda7eba7555e385ef3fcd44b490f78c9 Reviewed-on: https://code.wireshark.org/review/32287 Petri-Dish: Peter Wu Reviewed-by: Alexander Gryanko Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte --- epan/dissectors/packet-tcp.c | 10 +++++----- epan/dissectors/packet-tcp.h | 6 +++--- epan/dissectors/packet-udp.c | 10 +++++----- epan/follow.h | 4 ++-- ui/qt/conversation_dialog.cpp | 2 +- ui/qt/conversation_dialog.h | 2 +- ui/qt/follow_stream_dialog.cpp | 2 +- ui/qt/follow_stream_dialog.h | 2 +- ui/qt/main_window.h | 3 ++- ui/qt/main_window_slots.cpp | 22 +++++++++++++--------- 10 files changed, 34 insertions(+), 29 deletions(-) diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 8c7cc4c7a2..f6a66006fd 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -900,7 +900,7 @@ tcp_seq_analysis_packet( void *ptr, packet_info *pinfo, epan_dissect_t *edt _U_, } -gchar* tcp_follow_conv_filter(packet_info* pinfo, int* stream) +gchar *tcp_follow_conv_filter(packet_info *pinfo, guint *stream) { conversation_t *conv; struct tcp_analysis *tcpd; @@ -915,18 +915,18 @@ gchar* tcp_follow_conv_filter(packet_info* pinfo, int* stream) return NULL; *stream = tcpd->stream; - return g_strdup_printf("tcp.stream eq %d", tcpd->stream); + return g_strdup_printf("tcp.stream eq %u", tcpd->stream); } return NULL; } -gchar* tcp_follow_index_filter(int stream) +gchar *tcp_follow_index_filter(guint stream) { - return g_strdup_printf("tcp.stream eq %d", stream); + return g_strdup_printf("tcp.stream eq %u", stream); } -gchar* tcp_follow_address_filter(address* src_addr, address* dst_addr, int src_port, int dst_port) +gchar *tcp_follow_address_filter(address *src_addr, address *dst_addr, int src_port, int dst_port) { const gchar *ip_version = src_addr->type == AT_IPv6 ? "v6" : ""; gchar src_addr_str[WS_INET6_ADDRSTRLEN]; diff --git a/epan/dissectors/packet-tcp.h b/epan/dissectors/packet-tcp.h index a01b175cb0..d46020f4cb 100644 --- a/epan/dissectors/packet-tcp.h +++ b/epan/dissectors/packet-tcp.h @@ -508,9 +508,9 @@ WS_DLL_PUBLIC guint32 get_tcp_stream_count(void); WS_DLL_PUBLIC guint32 get_mptcp_stream_count(void); /* Follow Stream functionality shared with HTTP (and SSL?) */ -extern gchar* tcp_follow_conv_filter(packet_info* pinfo, int* stream); -extern gchar* tcp_follow_index_filter(int stream); -extern gchar* tcp_follow_address_filter(address* src_addr, address* dst_addr, int src_port, int dst_port); +extern gchar *tcp_follow_conv_filter(packet_info *pinfo, guint *stream); +extern gchar *tcp_follow_index_filter(guint stream); +extern gchar *tcp_follow_address_filter(address *src_addr, address *dst_addr, int src_port, int dst_port); #ifdef __cplusplus } diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index bc7bb111f5..a7df2c84ac 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -425,7 +425,7 @@ udp_build_filter(packet_info *pinfo) return NULL; } -static gchar* udp_follow_conv_filter(packet_info *pinfo, int* stream) +static gchar *udp_follow_conv_filter(packet_info *pinfo, guint *stream) { conversation_t *conv; struct udp_analysis *udpd; @@ -440,18 +440,18 @@ static gchar* udp_follow_conv_filter(packet_info *pinfo, int* stream) return NULL; *stream = udpd->stream; - return g_strdup_printf("udp.stream eq %d", udpd->stream); + return g_strdup_printf("udp.stream eq %u", udpd->stream); } return NULL; } -static gchar* udp_follow_index_filter(int stream) +static gchar *udp_follow_index_filter(guint stream) { - return g_strdup_printf("udp.stream eq %d", stream); + return g_strdup_printf("udp.stream eq %u", stream); } -static gchar* udp_follow_address_filter(address* src_addr, address* dst_addr, int src_port, int dst_port) +static gchar *udp_follow_address_filter(address *src_addr, address *dst_addr, int src_port, int dst_port) { const gchar *ip_version = src_addr->type == AT_IPv6 ? "v6" : ""; gchar src_addr_str[WS_INET6_ADDRSTRLEN]; diff --git a/epan/follow.h b/epan/follow.h index a841273825..f8053d139c 100644 --- a/epan/follow.h +++ b/epan/follow.h @@ -99,8 +99,8 @@ typedef struct _follow_info { struct register_follow; typedef struct register_follow register_follow_t; -typedef gchar* (*follow_conv_filter_func)(packet_info* pinfo, int* stream); -typedef gchar* (*follow_index_filter_func)(int stream); +typedef gchar* (*follow_conv_filter_func)(packet_info *pinfo, guint *stream); +typedef gchar* (*follow_index_filter_func)(guint 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); diff --git a/ui/qt/conversation_dialog.cpp b/ui/qt/conversation_dialog.cpp index eb7a433432..5f0de61957 100644 --- a/ui/qt/conversation_dialog.cpp +++ b/ui/qt/conversation_dialog.cpp @@ -212,7 +212,7 @@ void ConversationDialog::followStream() } // Will set the display filter too. - emit openFollowStreamDialog(ftype, (int)conv_item->conv_id); + emit openFollowStreamDialog(ftype, conv_item->conv_id); } void ConversationDialog::graphTcp() diff --git a/ui/qt/conversation_dialog.h b/ui/qt/conversation_dialog.h index f62d81edf0..1fcfc6b60f 100644 --- a/ui/qt/conversation_dialog.h +++ b/ui/qt/conversation_dialog.h @@ -57,7 +57,7 @@ public slots: signals: void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type); - void openFollowStreamDialog(follow_type_t type, int stream_num); + void openFollowStreamDialog(follow_type_t type, guint stream_num); void openTcpStreamGraph(int graph_type); private: diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index c039877100..f30a1b558b 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -771,7 +771,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser return FRS_OK; } -bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index, int stream_num) +bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index, guint stream_num) { QString follow_filter; const char *hostname0 = NULL, *hostname1 = NULL; diff --git a/ui/qt/follow_stream_dialog.h b/ui/qt/follow_stream_dialog.h index 805f46c6ab..183a42dea9 100644 --- a/ui/qt/follow_stream_dialog.h +++ b/ui/qt/follow_stream_dialog.h @@ -42,7 +42,7 @@ public: explicit FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type = FOLLOW_TCP); ~FollowStreamDialog(); - bool follow(QString previous_filter = QString(), bool use_stream_index = false, int stream_num = -1); + bool follow(QString previous_filter = QString(), bool use_stream_index = false, guint stream_num = 0); public slots: void captureEvent(CaptureEvent e); diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index a7c619d7a4..55cdc7629c 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -545,7 +545,8 @@ private slots: void on_actionAnalyzeDecodeAs_triggered(); void on_actionAnalyzeReloadLuaPlugins_triggered(); - void openFollowStreamDialog(follow_type_t type, int stream_num = -1); + void openFollowStreamDialog(follow_type_t type, guint stream_num, bool use_stream_index = true); + void openFollowStreamDialogForType(follow_type_t type); void on_actionAnalyzeFollowTCPStream_triggered(); void on_actionAnalyzeFollowUDPStream_triggered(); void on_actionAnalyzeFollowTLSStream_triggered(); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 5d6ace80c9..c3dac66d02 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -2760,13 +2760,13 @@ void MainWindow::on_actionAnalyzeReloadLuaPlugins_triggered() reloadLuaPlugins(); } -void MainWindow::openFollowStreamDialog(follow_type_t type, int stream_num) { +void MainWindow::openFollowStreamDialog(follow_type_t type, guint stream_num, bool use_stream_index) { FollowStreamDialog *fsd = new FollowStreamDialog(*this, capture_file_, type); connect(fsd, SIGNAL(updateFilter(QString, bool)), this, SLOT(filterPackets(QString, bool))); connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int))); fsd->show(); - if (stream_num >= 0) { + if (use_stream_index) { // If a specific conversation was requested, then ignore any previous // display filters and display all related packets. fsd->follow("", true, stream_num); @@ -2775,24 +2775,28 @@ void MainWindow::openFollowStreamDialog(follow_type_t type, int stream_num) { } } +void MainWindow::openFollowStreamDialogForType(follow_type_t type) { + openFollowStreamDialog(type, 0, false); +} + void MainWindow::on_actionAnalyzeFollowTCPStream_triggered() { - openFollowStreamDialog(FOLLOW_TCP); + openFollowStreamDialogForType(FOLLOW_TCP); } void MainWindow::on_actionAnalyzeFollowUDPStream_triggered() { - openFollowStreamDialog(FOLLOW_UDP); + openFollowStreamDialogForType(FOLLOW_UDP); } void MainWindow::on_actionAnalyzeFollowTLSStream_triggered() { - openFollowStreamDialog(FOLLOW_TLS); + openFollowStreamDialogForType(FOLLOW_TLS); } void MainWindow::on_actionAnalyzeFollowHTTPStream_triggered() { - openFollowStreamDialog(FOLLOW_HTTP); + openFollowStreamDialogForType(FOLLOW_HTTP); } void MainWindow::openSCTPAllAssocsDialog() @@ -3080,8 +3084,8 @@ void MainWindow::statCommandConversations(const char *arg, void *userdata) ConversationDialog *conv_dialog = new ConversationDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg); connect(conv_dialog, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)), this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType))); - connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t,int)), - this, SLOT(openFollowStreamDialog(follow_type_t,int))); + connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t,guint)), + this, SLOT(openFollowStreamDialog(follow_type_t,guint))); connect(conv_dialog, SIGNAL(openTcpStreamGraph(int)), this, SLOT(openTcpStreamDialog(int))); conv_dialog->show(); @@ -3099,7 +3103,7 @@ void MainWindow::statCommandEndpoints(const char *arg, void *userdata) connect(endp_dialog, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)), this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType))); connect(endp_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)), - this, SLOT(openFollowStreamDialog(follow_type_t))); + this, SLOT(openFollowStreamDialogForType(follow_type_t))); connect(endp_dialog, SIGNAL(openTcpStreamGraph(int)), this, SLOT(openTcpStreamDialog(int))); endp_dialog->show();