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 <peter@lekensteyn.nl>
Reviewed-by: Alexander Gryanko <xpahos@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Peter Wu 2019-03-01 15:20:22 +01:00 committed by Alexis La Goutte
parent 712d94fa78
commit f4167c32e0
10 changed files with 34 additions and 29 deletions

View File

@ -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; conversation_t *conv;
struct tcp_analysis *tcpd; struct tcp_analysis *tcpd;
@ -915,18 +915,18 @@ gchar* tcp_follow_conv_filter(packet_info* pinfo, int* stream)
return NULL; return NULL;
*stream = tcpd->stream; *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; 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" : ""; const gchar *ip_version = src_addr->type == AT_IPv6 ? "v6" : "";
gchar src_addr_str[WS_INET6_ADDRSTRLEN]; gchar src_addr_str[WS_INET6_ADDRSTRLEN];

View File

@ -508,9 +508,9 @@ WS_DLL_PUBLIC guint32 get_tcp_stream_count(void);
WS_DLL_PUBLIC guint32 get_mptcp_stream_count(void); WS_DLL_PUBLIC guint32 get_mptcp_stream_count(void);
/* Follow Stream functionality shared with HTTP (and SSL?) */ /* Follow Stream functionality shared with HTTP (and SSL?) */
extern gchar* tcp_follow_conv_filter(packet_info* pinfo, int* stream); extern gchar *tcp_follow_conv_filter(packet_info *pinfo, guint *stream);
extern gchar* tcp_follow_index_filter(int 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); extern gchar *tcp_follow_address_filter(address *src_addr, address *dst_addr, int src_port, int dst_port);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -425,7 +425,7 @@ udp_build_filter(packet_info *pinfo)
return NULL; 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; conversation_t *conv;
struct udp_analysis *udpd; struct udp_analysis *udpd;
@ -440,18 +440,18 @@ static gchar* udp_follow_conv_filter(packet_info *pinfo, int* stream)
return NULL; return NULL;
*stream = udpd->stream; *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; 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" : ""; const gchar *ip_version = src_addr->type == AT_IPv6 ? "v6" : "";
gchar src_addr_str[WS_INET6_ADDRSTRLEN]; gchar src_addr_str[WS_INET6_ADDRSTRLEN];

View File

@ -99,8 +99,8 @@ typedef struct _follow_info {
struct register_follow; struct register_follow;
typedef struct register_follow register_follow_t; typedef struct register_follow register_follow_t;
typedef gchar* (*follow_conv_filter_func)(packet_info* pinfo, int* stream); typedef gchar* (*follow_conv_filter_func)(packet_info *pinfo, guint *stream);
typedef gchar* (*follow_index_filter_func)(int 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_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 gchar* (*follow_port_to_display_func)(wmem_allocator_t *allocator, guint port);

View File

@ -212,7 +212,7 @@ void ConversationDialog::followStream()
} }
// Will set the display filter too. // Will set the display filter too.
emit openFollowStreamDialog(ftype, (int)conv_item->conv_id); emit openFollowStreamDialog(ftype, conv_item->conv_id);
} }
void ConversationDialog::graphTcp() void ConversationDialog::graphTcp()

View File

@ -57,7 +57,7 @@ public slots:
signals: signals:
void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type); 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); void openTcpStreamGraph(int graph_type);
private: private:

View File

@ -771,7 +771,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser
return FRS_OK; 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; QString follow_filter;
const char *hostname0 = NULL, *hostname1 = NULL; const char *hostname0 = NULL, *hostname1 = NULL;

View File

@ -42,7 +42,7 @@ public:
explicit FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type = FOLLOW_TCP); explicit FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type = FOLLOW_TCP);
~FollowStreamDialog(); ~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: public slots:
void captureEvent(CaptureEvent e); void captureEvent(CaptureEvent e);

View File

@ -545,7 +545,8 @@ private slots:
void on_actionAnalyzeDecodeAs_triggered(); void on_actionAnalyzeDecodeAs_triggered();
void on_actionAnalyzeReloadLuaPlugins_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_actionAnalyzeFollowTCPStream_triggered();
void on_actionAnalyzeFollowUDPStream_triggered(); void on_actionAnalyzeFollowUDPStream_triggered();
void on_actionAnalyzeFollowTLSStream_triggered(); void on_actionAnalyzeFollowTLSStream_triggered();

View File

@ -2760,13 +2760,13 @@ void MainWindow::on_actionAnalyzeReloadLuaPlugins_triggered()
reloadLuaPlugins(); 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); FollowStreamDialog *fsd = new FollowStreamDialog(*this, capture_file_, type);
connect(fsd, SIGNAL(updateFilter(QString, bool)), this, SLOT(filterPackets(QString, bool))); connect(fsd, SIGNAL(updateFilter(QString, bool)), this, SLOT(filterPackets(QString, bool)));
connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int))); connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
fsd->show(); fsd->show();
if (stream_num >= 0) { if (use_stream_index) {
// If a specific conversation was requested, then ignore any previous // If a specific conversation was requested, then ignore any previous
// display filters and display all related packets. // display filters and display all related packets.
fsd->follow("", true, stream_num); 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() void MainWindow::on_actionAnalyzeFollowTCPStream_triggered()
{ {
openFollowStreamDialog(FOLLOW_TCP); openFollowStreamDialogForType(FOLLOW_TCP);
} }
void MainWindow::on_actionAnalyzeFollowUDPStream_triggered() void MainWindow::on_actionAnalyzeFollowUDPStream_triggered()
{ {
openFollowStreamDialog(FOLLOW_UDP); openFollowStreamDialogForType(FOLLOW_UDP);
} }
void MainWindow::on_actionAnalyzeFollowTLSStream_triggered() void MainWindow::on_actionAnalyzeFollowTLSStream_triggered()
{ {
openFollowStreamDialog(FOLLOW_TLS); openFollowStreamDialogForType(FOLLOW_TLS);
} }
void MainWindow::on_actionAnalyzeFollowHTTPStream_triggered() void MainWindow::on_actionAnalyzeFollowHTTPStream_triggered()
{ {
openFollowStreamDialog(FOLLOW_HTTP); openFollowStreamDialogForType(FOLLOW_HTTP);
} }
void MainWindow::openSCTPAllAssocsDialog() 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); ConversationDialog *conv_dialog = new ConversationDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg);
connect(conv_dialog, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)), connect(conv_dialog, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)),
this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType))); this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)));
connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t,int)), connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t,guint)),
this, SLOT(openFollowStreamDialog(follow_type_t,int))); this, SLOT(openFollowStreamDialog(follow_type_t,guint)));
connect(conv_dialog, SIGNAL(openTcpStreamGraph(int)), connect(conv_dialog, SIGNAL(openTcpStreamGraph(int)),
this, SLOT(openTcpStreamDialog(int))); this, SLOT(openTcpStreamDialog(int)));
conv_dialog->show(); 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)), connect(endp_dialog, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)),
this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType))); this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)));
connect(endp_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)), 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)), connect(endp_dialog, SIGNAL(openTcpStreamGraph(int)),
this, SLOT(openTcpStreamDialog(int))); this, SLOT(openTcpStreamDialog(int)));
endp_dialog->show(); endp_dialog->show();