From 2bffa17891366c44880ec2f7bca78c5a64911ab1 Mon Sep 17 00:00:00 2001 From: Sake Blok Date: Fri, 1 Oct 2010 22:46:30 +0000 Subject: [PATCH] Add navigation to previous/next packets in the conversation. It will check TCP and UDP first and if this is not TCP or UDP, it will use IP. Accelerator keys: +[ Goto Previous Packet In Conversation +] Goto Next Packet In Conversation svn path=/trunk/; revision=34319 --- docbook/wsug_src/WSUG_chapter_use.xml | 14 ++++++ gtk/menus.c | 65 +++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/docbook/wsug_src/WSUG_chapter_use.xml b/docbook/wsug_src/WSUG_chapter_use.xml index c5bae8c135..16361c5c91 100644 --- a/docbook/wsug_src/WSUG_chapter_use.xml +++ b/docbook/wsug_src/WSUG_chapter_use.xml @@ -182,6 +182,20 @@ list isn't focused. + + Ctrl+] + + Move to the next packet of the conversation + (TCP, UDP or IP) + + + + Ctrl+[ + + Move to the previous packet of the conversation + (TCP, UDP or IP) + + Left diff --git a/gtk/menus.c b/gtk/menus.c index c799789961..346438da9b 100644 --- a/gtk/menus.c +++ b/gtk/menus.c @@ -444,6 +444,55 @@ colorize_conversation_cb(GtkWidget * w _U_, gpointer data _U_, int action) } } +void +goto_conversation_frame(gboolean dir) +{ + gchar *filter; + dfilter_t *dfcode = NULL; + gboolean found_packet=FALSE; + + filter = build_conversation_filter(CONV_TCP,FALSE); + if( filter == NULL ) + filter = build_conversation_filter(CONV_UDP,FALSE); + if( filter == NULL ) + filter = build_conversation_filter(CONV_IP,FALSE); + if( filter == NULL ) { + simple_status("Unable to build conversation filter."); + g_free(filter); + return; + } + + if (!dfilter_compile(filter, &dfcode)) { + /* The attempt failed; report an error. */ + simple_status("Error compiling filter for this conversation."); + g_free(filter); + return; + } + + found_packet = cf_find_packet_dfilter(&cfile, dfcode, dir); + + if (!found_packet) { + /* We didn't find a packet */ + simple_status("No previous/next packet in conversation."); + } + + dfilter_free(dfcode); + g_free(filter); +} + +void +goto_next_frame_conversation_cb(GtkWidget *w _U_, gpointer d _U_) +{ + goto_conversation_frame(FALSE); +} + +void +goto_previous_frame_conversation_cb(GtkWidget *w _U_, gpointer d _U_) +{ + goto_conversation_frame(TRUE); +} + + /* * Main menu. * @@ -778,6 +827,10 @@ static GtkItemFactoryEntry menu_items[] = GTK_MENU_FUNC(goto_top_frame_cb), 0, "", GTK_STOCK_GOTO_TOP,}, {"/Go/_Last Packet", "End", GTK_MENU_FUNC(goto_bottom_frame_cb), 0, "", GTK_STOCK_GOTO_BOTTOM,}, + {"/Go/Previous Packet In Conversation", "bracketleft", + GTK_MENU_FUNC(goto_previous_frame_conversation_cb), 0, NULL, NULL,}, + {"/Go/Next Packet In Conversation", "bracketright", + GTK_MENU_FUNC(goto_next_frame_conversation_cb), 0, NULL, NULL,}, #ifdef HAVE_LIBPCAP {"/_Capture", NULL, NULL, 0, "", NULL,}, {"/Capture/_Interfaces...", "I", @@ -1476,6 +1529,8 @@ Not implemented! " \n" " \n" " \n" +" \n" +" \n" " \n" #ifdef HAVE_LIBPCAP " \n" @@ -1772,6 +1827,8 @@ Not implemeted. { "/Go/NextPacket", GTK_STOCK_GO_DOWN, "Next Packet", "Down", NULL, G_CALLBACK(goto_next_frame_cb) }, { "/Go/FirstPacket", GTK_STOCK_GOTO_TOP, "F_irst Packet", "Home", NULL, G_CALLBACK(goto_top_frame_cb) }, { "/Go/LastPacket", GTK_STOCK_GOTO_BOTTOM, "_Last Packet", "End", NULL, G_CALLBACK(goto_bottom_frame_cb) }, + { "/Go/PreviousPacketInConversation", GTK_STOCK_GO_UP, "Previous Packet In Conversation", "bracketleft", NULL, G_CALLBACK(goto_previous_frame_conversation_cb) }, + { "/Go/NextPacketInConversation", GTK_STOCK_GO_DOWN, "Next Packet In Conversation", "bracketright", NULL, G_CALLBACK(goto_next_frame_conversation_cb) }, #ifdef HAVE_LIBPCAP { "/Capture/Interfaces", WIRESHARK_STOCK_CAPTURE_INTERFACES, "_Interfaces...", "I", NULL, G_CALLBACK(capture_if_cb) }, @@ -5732,6 +5789,10 @@ set_menus_for_captured_packets(gboolean have_captured_packets) have_captured_packets); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/LastPacket", have_captured_packets); + set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/PreviousPacketInConversation", + have_captured_packets); + set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/NextPacketInConversation", + have_captured_packets); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/Summary", have_captured_packets); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/ProtocolHierarchy", @@ -5759,6 +5820,10 @@ set_menus_for_captured_packets(gboolean have_captured_packets) have_captured_packets); set_menu_sensitivity_old(main_menu_factory, "/Go/Last Packet", have_captured_packets); + set_menu_sensitivity_old(main_menu_factory, "/Go/Previous Packet In Conversation", + have_captured_packets); + set_menu_sensitivity_old(main_menu_factory, "/Go/Next Packet In Conversation", + have_captured_packets); set_menu_sensitivity_old(main_menu_factory, "/Statistics/Summary", have_captured_packets); set_menu_sensitivity_old(main_menu_factory, "/Statistics/Protocol Hierarchy",