2012-01-04 22:13:01 +00:00
|
|
|
/* packet_list.cpp
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-01-04 22:13:01 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/epan.h>
|
|
|
|
#include <epan/epan_dissect.h>
|
|
|
|
|
|
|
|
#include <epan/column_info.h>
|
|
|
|
#include <epan/column.h>
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
#include "packet_list.h"
|
|
|
|
#include "monospace_font.h"
|
|
|
|
#include "proto_tree.h"
|
|
|
|
|
|
|
|
#include "qt_ui_utils.h"
|
2012-01-16 01:18:56 +00:00
|
|
|
|
|
|
|
#include "ui/main_statusbar.h"
|
2012-01-18 19:59:13 +00:00
|
|
|
#include "ui/recent.h"
|
2012-08-23 17:29:05 +00:00
|
|
|
#include "ui/recent_utils.h"
|
2012-01-16 01:18:56 +00:00
|
|
|
#include "ui/ui_util.h"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTextEdit>
|
2012-08-23 17:29:05 +00:00
|
|
|
#include <QScrollBar>
|
2012-12-07 01:46:20 +00:00
|
|
|
#include <QContextMenuEvent>
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
// If we ever add the ability to open multiple capture files we might be
|
|
|
|
// able to use something like QMap<capture_file *, PacketList *> to match
|
|
|
|
// capture files against packet lists and models.
|
2012-08-23 17:29:05 +00:00
|
|
|
static PacketList *gbl_cur_packet_list = NULL;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
guint
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_append(column_info *cinfo, frame_data *fdata, packet_info *pinfo)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-01-14 00:16:16 +00:00
|
|
|
Q_UNUSED(cinfo);
|
|
|
|
Q_UNUSED(pinfo);
|
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
2012-01-04 22:13:01 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* fdata should be filled with the stuff we need
|
|
|
|
* strings are built at display time.
|
|
|
|
*/
|
|
|
|
guint visible_pos;
|
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
visible_pos = gbl_cur_packet_list->packetListModel()->appendPacket(fdata);
|
2012-01-04 22:13:01 +00:00
|
|
|
return visible_pos;
|
|
|
|
}
|
|
|
|
|
2012-09-04 01:57:36 +00:00
|
|
|
// Copied from ui/gtk/packet_list.c
|
2012-09-04 02:35:25 +00:00
|
|
|
void packet_list_resize_column(gint col)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
|
|
|
// xxx qtshark
|
|
|
|
// gint col_width;
|
|
|
|
// const gchar *long_str;
|
|
|
|
|
2012-09-04 02:35:25 +00:00
|
|
|
g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: packet_list_resize_column %d", col);
|
2012-01-04 22:13:01 +00:00
|
|
|
// long_str = packet_list_get_widest_column_string(packetlist, col);
|
|
|
|
// if(!long_str || strcmp("",long_str)==0)
|
|
|
|
// /* If we get an empty string leave the width unchanged */
|
|
|
|
// return;
|
|
|
|
// column = gtk_tree_view_get_column (GTK_TREE_VIEW(packetlist->view), col);
|
|
|
|
// col_width = get_default_col_size (packetlist->view, long_str);
|
|
|
|
// gtk_tree_view_column_set_fixed_width(column, col_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_select_first_row(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
2012-08-13 01:50:14 +00:00
|
|
|
return;
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->goFirstPacket();
|
|
|
|
gbl_cur_packet_list->setFocus();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_select_last_row(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
2012-08-13 01:50:14 +00:00
|
|
|
return;
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->goLastPacket();
|
|
|
|
gbl_cur_packet_list->setFocus();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a frame_data structure, scroll to and select the row in the
|
|
|
|
* packet list corresponding to that frame. If there is no such
|
|
|
|
* row, return FALSE, otherwise return TRUE.
|
|
|
|
*/
|
|
|
|
gboolean
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_select_row_from_data(frame_data *fdata_needle)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
int row = gbl_cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle);
|
2012-01-04 22:13:01 +00:00
|
|
|
if (row >= 0) {
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->setCurrentIndex(gbl_cur_packet_list->packetListModel()->index(row,0));
|
2012-01-04 22:13:01 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_check_end(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
|
|
|
QScrollBar *sb = gbl_cur_packet_list->verticalScrollBar();
|
|
|
|
if (sb && sb->isVisible() && sb->value() == sb->maximum()) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_clear(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
|
|
|
gbl_cur_packet_list->clear();
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_enable_color(gboolean enable)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list && gbl_cur_packet_list->packetListModel()) {
|
|
|
|
gbl_cur_packet_list->packetListModel()->setColorEnabled(enable);
|
|
|
|
gbl_cur_packet_list->update();
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_freeze(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
|
|
|
gbl_cur_packet_list->setUpdatesEnabled(false);
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_thaw(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list) {
|
|
|
|
gbl_cur_packet_list->setUpdatesEnabled(true);
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
packets_bar_update();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recreate_visible_rows(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list && gbl_cur_packet_list->packetListModel()) {
|
|
|
|
gbl_cur_packet_list->packetListModel()->recreateVisibleRows();
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
frame_data *
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_get_row_data(gint row)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list && gbl_cur_packet_list->packetListModel()) {
|
|
|
|
return gbl_cur_packet_list->packetListModel()->getRowFdata(row);
|
|
|
|
}
|
|
|
|
return NULL;
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_moveto_end(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list)
|
|
|
|
gbl_cur_packet_list->goLastPacket();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Redraw the packet list *and* currently-selected detail */
|
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_queue_draw(void)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-08-23 17:29:05 +00:00
|
|
|
if (gbl_cur_packet_list)
|
|
|
|
gbl_cur_packet_list->updateAll();
|
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
void
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recent_write_all(FILE *rf) {
|
2012-08-23 17:29:05 +00:00
|
|
|
if (!gbl_cur_packet_list)
|
|
|
|
return;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
gbl_cur_packet_list->writeRecent(rf);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MIN_COL_WIDTH_STR "...."
|
|
|
|
|
|
|
|
PacketList::PacketList(QWidget *parent) :
|
2012-10-30 19:21:24 +00:00
|
|
|
QTreeView(parent),
|
|
|
|
proto_tree_(NULL),
|
|
|
|
byte_view_tab_(NULL),
|
2012-12-07 20:08:00 +00:00
|
|
|
cap_file_(NULL),
|
|
|
|
ctx_column_(-1)
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
2012-12-07 20:08:00 +00:00
|
|
|
QMenu *submenu, *subsubmenu;
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
setItemsExpandable(FALSE);
|
|
|
|
setRootIsDecorated(FALSE);
|
|
|
|
setSortingEnabled(TRUE);
|
|
|
|
setUniformRowHeights(TRUE);
|
|
|
|
setAccessibleName("Packet list");
|
|
|
|
|
2012-12-07 20:08:00 +00:00
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
packet_list_model_ = new PacketListModel(this, cap_file_);
|
2012-08-19 23:52:08 +00:00
|
|
|
setModel(packet_list_model_);
|
2012-08-23 17:29:05 +00:00
|
|
|
packet_list_model_->setColorEnabled(true); // We don't yet fetch color settings.
|
|
|
|
// packet_list_model_->setColorEnabled(recent.packet_list_colorize);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-12-07 20:08:00 +00:00
|
|
|
// " <menuitem name='MarkPacket' action='/MarkPacket'/>\n"
|
|
|
|
// " <menuitem name='IgnorePacket' action='/IgnorePacket'/>\n"
|
|
|
|
// " <menuitem name='SetTimeReference' action='/Set Time Reference'/>\n"
|
|
|
|
// " <menuitem name='TimeShift' action='/TimeShift'/>\n"
|
|
|
|
// " <menuitem name='AddEditPktComment' action='/Edit/AddEditPktComment'/>\n"
|
|
|
|
ctx_menu_.addSeparator();
|
|
|
|
// " <menuitem name='ManuallyResolveAddress' action='/ManuallyResolveAddress'/>\n"
|
|
|
|
ctx_menu_.addSeparator();
|
|
|
|
submenu = new QMenu(tr("Apply as Filter"));
|
|
|
|
ctx_menu_.addMenu(submenu);
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrNotSelected"));
|
|
|
|
filter_actions_ << submenu->actions();
|
|
|
|
submenu = new QMenu(tr("Prepare a Filter"));
|
|
|
|
ctx_menu_.addMenu(submenu);
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndNotSelected"));
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrNotSelected"));
|
|
|
|
filter_actions_ << submenu->actions();
|
|
|
|
submenu = new QMenu(tr("Colorize with Filter"));
|
|
|
|
// " <menu name= 'ConversationFilter' action='/Conversation Filter'>\n"
|
|
|
|
// " <menuitem name='Ethernet' action='/Conversation Filter/Ethernet'/>\n"
|
|
|
|
// " <menuitem name='IP' action='/Conversation Filter/IP'/>\n"
|
|
|
|
// " <menuitem name='TCP' action='/Conversation Filter/TCP'/>\n"
|
|
|
|
// " <menuitem name='UDP' action='/Conversation Filter/UDP'/>\n"
|
|
|
|
// " <menuitem name='PN-CBA' action='/Conversation Filter/PN-CBA'/>\n"
|
|
|
|
// " <menu name= 'ColorizeConversation' action='/Colorize Conversation'>\n"
|
|
|
|
// " <menu name= 'Ethernet' action='/Colorize Conversation/Ethernet'>\n"
|
|
|
|
// " <menuitem name='Color1' action='/Colorize Conversation/Ethernet/Color 1'/>\n"
|
|
|
|
// " <menuitem name='Color2' action='/Colorize Conversation/Ethernet/Color 2'/>\n"
|
|
|
|
// " <menuitem name='Color3' action='/Colorize Conversation/Ethernet/Color 3'/>\n"
|
|
|
|
// " <menuitem name='Color4' action='/Colorize Conversation/Ethernet/Color 4'/>\n"
|
|
|
|
// " <menuitem name='Color5' action='/Colorize Conversation/Ethernet/Color 5'/>\n"
|
|
|
|
// " <menuitem name='Color6' action='/Colorize Conversation/Ethernet/Color 6'/>\n"
|
|
|
|
// " <menuitem name='Color7' action='/Colorize Conversation/Ethernet/Color 7'/>\n"
|
|
|
|
// " <menuitem name='Color8' action='/Colorize Conversation/Ethernet/Color 8'/>\n"
|
|
|
|
// " <menuitem name='Color9' action='/Colorize Conversation/Ethernet/Color 9'/>\n"
|
|
|
|
// " <menuitem name='Color10' action='/Colorize Conversation/Ethernet/Color 10'/>\n"
|
|
|
|
// " <menuitem name='NewColoringRule' action='/Colorize Conversation/Ethernet/New Coloring Rule'/>\n"
|
|
|
|
// " <menu name= 'IP' action='/Colorize Conversation/IP'>\n"
|
|
|
|
// " <menuitem name='Color1' action='/Colorize Conversation/IP/Color 1'/>\n"
|
|
|
|
// " <menuitem name='Color2' action='/Colorize Conversation/IP/Color 2'/>\n"
|
|
|
|
// " <menuitem name='Color3' action='/Colorize Conversation/IP/Color 3'/>\n"
|
|
|
|
// " <menuitem name='Color4' action='/Colorize Conversation/IP/Color 4'/>\n"
|
|
|
|
// " <menuitem name='Color5' action='/Colorize Conversation/IP/Color 5'/>\n"
|
|
|
|
// " <menuitem name='Color6' action='/Colorize Conversation/IP/Color 6'/>\n"
|
|
|
|
// " <menuitem name='Color7' action='/Colorize Conversation/IP/Color 7'/>\n"
|
|
|
|
// " <menuitem name='Color8' action='/Colorize Conversation/IP/Color 8'/>\n"
|
|
|
|
// " <menuitem name='Color9' action='/Colorize Conversation/IP/Color 9'/>\n"
|
|
|
|
// " <menuitem name='Color10' action='/Colorize Conversation/IP/Color 10'/>\n"
|
|
|
|
// " <menuitem name='NewColoringRule' action='/Colorize Conversation/IP/New Coloring Rule'/>\n"
|
|
|
|
// " <menu name= 'TCP' action='/Colorize Conversation/TCP'>\n"
|
|
|
|
// " <menuitem name='Color1' action='/Colorize Conversation/TCP/Color 1'/>\n"
|
|
|
|
// " <menuitem name='Color2' action='/Colorize Conversation/TCP/Color 2'/>\n"
|
|
|
|
// " <menuitem name='Color3' action='/Colorize Conversation/TCP/Color 3'/>\n"
|
|
|
|
// " <menuitem name='Color4' action='/Colorize Conversation/TCP/Color 4'/>\n"
|
|
|
|
// " <menuitem name='Color5' action='/Colorize Conversation/TCP/Color 5'/>\n"
|
|
|
|
// " <menuitem name='Color6' action='/Colorize Conversation/TCP/Color 6'/>\n"
|
|
|
|
// " <menuitem name='Color7' action='/Colorize Conversation/TCP/Color 7'/>\n"
|
|
|
|
// " <menuitem name='Color8' action='/Colorize Conversation/TCP/Color 8'/>\n"
|
|
|
|
// " <menuitem name='Color9' action='/Colorize Conversation/TCP/Color 9'/>\n"
|
|
|
|
// " <menuitem name='Color10' action='/Colorize Conversation/TCP/Color 10'/>\n"
|
|
|
|
// " <menuitem name='NewColoringRule' action='/Colorize Conversation/TCP/New Coloring Rule'/>\n"
|
|
|
|
// " <menu name= 'UDP' action='/Colorize Conversation/UDP'>\n"
|
|
|
|
// " <menuitem name='Color1' action='/Colorize Conversation/UDP/Color 1'/>\n"
|
|
|
|
// " <menuitem name='Color2' action='/Colorize Conversation/UDP/Color 2'/>\n"
|
|
|
|
// " <menuitem name='Color3' action='/Colorize Conversation/UDP/Color 3'/>\n"
|
|
|
|
// " <menuitem name='Color4' action='/Colorize Conversation/UDP/Color 4'/>\n"
|
|
|
|
// " <menuitem name='Color5' action='/Colorize Conversation/UDP/Color 5'/>\n"
|
|
|
|
// " <menuitem name='Color6' action='/Colorize Conversation/UDP/Color 6'/>\n"
|
|
|
|
// " <menuitem name='Color7' action='/Colorize Conversation/UDP/Color 7'/>\n"
|
|
|
|
// " <menuitem name='Color8' action='/Colorize Conversation/UDP/Color 8'/>\n"
|
|
|
|
// " <menuitem name='Color9' action='/Colorize Conversation/UDP/Color 9'/>\n"
|
|
|
|
// " <menuitem name='Color10' action='/Colorize Conversation/UDP/Color 10'/>\n"
|
|
|
|
// " <menuitem name='NewColoringRule' action='/Colorize Conversation/UDP/New Coloring Rule'/>\n"
|
|
|
|
// " <menu name= 'PN-CBA' action='/Colorize Conversation/PN-CBA'>\n"
|
|
|
|
// " <menuitem name='Color1' action='/Colorize Conversation/PN-CBA/Color 1'/>\n"
|
|
|
|
// " <menuitem name='Color2' action='/Colorize Conversation/PN-CBA/Color 2'/>\n"
|
|
|
|
// " <menuitem name='Color3' action='/Colorize Conversation/PN-CBA/Color 3'/>\n"
|
|
|
|
// " <menuitem name='Color4' action='/Colorize Conversation/PN-CBA/Color 4'/>\n"
|
|
|
|
// " <menuitem name='Color5' action='/Colorize Conversation/PN-CBA/Color 5'/>\n"
|
|
|
|
// " <menuitem name='Color6' action='/Colorize Conversation/PN-CBA/Color 6'/>\n"
|
|
|
|
// " <menuitem name='Color7' action='/Colorize Conversation/PN-CBA/Color 7'/>\n"
|
|
|
|
// " <menuitem name='Color8' action='/Colorize Conversation/PN-CBA/Color 8'/>\n"
|
|
|
|
// " <menuitem name='Color9' action='/Colorize Conversation/PN-CBA/Color 9'/>\n"
|
|
|
|
// " <menuitem name='Color10' action='/Colorize Conversation/PN-CBA/Color 10'/>\n"
|
|
|
|
// " <menuitem name='NewColoringRule' action='/Colorize Conversation/PN-CBA/New Coloring Rule'/>\n"
|
|
|
|
// " <menu name= 'SCTP' action='/SCTP'>\n"
|
|
|
|
// " <menuitem name='AnalysethisAssociation' action='/SCTP/Analyse this Association'/>\n"
|
|
|
|
// " <menuitem name='PrepareFilterforthisAssociation' action='/SCTP/Prepare Filter for this Association'/>\n"
|
|
|
|
// " <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
|
|
|
|
// " <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
|
|
|
|
// " <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
|
|
|
|
ctx_menu_.addSeparator();
|
|
|
|
// " <menu name= 'Copy' action='/Copy'>\n"
|
|
|
|
submenu = new QMenu(tr("Copy"));
|
|
|
|
ctx_menu_.addMenu(submenu);
|
|
|
|
// " <menuitem name='SummaryTxt' action='/Copy/SummaryTxt'/>\n"
|
|
|
|
// " <menuitem name='SummaryCSV' action='/Copy/SummaryCSV'/>\n"
|
|
|
|
submenu->addAction(window()->findChild<QAction *>("actionEditCopyAsFilter"));
|
|
|
|
filter_actions_ << window()->findChild<QAction *>("actionEditCopyAsFilter");
|
|
|
|
submenu->addSeparator();
|
|
|
|
subsubmenu = new QMenu(tr("Bytes"));
|
|
|
|
submenu->addMenu(subsubmenu);
|
|
|
|
// " <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
|
|
|
|
// " <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
|
|
|
|
// " <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
|
|
|
|
ctx_menu_.addSeparator();
|
|
|
|
// " <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
|
|
|
|
// " <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
|
|
|
|
ctx_menu_.addSeparator();
|
|
|
|
// " <menuitem name='ProtocolPreferences' action='/ProtocolPreferences'/>\n"
|
|
|
|
// " <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
|
|
|
|
// " <menuitem name='Print' action='/Print'/>\n"
|
|
|
|
// " <menuitem name='ShowPacketinNewWindow' action='/ShowPacketinNewWindow'/>\n"
|
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
g_assert(gbl_cur_packet_list == NULL);
|
|
|
|
gbl_cur_packet_list = this;
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 02:59:31 +00:00
|
|
|
void PacketList::setProtoTree (ProtoTree *proto_tree) {
|
|
|
|
proto_tree_ = proto_tree;
|
2012-08-19 23:52:08 +00:00
|
|
|
|
|
|
|
connect(proto_tree_, SIGNAL(goToFrame(int)), this, SLOT(goToPacket(int)));
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 02:59:31 +00:00
|
|
|
void PacketList::setByteViewTab (ByteViewTab *byte_view_tab) {
|
|
|
|
byte_view_tab_ = byte_view_tab;
|
2012-11-06 23:20:07 +00:00
|
|
|
|
|
|
|
connect(proto_tree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
|
|
|
byte_view_tab_, SLOT(protoTreeItemChanged(QTreeWidgetItem*)));
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketListModel *PacketList::packetListModel() const {
|
2012-08-19 23:52:08 +00:00
|
|
|
return packet_list_model_;
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::showEvent (QShowEvent *event) {
|
2012-01-14 00:16:16 +00:00
|
|
|
Q_UNUSED(event);
|
2012-10-30 19:21:24 +00:00
|
|
|
|
|
|
|
if (!cap_file_) return;
|
|
|
|
|
|
|
|
for (int i = 0; i < cap_file_->cinfo.num_cols; i++) {
|
2012-01-04 22:13:01 +00:00
|
|
|
int fmt, col_width;
|
|
|
|
const char *long_str;
|
|
|
|
|
|
|
|
fmt = get_column_format(i);
|
|
|
|
long_str = get_column_width_string(fmt, i);
|
|
|
|
if (long_str) {
|
|
|
|
col_width = get_monospace_text_size(long_str, TRUE);
|
|
|
|
} else {
|
|
|
|
col_width = get_monospace_text_size(MIN_COL_WIDTH_STR, TRUE);
|
|
|
|
}
|
|
|
|
setColumnWidth(i, col_width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) {
|
|
|
|
QTreeView::selectionChanged(selected, deselected);
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
if (!cap_file_) return;
|
|
|
|
|
2012-08-19 23:52:08 +00:00
|
|
|
if (proto_tree_) {
|
2012-01-04 22:13:01 +00:00
|
|
|
int row = selected.first().top();
|
2012-10-30 19:21:24 +00:00
|
|
|
cf_select_packet(cap_file_, row);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
if (!cap_file_->edt && !cap_file_->edt->tree) {
|
2012-01-04 22:13:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
proto_tree_->fillProtocolTree(cap_file_->edt->tree);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
if (byte_view_tab_ && cap_file_->edt) {
|
2012-01-04 22:13:01 +00:00
|
|
|
GSList *src_le;
|
2012-10-20 19:54:56 +00:00
|
|
|
struct data_source *source;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-11-06 21:49:16 +00:00
|
|
|
byte_view_tab_->clear();
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
for (src_le = cap_file_->edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
|
2012-10-20 19:54:56 +00:00
|
|
|
source = (struct data_source *)src_le->data;
|
2012-10-30 19:21:24 +00:00
|
|
|
byte_view_tab_->addTab(get_data_source_name(source), get_data_source_tvb(source), cap_file_->edt->tree, proto_tree_, cap_file_->current_frame->flags.encoding);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
2012-11-06 21:49:16 +00:00
|
|
|
byte_view_tab_->setCurrentIndex(0);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
void PacketList::contextMenuEvent(QContextMenuEvent *event)
|
|
|
|
{
|
2012-12-07 20:08:00 +00:00
|
|
|
bool fa_enabled = filter_actions_[0]->isEnabled();
|
|
|
|
QAction *act;
|
|
|
|
|
|
|
|
foreach (act, filter_actions_) {
|
|
|
|
act->setEnabled(true);
|
2012-12-07 01:46:20 +00:00
|
|
|
}
|
2012-12-07 20:08:00 +00:00
|
|
|
ctx_column_ = columnAt(event->x());
|
2012-12-07 01:46:20 +00:00
|
|
|
ctx_menu_.exec(event->globalPos());
|
2012-12-07 20:08:00 +00:00
|
|
|
ctx_column_ = -1;
|
|
|
|
foreach (act, filter_actions_) {
|
|
|
|
act->setEnabled(fa_enabled);
|
2012-12-07 01:46:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
// Redraw the packet list and detail
|
|
|
|
void PacketList::updateAll() {
|
|
|
|
update();
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
if (cap_file_ && selectedIndexes().length() > 0) {
|
|
|
|
cf_select_packet(cap_file_, selectedIndexes()[0].row());
|
2012-08-23 17:29:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
void PacketList::clear() {
|
|
|
|
// packet_history_clear();
|
2012-10-30 19:21:24 +00:00
|
|
|
packet_list_model_->clear();
|
2012-08-19 23:52:08 +00:00
|
|
|
proto_tree_->clear();
|
2012-11-06 21:49:16 +00:00
|
|
|
byte_view_tab_->clear();
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-08-23 17:29:05 +00:00
|
|
|
/* XXX is this correct in all cases?
|
|
|
|
* Reset the sort column, use packetlist as model in case the list is frozen.
|
|
|
|
*/
|
|
|
|
gbl_cur_packet_list->sortByColumn(0, Qt::AscendingOrder);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketList::writeRecent(FILE *rf) {
|
|
|
|
gint col, width, col_fmt;
|
|
|
|
gchar xalign;
|
|
|
|
|
|
|
|
fprintf (rf, "%s:", RECENT_KEY_COL_WIDTH);
|
2012-10-30 19:21:24 +00:00
|
|
|
for (col = 0; col < packet_list_model_->columnCount(); col++) {
|
2012-01-04 22:13:01 +00:00
|
|
|
if (col > 0) {
|
|
|
|
fprintf (rf, ",");
|
|
|
|
}
|
|
|
|
col_fmt = get_column_format(col);
|
|
|
|
if (col_fmt == COL_CUSTOM) {
|
|
|
|
fprintf (rf, " %%Cus:%s,", get_column_custom_field(col));
|
|
|
|
} else {
|
|
|
|
fprintf (rf, " %s,", col_format_to_string(col_fmt));
|
|
|
|
}
|
|
|
|
width = columnWidth(col);
|
|
|
|
xalign = recent_get_column_xalign (col);
|
|
|
|
if (width == 0) {
|
|
|
|
/* We have not initialized the packet list yet, use old values */
|
|
|
|
width = recent_get_column_width (col);
|
|
|
|
}
|
|
|
|
fprintf (rf, " %d", width);
|
|
|
|
if (xalign != COLUMN_XALIGN_DEFAULT) {
|
|
|
|
fprintf (rf, ":%c", xalign);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (rf, "\n");
|
|
|
|
|
|
|
|
}
|
2012-08-13 01:50:14 +00:00
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
bool PacketList::contextMenuActive()
|
|
|
|
{
|
2012-12-07 20:08:00 +00:00
|
|
|
return ctx_column_ >= 0 ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString &PacketList::getFilterFromRowAndColumn()
|
|
|
|
{
|
|
|
|
frame_data *fdata;
|
|
|
|
QString &filter = *new QString();
|
|
|
|
int row = currentIndex().row();
|
|
|
|
|
|
|
|
if (!cap_file_ || !packet_list_model_ || ctx_column_ < 0 || ctx_column_ >= cap_file_->cinfo.num_cols) return filter;
|
|
|
|
|
|
|
|
fdata = (frame_data *) packet_list_model_->getRowFdata(row);
|
|
|
|
|
|
|
|
if (fdata != NULL) {
|
|
|
|
epan_dissect_t edt;
|
|
|
|
|
|
|
|
if (!cf_read_frame(cap_file_, fdata))
|
|
|
|
return filter; /* error reading the frame */
|
|
|
|
/* proto tree, visible. We need a proto tree if there's custom columns */
|
|
|
|
epan_dissect_init(&edt, have_custom_cols(&cap_file_->cinfo), FALSE);
|
|
|
|
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
|
|
|
|
|
|
|
epan_dissect_run(&edt, &cap_file_->phdr, cap_file_->pd, fdata, &cap_file_->cinfo);
|
|
|
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
|
|
|
|
|
|
|
if ((cap_file_->cinfo.col_custom_occurrence[ctx_column_]) ||
|
|
|
|
(strchr (cap_file_->cinfo.col_expr.col_expr_val[ctx_column_], ',') == NULL))
|
|
|
|
{
|
|
|
|
/* Only construct the filter when a single occurrence is displayed
|
|
|
|
* otherwise we might end up with a filter like "ip.proto==1,6".
|
|
|
|
*
|
|
|
|
* Or do we want to be able to filter on multiple occurrences so that
|
|
|
|
* the filter might be calculated as "ip.proto==1 && ip.proto==6"
|
|
|
|
* instead?
|
|
|
|
*/
|
|
|
|
if (strlen(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) != 0 &&
|
|
|
|
strlen(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]) != 0) {
|
|
|
|
/* leak a little but safer than ep_ here */
|
|
|
|
if (cap_file_->cinfo.col_fmt[ctx_column_] == COL_CUSTOM) {
|
|
|
|
header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.col_custom_field[ctx_column_]);
|
|
|
|
if (hfi->parent == -1) {
|
|
|
|
/* Protocol only */
|
|
|
|
filter.append(cap_file_->cinfo.col_expr.col_expr[ctx_column_]);
|
|
|
|
} else if (hfi->type == FT_STRING) {
|
|
|
|
/* Custom string, add quotes */
|
|
|
|
filter.append(QString("%1 == \"%2\"")
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_])
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.isEmpty()) {
|
|
|
|
filter.append(QString("%1 == %2")
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr[ctx_column_])
|
|
|
|
.arg(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
epan_dissect_cleanup(&edt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return filter;
|
2012-12-07 01:46:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 19:21:24 +00:00
|
|
|
// Slots
|
|
|
|
|
|
|
|
void PacketList::setCaptureFile(capture_file *cf)
|
|
|
|
{
|
|
|
|
cap_file_ = cf;
|
|
|
|
packet_list_model_->setCaptureFile(cf);
|
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goNextPacket(void) {
|
2012-08-13 01:50:14 +00:00
|
|
|
setCurrentIndex(moveCursor(MoveDown, Qt::NoModifier));
|
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goPreviousPacket(void) {
|
2012-08-13 01:50:14 +00:00
|
|
|
setCurrentIndex(moveCursor(MoveUp, Qt::NoModifier));
|
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goFirstPacket(void) {
|
2012-08-13 01:50:14 +00:00
|
|
|
setCurrentIndex(moveCursor(MoveHome, Qt::NoModifier));
|
|
|
|
}
|
|
|
|
|
2012-08-14 04:12:56 +00:00
|
|
|
void PacketList::goLastPacket(void) {
|
2012-08-13 01:50:14 +00:00
|
|
|
setCurrentIndex(moveCursor(MoveEnd, Qt::NoModifier));
|
|
|
|
}
|
2012-08-19 23:52:08 +00:00
|
|
|
|
|
|
|
void PacketList::goToPacket(int packet) {
|
2012-08-20 04:34:23 +00:00
|
|
|
if (packet > 0 && packet <= packet_list_model_->rowCount()) {
|
|
|
|
setCurrentIndex(packet_list_model_->index(packet - 1, 0));
|
|
|
|
}
|
2012-08-19 23:52:08 +00:00
|
|
|
}
|
2012-09-04 08:18:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|