aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2018-04-14 08:15:01 +0200
committerRoland Knall <rknall@gmail.com>2018-04-15 05:45:32 +0000
commit9c5049a80b635d5d12829a4c51db9696dadaee00 (patch)
treebc96aadd93f726d01c65277bd3f8e91d7b382fc7 /ui
parentf5330163396c85e080ffff1348df8e12c78f2411 (diff)
Gtk: Remove source code
Removing all gtk source code, except for main.? which will remain for the official removal during SFUS18 Change-Id: I4273baf207df1eaaa4b94623cfd10bf74b1fc4a4 Reviewed-on: https://code.wireshark.org/review/26937 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/.editorconfig217
-rw-r--r--ui/gtk/CMakeLists.txt349
-rw-r--r--ui/gtk/CMakeListsCustom.txt.example31
-rw-r--r--ui/gtk/Makefile.am440
-rw-r--r--ui/gtk/Makefile_custom.common12
-rw-r--r--ui/gtk/STATUS.gtk341
-rw-r--r--ui/gtk/about_dlg.c628
-rw-r--r--ui/gtk/about_dlg.h61
-rw-r--r--ui/gtk/addr_resolution_dlg.c344
-rw-r--r--ui/gtk/addr_resolution_dlg.h28
-rw-r--r--ui/gtk/airpcap_dlg.c2697
-rw-r--r--ui/gtk/airpcap_dlg.h63
-rw-r--r--ui/gtk/airpcap_gui_utils.c2377
-rw-r--r--ui/gtk/airpcap_gui_utils.h305
-rw-r--r--ui/gtk/bytes_view.c1499
-rw-r--r--ui/gtk/bytes_view.h51
-rw-r--r--ui/gtk/capture_dlg.c6243
-rw-r--r--ui/gtk/capture_dlg.h109
-rw-r--r--ui/gtk/capture_file_dlg.c2365
-rw-r--r--ui/gtk/capture_file_dlg.h117
-rw-r--r--ui/gtk/capture_if_details_dlg_win32.c2415
-rw-r--r--ui/gtk/capture_if_details_dlg_win32.h43
-rw-r--r--ui/gtk/capture_if_dlg.c978
-rw-r--r--ui/gtk/capture_if_dlg.h77
-rw-r--r--ui/gtk/capture_info_dlg.c389
-rw-r--r--ui/gtk/cfilter_combo_utils.h33
-rw-r--r--ui/gtk/color_dlg.c1124
-rw-r--r--ui/gtk/color_dlg.h53
-rw-r--r--ui/gtk/color_edit_dlg.c663
-rw-r--r--ui/gtk/color_edit_dlg.h49
-rw-r--r--ui/gtk/color_utils.c95
-rw-r--r--ui/gtk/color_utils.h74
-rw-r--r--ui/gtk/compare_stat.c1078
-rw-r--r--ui/gtk/conversation_hastables_dlg.c176
-rw-r--r--ui/gtk/conversation_hastables_dlg.h30
-rw-r--r--ui/gtk/conversations_table.c2608
-rw-r--r--ui/gtk/conversations_table.h76
-rw-r--r--ui/gtk/dcerpc_stat.c689
-rw-r--r--ui/gtk/decode_as_dlg.c1513
-rw-r--r--ui/gtk/decode_as_dlg.h65
-rw-r--r--ui/gtk/dfilter_expr_dlg.c1228
-rw-r--r--ui/gtk/dfilter_expr_dlg.h39
-rw-r--r--ui/gtk/dissector_tables_dlg.c442
-rw-r--r--ui/gtk/dissector_tables_dlg.h23
-rw-r--r--ui/gtk/dlg_utils.c565
-rw-r--r--ui/gtk/dlg_utils.h154
-rw-r--r--ui/gtk/doxygen.cfg.in67
-rw-r--r--ui/gtk/drag_and_drop.c316
-rw-r--r--ui/gtk/drag_and_drop.h38
-rw-r--r--ui/gtk/edit_packet_comment_dlg.c259
-rw-r--r--ui/gtk/edit_packet_comment_dlg.h30
-rw-r--r--ui/gtk/expert_comp_dlg.c1067
-rw-r--r--ui/gtk/expert_comp_dlg.h29
-rw-r--r--ui/gtk/expert_comp_table.c877
-rw-r--r--ui/gtk/expert_comp_table.h91
-rw-r--r--ui/gtk/export_object_dlg.c492
-rw-r--r--ui/gtk/export_object_dlg.h32
-rw-r--r--ui/gtk/export_pdu_dlg.c187
-rw-r--r--ui/gtk/export_pdu_dlg.h43
-rw-r--r--ui/gtk/export_sslkeys.c196
-rw-r--r--ui/gtk/export_sslkeys.h35
-rw-r--r--ui/gtk/extcap_gtk.c960
-rw-r--r--ui/gtk/extcap_gtk.h125
-rw-r--r--ui/gtk/file_dlg.c474
-rw-r--r--ui/gtk/file_dlg.h133
-rw-r--r--ui/gtk/file_import_dlg.c1224
-rw-r--r--ui/gtk/file_import_dlg.h30
-rw-r--r--ui/gtk/fileset_dlg.c414
-rw-r--r--ui/gtk/fileset_dlg.h63
-rw-r--r--ui/gtk/filter_autocomplete.c899
-rw-r--r--ui/gtk/filter_autocomplete.h53
-rw-r--r--ui/gtk/filter_dlg.c1399
-rw-r--r--ui/gtk/filter_dlg.h132
-rw-r--r--ui/gtk/filter_expression_save_dlg.c354
-rw-r--r--ui/gtk/filter_expression_save_dlg.h37
-rw-r--r--ui/gtk/filter_utils.c118
-rw-r--r--ui/gtk/filter_utils.h65
-rw-r--r--ui/gtk/find_dlg.c803
-rw-r--r--ui/gtk/find_dlg.h59
-rw-r--r--ui/gtk/firewall_dlg.c549
-rw-r--r--ui/gtk/firewall_dlg.h30
-rw-r--r--ui/gtk/flow_graph.c431
-rw-r--r--ui/gtk/follow_stream.c1259
-rw-r--r--ui/gtk/follow_stream.h86
-rw-r--r--ui/gtk/font_utils.c378
-rw-r--r--ui/gtk/font_utils.h67
-rw-r--r--ui/gtk/funnel_stat.c655
-rw-r--r--ui/gtk/goto_dlg.c180
-rw-r--r--ui/gtk/goto_dlg.h74
-rw-r--r--ui/gtk/graph_analysis.c1839
-rw-r--r--ui/gtk/graph_analysis.h111
-rw-r--r--ui/gtk/gsm_map_summary.c429
-rw-r--r--ui/gtk/gtk_iface_monitor.c127
-rw-r--r--ui/gtk/gtk_iface_monitor.h36
-rw-r--r--ui/gtk/gtkglobals.h59
-rw-r--r--ui/gtk/gui_stat_menu.h185
-rw-r--r--ui/gtk/gui_stat_util.c128
-rw-r--r--ui/gtk/gui_stat_util.h60
-rw-r--r--ui/gtk/gui_utils.c2097
-rw-r--r--ui/gtk/gui_utils.h682
-rw-r--r--ui/gtk/help_dlg.c114
-rw-r--r--ui/gtk/help_dlg.h56
-rw-r--r--ui/gtk/hostlist_table.c1281
-rw-r--r--ui/gtk/hostlist_table.h108
-rw-r--r--ui/gtk/iax2_analysis.c3678
-rw-r--r--ui/gtk/io_stat.c2197
-rw-r--r--ui/gtk/keys.h125
-rw-r--r--ui/gtk/lbm_stream_dlg.c775
-rw-r--r--ui/gtk/lbm_stream_dlg.h45
-rw-r--r--ui/gtk/mac_lte_stat_dlg.c1434
-rw-r--r--ui/gtk/macros_dlg.c71
-rw-r--r--ui/gtk/macros_dlg.h29
-rw-r--r--ui/gtk/main.gresources.xml65
-rw-r--r--ui/gtk/main_80211_toolbar.c433
-rw-r--r--ui/gtk/main_80211_toolbar.h32
-rw-r--r--ui/gtk/main_airpcap_toolbar.c429
-rw-r--r--ui/gtk/main_airpcap_toolbar.h31
-rw-r--r--ui/gtk/main_filter_toolbar.c461
-rw-r--r--ui/gtk/main_filter_toolbar.h33
-rw-r--r--ui/gtk/main_menubar.c5439
-rw-r--r--ui/gtk/main_menubar_private.h63
-rw-r--r--ui/gtk/main_statusbar.c1138
-rw-r--r--ui/gtk/main_statusbar_private.h40
-rw-r--r--ui/gtk/main_titlebar.c127
-rw-r--r--ui/gtk/main_titlebar.h38
-rw-r--r--ui/gtk/main_toolbar.c486
-rw-r--r--ui/gtk/main_toolbar.h48
-rw-r--r--ui/gtk/main_toolbar_private.h72
-rw-r--r--ui/gtk/main_welcome.c1580
-rw-r--r--ui/gtk/main_welcome.h69
-rw-r--r--ui/gtk/main_welcome_private.h34
-rw-r--r--ui/gtk/manual_addr_resolv.c212
-rw-r--r--ui/gtk/manual_addr_resolv.h29
-rw-r--r--ui/gtk/mcast_stream_dlg.c858
-rw-r--r--ui/gtk/mcast_stream_dlg.h56
-rw-r--r--ui/gtk/memory_dlg.c740
-rw-r--r--ui/gtk/menus.h111
-rw-r--r--ui/gtk/mtp3_summary.c563
-rw-r--r--ui/gtk/old-gtk-compat.h121
-rw-r--r--ui/gtk/packet_history.c193
-rw-r--r--ui/gtk/packet_history.h34
-rw-r--r--ui/gtk/packet_list.c1733
-rw-r--r--ui/gtk/packet_list.h141
-rw-r--r--ui/gtk/packet_list_store.c1287
-rw-r--r--ui/gtk/packet_list_store.h102
-rw-r--r--ui/gtk/packet_panes.c1443
-rw-r--r--ui/gtk/packet_panes.h240
-rw-r--r--ui/gtk/packet_win.c400
-rw-r--r--ui/gtk/packet_win.h50
-rw-r--r--ui/gtk/pixbuf-csource.c10489
-rw-r--r--ui/gtk/pixbuf-csource.h57
-rw-r--r--ui/gtk/pixmap_save.c187
-rw-r--r--ui/gtk/pixmap_save.h36
-rw-r--r--ui/gtk/plugins_dlg.c136
-rw-r--r--ui/gtk/plugins_dlg.h49
-rw-r--r--ui/gtk/prefs_capture.c2210
-rw-r--r--ui/gtk/prefs_capture.h55
-rw-r--r--ui/gtk/prefs_column.c772
-rw-r--r--ui/gtk/prefs_column.h56
-rw-r--r--ui/gtk/prefs_dlg.c1838
-rw-r--r--ui/gtk/prefs_dlg.h184
-rw-r--r--ui/gtk/prefs_filter_expressions.c92
-rw-r--r--ui/gtk/prefs_filter_expressions.h37
-rw-r--r--ui/gtk/prefs_font_color.c557
-rw-r--r--ui/gtk/prefs_font_color.h57
-rw-r--r--ui/gtk/prefs_gui.c583
-rw-r--r--ui/gtk/prefs_gui.h56
-rw-r--r--ui/gtk/prefs_layout.c531
-rw-r--r--ui/gtk/prefs_layout.h55
-rw-r--r--ui/gtk/print_dlg.c1253
-rw-r--r--ui/gtk/profile_dlg.c1003
-rw-r--r--ui/gtk/profile_dlg.h67
-rw-r--r--ui/gtk/progress_dlg.c422
-rw-r--r--ui/gtk/proto_dlg.c913
-rw-r--r--ui/gtk/proto_dlg.h60
-rw-r--r--ui/gtk/proto_hier_stats_dlg.c609
-rw-r--r--ui/gtk/proto_hier_stats_dlg.h37
-rw-r--r--ui/gtk/proto_hier_tree_model.c500
-rw-r--r--ui/gtk/proto_hier_tree_model.h48
-rw-r--r--ui/gtk/proto_tree_model.c486
-rw-r--r--ui/gtk/proto_tree_model.h40
-rw-r--r--ui/gtk/range_utils.c734
-rw-r--r--ui/gtk/range_utils.h63
-rw-r--r--ui/gtk/response_time_delay_table.c399
-rw-r--r--ui/gtk/response_time_delay_table.h43
-rw-r--r--ui/gtk/rlc_lte_graph.c2733
-rw-r--r--ui/gtk/rlc_lte_stat_dlg.c1685
-rw-r--r--ui/gtk/rpc_stat.c532
-rw-r--r--ui/gtk/rtp_analysis.c4026
-rw-r--r--ui/gtk/rtp_player.c2516
-rw-r--r--ui/gtk/rtp_player.h45
-rw-r--r--ui/gtk/rtp_stream_dlg.c1200
-rw-r--r--ui/gtk/rtp_stream_dlg.h54
-rw-r--r--ui/gtk/sctp_assoc_analyse.c1120
-rw-r--r--ui/gtk/sctp_byte_graph_dlg.c1551
-rw-r--r--ui/gtk/sctp_chunk_stat.c341
-rw-r--r--ui/gtk/sctp_chunk_stat_dlg.c822
-rw-r--r--ui/gtk/sctp_error_dlg.c312
-rw-r--r--ui/gtk/sctp_graph_dlg.c1908
-rw-r--r--ui/gtk/sctp_stat_dlg.c713
-rw-r--r--ui/gtk/sctp_stat_gtk.h160
-rw-r--r--ui/gtk/service_response_time_table.c889
-rw-r--r--ui/gtk/service_response_time_table.h104
-rw-r--r--ui/gtk/simple_dialog.c567
-rw-r--r--ui/gtk/simple_dialog.h91
-rw-r--r--ui/gtk/simple_stattable.c303
-rw-r--r--ui/gtk/simple_stattable.h38
-rw-r--r--ui/gtk/stats_tree_stat.c618
-rw-r--r--ui/gtk/stock_icons.c631
-rw-r--r--ui/gtk/stock_icons.h665
-rw-r--r--ui/gtk/summary_dlg.c1008
-rw-r--r--ui/gtk/summary_dlg.h41
-rw-r--r--ui/gtk/supported_protos_dlg.c356
-rw-r--r--ui/gtk/supported_protos_dlg.h43
-rw-r--r--ui/gtk/tap_param_dlg.c430
-rw-r--r--ui/gtk/tap_param_dlg.h89
-rw-r--r--ui/gtk/tcp_graph.c4546
-rw-r--r--ui/gtk/text_page_utils.c162
-rw-r--r--ui/gtk/text_page_utils.h57
-rw-r--r--ui/gtk/time_shift_dlg.c484
-rw-r--r--ui/gtk/time_shift_dlg.h33
-rw-r--r--ui/gtk/uat_gui.c1164
-rw-r--r--ui/gtk/uat_gui.h33
-rw-r--r--ui/gtk/voip_calls_dlg.c977
-rw-r--r--ui/gtk/voip_calls_dlg.h46
-rw-r--r--ui/gtk/webbrowser.c487
-rw-r--r--ui/gtk/webbrowser.h35
-rw-r--r--ui/gtk/wlan_stat_dlg.c2017
-rw-r--r--ui/win32/print_win32.c267
-rw-r--r--ui/win32/print_win32.h24
230 files changed, 0 insertions, 142700 deletions
diff --git a/ui/gtk/.editorconfig b/ui/gtk/.editorconfig
deleted file mode 100644
index 84e07a6ae5..0000000000
--- a/ui/gtk/.editorconfig
+++ /dev/null
@@ -1,217 +0,0 @@
-#
-# Editor configuration
-#
-# http://editorconfig.org/
-#
-
-[about_dlg.[ch]]
-indent_size = 2
-
-[bytes_view.[ch]]
-indent_style = tab
-indent_size = tab
-
-[capture_dlg.[ch]]
-indent_size = 2
-
-[capture_file_dlg.[ch]]
-indent_size = 2
-
-[capture_if_dlg.[ch]]
-indent_size = 2
-
-[capture_info_dlg.[ch]]
-indent_size = 2
-
-[color_dlg.[ch]]
-indent_size = 2
-
-[color_edit_dlg.[ch]]
-indent_size = 2
-
-[color_utils.[ch]]
-indent_style = tab
-indent_size = tab
-
-[compare_stat.[ch]]
-indent_style = tab
-indent_size = tab
-
-[dcerpc_stat.[ch]]
-indent_style = tab
-indent_size = tab
-
-[edit_packet_comment_dlg.[ch]]
-indent_size = 2
-
-[export_object_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[filter_autocomplete.[ch]]
-indent_size = 2
-
-[filter_expression_save_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[filter_utils.[ch]]
-indent_style = tab
-indent_size = tab
-
-[find_dlg.[ch]]
-indent_size = 2
-
-[flow_graph.[ch]]
-indent_style = tab
-indent_size = tab
-
-[goto_dlg.[ch]]
-indent_size = 2
-
-[graph_analysis.[ch]]
-indent_style = tab
-indent_size = tab
-
-[gsm_map_summary.[ch]]
-indent_size = 2
-
-[gui_stat_util.[ch]]
-indent_style = tab
-indent_size = tab
-
-[iax2_analysis.[ch]]
-indent_style = tab
-indent_size = tab
-
-[macros_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[manual_addr_resolv.[ch]]
-indent_size = 2
-
-[packet_list.[ch]]
-indent_style = tab
-indent_size = tab
-
-[packet_list_store.[ch]]
-indent_style = tab
-indent_size = tab
-
-[packet_win.[ch]]
-indent_style = tab
-indent_size = tab
-
-[pixmap_save.[ch]]
-indent_style = tab
-indent_size = tab
-
-[prefs_capture.[ch]]
-indent_style = tab
-indent_size = tab
-
-[prefs_dlg.[ch]]
-indent_size = 2
-
-[prefs_font_color.[ch]]
-indent_size = 2
-
-[prefs_gui.[ch]]
-indent_style = tab
-indent_size = tab
-
-[print_dlg.[ch]]
-indent_size = 2
-
-[profile_dlg.[ch]]
-indent_size = 2
-
-[proto_dlg.[ch]]
-indent_size = 2
-
-[proto_hier_tree_model.[ch]]
-indent_style = tab
-indent_size = tab
-
-[proto_tree_model.[ch]]
-indent_style = tab
-indent_size = tab
-
-[range_utils.[ch]]
-indent_size = 2
-
-[response_time_delay_table.[ch]]
-indent_style = tab
-indent_size = tab
-
-[rpc_stat.[ch]]
-indent_style = tab
-indent_size = tab
-
-[rtp_analysis.[ch]]
-indent_style = tab
-indent_size = tab
-
-[rtp_player.[ch]]
-indent_style = tab
-indent_size = tab
-
-[sctp_assoc_analyse.[ch]]
-indent_style = tab
-indent_size = tab
-
-[sctp_byte_graph_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[sctp_chunk_stat.[ch]]
-indent_style = tab
-indent_size = tab
-
-[sctp_error_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[sctp_graph_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[sctp_stat_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[service_response_time_table.[ch]]
-indent_style = tab
-indent_size = tab
-
-[simple_dialog.[ch]]
-indent_size = 2
-
-[simple_stattable.[ch]]
-indent_style = tab
-indent_size = tab
-
-[stats_tree_stat.[ch]]
-indent_style = tab
-indent_size = tab
-
-[summary_dlg.[ch]]
-indent_size = 2
-
-[supported_protos_dlg.[ch]]
-indent_size = 2
-
-[time_shift_dlg.[ch]]
-indent_size = 2
-
-[uat_gui.[ch]]
-indent_style = tab
-indent_size = tab
-
-[voip_calls_dlg.[ch]]
-indent_style = tab
-indent_size = tab
-
-[webbrowser.[ch]]
-indent_size = 2
diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt
deleted file mode 100644
index 173f02780c..0000000000
--- a/ui/gtk/CMakeLists.txt
+++ /dev/null
@@ -1,349 +0,0 @@
-# CMakeLists.txt
-#
-# 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
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-ADD_CUSTOM_CMAKE_INCLUDE()
-
-set(WIRESHARK_GTK_SRC
- about_dlg.c
- addr_resolution_dlg.c
- bytes_view.c
- capture_dlg.c
- capture_file_dlg.c
- capture_if_dlg.c
- capture_info_dlg.c
- color_dlg.c
- color_edit_dlg.c
- color_utils.c
- conversation_hastables_dlg.c
- conversations_table.c
- decode_as_dlg.c
- dfilter_expr_dlg.c
- dissector_tables_dlg.c
- dlg_utils.c
- drag_and_drop.c
- edit_packet_comment_dlg.c
- expert_comp_table.c
- export_object_dlg.c
- export_pdu_dlg.c
- export_sslkeys.c
- extcap_gtk.c
- filter_autocomplete.c
- file_dlg.c
- file_import_dlg.c
- fileset_dlg.c
- filter_dlg.c
- filter_expression_save_dlg.c
- filter_utils.c
- find_dlg.c
- firewall_dlg.c
- follow_stream.c
- font_utils.c
- goto_dlg.c
- graph_analysis.c
- gtk_iface_monitor.c
- gui_stat_util.c
- gui_utils.c
- help_dlg.c
- hostlist_table.c
- macros_dlg.c
- main.c
- main_80211_toolbar.c
- main_filter_toolbar.c
- main_menubar.c
- main_statusbar.c
- main_titlebar.c
- main_toolbar.c
- main_welcome.c
- manual_addr_resolv.c
- packet_history.c
- packet_list_store.c
- packet_list.c
- packet_panes.c
- packet_win.c
- pixmap_save.c
- plugins_dlg.c
- prefs_capture.c
- prefs_column.c
- prefs_dlg.c
- prefs_filter_expressions.c
- prefs_gui.c
- prefs_layout.c
- prefs_font_color.c
- print_dlg.c
- profile_dlg.c
- progress_dlg.c
- proto_dlg.c
- proto_hier_stats_dlg.c
- proto_hier_tree_model.c
- proto_tree_model.c
- range_utils.c
- response_time_delay_table.c
- sctp_byte_graph_dlg.c
- sctp_error_dlg.c
- sctp_graph_dlg.c
- service_response_time_table.c
- simple_dialog.c
- simple_stattable.c
- stock_icons.c
- summary_dlg.c
- supported_protos_dlg.c
- tap_param_dlg.c
- text_page_utils.c
- time_shift_dlg.c
- uat_gui.c
- webbrowser.c
- ${WIRESHARK_CUSTOM_GTK_SRC}
-)
-
-if (AIRPCAP_FOUND)
- set(WIRESHARK_GTK_SRC
- ${WIRESHARK_GTK_SRC}
- airpcap_dlg.c
- airpcap_gui_utils.c
- main_airpcap_toolbar.c
- )
-endif()
-
-if(PORTAUDIO_FOUND)
- set(WIRESHARK_GTK_SRC
- ${WIRESHARK_GTK_SRC}
- rtp_player.c
- )
-
- # For Win32, there is no PortAudio lib, we compile the files locally
- if(WIN32)
- add_definitions(
- -DPA_NO_DS
- -DPA_NO_ASIO
- )
- set(PORTAUDIO_SRC
- ${PORTAUDIO_SRC_DIR}/common/pa_allocation.c
- ${PORTAUDIO_SRC_DIR}/common/pa_converters.c
- ${PORTAUDIO_SRC_DIR}/common/pa_cpuload.c
- ${PORTAUDIO_SRC_DIR}/common/pa_dither.c
- ${PORTAUDIO_SRC_DIR}/common/pa_front.c
- ${PORTAUDIO_SRC_DIR}/common/pa_process.c
- ${PORTAUDIO_SRC_DIR}/common/pa_skeleton.c
- ${PORTAUDIO_SRC_DIR}/common/pa_stream.c
- ${PORTAUDIO_SRC_DIR}/common/pa_trace.c
- ${PORTAUDIO_SRC_DIR}/os/win/pa_win_hostapis.c
- ${PORTAUDIO_SRC_DIR}/os/win/pa_win_util.c
- ${PORTAUDIO_SRC_DIR}/os/win/pa_x86_plain_converters.c
- ${PORTAUDIO_SRC_DIR}/os/win/pa_win_waveformat.c
- ${PORTAUDIO_SRC_DIR}/hostapi/wmme/pa_win_wmme.c
- )
- add_library(portaudio OBJECT
- ${PORTAUDIO_SRC}
- )
- set_target_properties(portaudio PROPERTIES
- INCLUDE_DIRECTORIES "${PORTAUDIO_INCLUDE_DIRS}"
- FOLDER "UI")
-
- # Portaudio has some warnings, annoyingly the combination of CMake
- # and MSBuild means that just disabling the warnings on the specific
- # source files doesn't work, so set them to level 4 for the target
- #set_source_files_properties(${PORTAUDIO_SRC_DIR}/common/pa_front.c
- # PROPERTIES
- # COMPILE_FLAGS "/wd4189"
- #)
- #set_source_files_properties(${PORTAUDIO_SRC_DIR}/os/win/pa_x86_plain_converters.c
- # PROPERTIES
- # COMPILE_FLAGS "/wd4305"
- #)
- target_compile_options(portaudio
- PUBLIC "/w44189"
- PUBLIC "/w44305"
- )
-
- # Portaudio has some size_t > long warnings as a result of using strlen()
- # and other warnings on x64.
- if ("${WIRESHARK_TARGET_PLATFORM}" STREQUAL "win64")
- #set_source_files_properties(${PORTAUDIO_SRC_DIR}/hostapi/wmme/pa_win_wmme.c
- # PROPERTIES
- # COMPILE_FLAGS "/wd4267"
- #)
- target_compile_options(portaudio
- PUBLIC "/w44267"
- PUBLIC "/w44311"
- PUBLIC "/w44312"
- )
- endif()
- endif()
-endif()
-
-set(WIRESHARK_TAP_SRC
- ${CMAKE_CURRENT_SOURCE_DIR}/compare_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/dcerpc_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/expert_comp_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/flow_graph.c
- ${CMAKE_CURRENT_SOURCE_DIR}/funnel_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/gsm_map_summary.c
- ${CMAKE_CURRENT_SOURCE_DIR}/iax2_analysis.c
- ${CMAKE_CURRENT_SOURCE_DIR}/io_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/lbm_stream_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/mac_lte_stat_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/mcast_stream_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/mtp3_summary.c
- ${CMAKE_CURRENT_SOURCE_DIR}/rlc_lte_graph.c
- ${CMAKE_CURRENT_SOURCE_DIR}/rlc_lte_stat_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/rpc_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/rtp_analysis.c
- ${CMAKE_CURRENT_SOURCE_DIR}/rtp_stream_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sctp_assoc_analyse.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sctp_chunk_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sctp_chunk_stat_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sctp_stat_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/stats_tree_stat.c
- ${CMAKE_CURRENT_SOURCE_DIR}/tcp_graph.c
- ${CMAKE_CURRENT_SOURCE_DIR}/voip_calls_dlg.c
- ${CMAKE_CURRENT_SOURCE_DIR}/wlan_stat_dlg.c
- ${WIRESHARK_CUSTOM_TAP_SRC}
-)
-
-if (ENABLE_GTK3)
- add_definitions(
- ${GTK3_DEFINITIONS}
- -DGDK_DISABLE_DEPRECATION_WARNINGS
- )
-else()
- add_definitions(
- # We are only allowed to include gtk/gtk.h, no other files. When
- # violating this with gtk3 the compiler will complain anyway.
- -DGTK_DISABLE_SINGLE_INCLUDES
-
- # GTK+ 3 removes many implementation details and struct members from its
- # public headers. Make the compiler catch all uses of direct access to
- # struct fields so that you can go through them one by one and replace
- # them with a call to an accessor function instead.
- -DGSEAL_ENABLE
-
- # To verify that your program does not use any deprecated symbols,
- # you can use defines to remove deprecated symbols from the header files
- # -DGDK_DISABLE_DEPRECATED
- -DGTK_DISABLE_DEPRECATED
- )
-endif()
-
-if(WIN32)
- set(PLATFORM_UI_SRC
- capture_if_details_dlg_win32.c
- )
-endif()
-
-set(GTKUI_FILES
- ${WIRESHARK_GTK_SRC}
- ${WIRESHARK_TAP_SRC}
- ${PLATFORM_UI_SRC}
-)
-
-set_source_files_properties(
- ${GTKUI_FILES}
- PROPERTIES
- COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS}"
-)
-
-register_tap_files(wireshark-tap-register.c
- ${WIRESHARK_TAP_SRC}
-)
-
-if(WIN32)
- set(PORTAUDIO_OBJ $<TARGET_OBJECTS:portaudio>)
-endif()
-
-find_program(GLIB_COMPILE_RESOURCES_EXECUTABLE
- glib-compile-resources
- HINTS
- "${GLIB2_HINTS}/bin"
-)
-
-pkg_check_modules(GRESOURCE QUIET gio-2.0>=2.32 gdk-pixbuf-2.0>=2.26)
-
-macro(WIRESHARK_GRESOURCES _outputfile _resourcefile)
- add_custom_command(
- OUTPUT ${_outputfile}
- COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE} --sourcedir=${CMAKE_SOURCE_DIR} --target=${_outputfile} --generate --manual-register ${CMAKE_CURRENT_SOURCE_DIR}/${_resourcefile}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_resourcefile}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )
-endmacro(WIRESHARK_GRESOURCES)
-
-WIRESHARK_GRESOURCES(wireshark-gresources.h main.gresources.xml)
-
-WIRESHARK_GRESOURCES(wireshark-gresources.c main.gresources.xml)
-
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-if(GRESOURCE_FOUND AND NOT WIN32)
- set(PIXBUF_SRC
- wireshark-gresources.c
- wireshark-gresources.h
- )
- add_definitions(-DHAVE_GDK_GRESOURCE)
-else()
- set(PIXBUF_SRC
- pixbuf-csource.c
- )
-endif()
-
-add_library(gtkui STATIC
- ${GTKUI_FILES}
- ${PORTAUDIO_OBJ}
- wireshark-tap-register.c
- ${PIXBUF_SRC}
-)
-set_target_properties(gtkui PROPERTIES
- LINK_FLAGS "${WS_LINK_FLAGS}"
- FOLDER "UI"
-)
-
-CHECKAPI(
- NAME
- gtk-base
- SWITCHES
- -g deprecated-gtk
- SOURCES
- ${WIRESHARK_GTK_SRC}
- ${WIRESHARK_TAP_SRC}
- ${PLATFORM_UI_SRC}
-)
-CHECKAPI(
- NAME
- gtk-todo
- SWITCHES
- -M -g deprecated-gtk-todo
- SOURCES
- ${WIRESHARK_GTK_SRC}
- ${WIRESHARK_TAP_SRC}
- ${PLATFORM_UI_SRC}
-)
-
-#
-# Editor modelines - http://www.wireshark.org/tools/modelines.html
-#
-# Local variables:
-# c-basic-offset: 8
-# tab-width: 8
-# indent-tabs-mode: t
-# End:
-#
-# vi: set shiftwidth=8 tabstop=8 noexpandtab:
-# :indentSize=8:tabSize=8:noTabs=false:
-#
diff --git a/ui/gtk/CMakeListsCustom.txt.example b/ui/gtk/CMakeListsCustom.txt.example
deleted file mode 100644
index 57ff1b7a02..0000000000
--- a/ui/gtk/CMakeListsCustom.txt.example
+++ /dev/null
@@ -1,31 +0,0 @@
-# CMakeListsCustom.txt
-#
-# 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
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# You can add custom GUI files here by replacing the commented out file foo with your file.
-
-#Add GUI source files here
-set(WIRESHARK_CUSTOM_GTK_SRC
-# foo.c
-)
-
-#Add your tap source files here:
-set(WIRESHARK_CUSTOM_TAP_SRC
-# tap_foo.c
-)
diff --git a/ui/gtk/Makefile.am b/ui/gtk/Makefile.am
deleted file mode 100644
index 23d70fb8b2..0000000000
--- a/ui/gtk/Makefile.am
+++ /dev/null
@@ -1,440 +0,0 @@
-# Makefile.am
-# Automake file for the GTK interface routines for Wireshark
-#
-# 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
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-include $(top_srcdir)/Makefile.am.inc
-include Makefile_custom.common
-
-# Generated C source files that we want in the distribution.
-GENERATED_FILES =
-
-# Generated C source files that we don't want in the distribution.
-NODIST_GENERATED_FILES = \
- wireshark-tap-register.c
-
-# Files that generate compileable files
-GENERATOR_FILES = \
- main.gresources.xml
-
-WIRESHARK_COMMON_GTK_SRC = \
- about_dlg.c \
- addr_resolution_dlg.c \
- bytes_view.c \
- capture_dlg.c \
- capture_file_dlg.c \
- capture_if_dlg.c \
- capture_info_dlg.c \
- color_dlg.c \
- color_edit_dlg.c \
- color_utils.c \
- conversation_hastables_dlg.c \
- conversations_table.c \
- decode_as_dlg.c \
- dfilter_expr_dlg.c \
- dissector_tables_dlg.c \
- dlg_utils.c \
- drag_and_drop.c \
- edit_packet_comment_dlg.c \
- expert_comp_table.c \
- export_object_dlg.c \
- export_sslkeys.c \
- extcap_gtk.c \
- filter_autocomplete.c \
- file_dlg.c \
- file_import_dlg.c \
- fileset_dlg.c \
- filter_dlg.c \
- filter_expression_save_dlg.c \
- filter_utils.c \
- find_dlg.c \
- firewall_dlg.c \
- follow_stream.c \
- font_utils.c \
- goto_dlg.c \
- graph_analysis.c \
- gtk_iface_monitor.c \
- gui_stat_util.c \
- gui_utils.c \
- help_dlg.c \
- hostlist_table.c \
- macros_dlg.c \
- main.c \
- main_80211_toolbar.c \
- main_filter_toolbar.c \
- main_menubar.c \
- manual_addr_resolv.c \
- packet_panes.c \
- main_statusbar.c \
- main_titlebar.c \
- main_toolbar.c \
- main_welcome.c \
- packet_history.c \
- packet_list_store.c \
- packet_list.c \
- packet_win.c \
- pixmap_save.c \
- plugins_dlg.c \
- prefs_capture.c \
- prefs_column.c \
- prefs_dlg.c \
- prefs_filter_expressions.c \
- prefs_gui.c \
- prefs_layout.c \
- prefs_font_color.c \
- print_dlg.c \
- profile_dlg.c \
- progress_dlg.c \
- proto_dlg.c \
- proto_hier_stats_dlg.c \
- proto_hier_tree_model.c \
- proto_tree_model.c \
- range_utils.c \
- response_time_delay_table.c \
- rtp_player.c \
- sctp_byte_graph_dlg.c \
- sctp_error_dlg.c \
- sctp_graph_dlg.c \
- service_response_time_table.c \
- simple_dialog.c \
- simple_stattable.c \
- stock_icons.c \
- summary_dlg.c \
- supported_protos_dlg.c \
- tap_param_dlg.c \
- text_page_utils.c \
- time_shift_dlg.c \
- uat_gui.c \
- webbrowser.c \
- $(WIRESHARK_CUSTOM_GTK_SRC)
-
-WIRESHARK_TAP_SRC = \
- compare_stat.c \
- dcerpc_stat.c \
- expert_comp_dlg.c \
- export_pdu_dlg.c \
- flow_graph.c \
- funnel_stat.c \
- gsm_map_summary.c \
- iax2_analysis.c \
- io_stat.c \
- lbm_stream_dlg.c \
- mac_lte_stat_dlg.c \
- mcast_stream_dlg.c \
- mtp3_summary.c \
- rlc_lte_graph.c \
- rlc_lte_stat_dlg.c \
- rpc_stat.c \
- rtp_analysis.c \
- rtp_stream_dlg.c \
- sctp_assoc_analyse.c \
- sctp_chunk_stat.c \
- sctp_chunk_stat_dlg.c \
- sctp_stat_dlg.c \
- stats_tree_stat.c \
- tcp_graph.c \
- voip_calls_dlg.c \
- wlan_stat_dlg.c \
- $(WIRESHARK_CUSTOM_TAP_SRC)
-
-WIRESHARK_COMMON_GTK_HDRS = \
- about_dlg.h \
- addr_resolution_dlg.h \
- bytes_view.h \
- capture_dlg.h \
- capture_file_dlg.h \
- capture_if_dlg.h \
- cfilter_combo_utils.h \
- color_dlg.h \
- color_edit_dlg.h \
- color_utils.h \
- conversation_hastables_dlg.h \
- conversations_table.h \
- decode_as_dlg.h \
- dfilter_expr_dlg.h \
- dissector_tables_dlg.h \
- dlg_utils.h \
- drag_and_drop.h \
- edit_packet_comment_dlg.h \
- expert_comp_dlg.h \
- expert_comp_table.h \
- export_object_dlg.h \
- export_pdu_dlg.h \
- export_sslkeys.h \
- extcap_gtk.h \
- file_dlg.h \
- file_import_dlg.h \
- fileset_dlg.h \
- filter_autocomplete.h \
- filter_dlg.h \
- filter_expression_save_dlg.h \
- filter_utils.h \
- find_dlg.h \
- firewall_dlg.h \
- follow_stream.h \
- font_utils.h \
- goto_dlg.h \
- graph_analysis.h \
- gtk_iface_monitor.h \
- gtkglobals.h \
- gui_stat_menu.h \
- gui_stat_util.h \
- gui_utils.h \
- help_dlg.h \
- hostlist_table.h \
- keys.h \
- lbm_stream_dlg.h \
- macros_dlg.h \
- main.h \
- main_filter_toolbar.h \
- main_menubar_private.h \
- main_80211_toolbar.h \
- menus.h \
- packet_panes.h \
- main_statusbar_private.h \
- main_titlebar.h \
- main_toolbar.h \
- main_toolbar_private.h \
- main_welcome.h \
- main_welcome_private.h \
- manual_addr_resolv.h \
- mcast_stream_dlg.h \
- old-gtk-compat.h \
- packet_history.h \
- packet_list_store.h \
- packet_list.h \
- packet_win.h \
- pixmap_save.h \
- plugins_dlg.h \
- prefs_capture.h \
- prefs_column.h \
- prefs_dlg.h \
- prefs_filter_expressions.h \
- prefs_gui.h \
- prefs_layout.h \
- prefs_font_color.h \
- profile_dlg.h \
- proto_dlg.h \
- proto_hier_stats_dlg.h \
- proto_hier_tree_model.h \
- proto_tree_model.h \
- range_utils.h \
- response_time_delay_table.h \
- rtp_player.h \
- rtp_stream_dlg.h \
- sctp_stat_gtk.h \
- service_response_time_table.h \
- simple_stattable.h \
- time_shift_dlg.h \
- simple_dialog.h \
- stock_icons.h \
- summary_dlg.h \
- supported_protos_dlg.h \
- tap_param_dlg.h \
- text_page_utils.h \
- uat_gui.h \
- voip_calls_dlg.h \
- webbrowser.h \
- $(WIRESHARK_CUSTOM_HDRS)
-
-if HAVE_GRESOURCE_PIXBUF
-NODIST_GENERATED_FILES += \
- wireshark-gresources.h \
- wireshark-gresources.c
-else
-BUILD_PIXBUF_CSOURCE = \
- pixbuf-csource.h \
- pixbuf-csource.c
-endif
-
-AM_CPPFLAGS = $(INCLUDEDIRS) $(WS_CPPFLAGS) $(GTK_CFLAGS) \
- $(PORTAUDIO_INCLUDES)
-
-DISTCLEANFILES = \
- $(NODIST_GENERATED_FILES)
-
-MAINTAINERCLEANFILES = \
- $(GENERATED_FILES)
-
-EXTRA_DIST = \
- .editorconfig \
- $(GENERATOR_FILES) \
- airpcap_dlg.c \
- airpcap_dlg.h \
- airpcap_gui_utils.c \
- airpcap_gui_utils.h \
- capture_if_details_dlg_win32.c \
- capture_if_details_dlg_win32.h \
- CMakeLists.txt \
- doxygen.cfg.in \
- main_airpcap_toolbar.c \
- main_airpcap_toolbar.h \
- Makefile_custom.common \
- pixbuf-csource.c \
- pixbuf-csource.h
-
-BUILT_SOURCES = \
- $(GENERATED_FILES) \
- $(NODIST_GENERATED_FILES)
-
-noinst_LIBRARIES = libgtkui.a
-
-libgtkui_a_SOURCES = \
- $(WIRESHARK_COMMON_GTK_SRC) \
- $(WIRESHARK_COMMON_GTK_HDRS) \
- $(WIRESHARK_TAP_SRC) \
- $(GENERATED_FILES)
-
-nodist_libgtkui_a_SOURCES = \
- $(NODIST_GENERATED_FILES) \
- $(BUILD_PIXBUF_CSOURCE)
-
-wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) ../make-taps
- $(AM_V_GEN)../make-taps $@ $(filter %.c,$^)
-
-wireshark-gresources.c: main.gresources.xml $(shell glib-compile-resources --sourcedir=$(top_srcdir) --generate-dependencies $(srcdir)/main.gresources.xml)
- @echo Making $@
- @glib-compile-resources --sourcedir=$(top_srcdir) --target=$@ --generate --manual-register $<
-
-wireshark-gresources.h: main.gresources.xml
- @echo Making $@
- @glib-compile-resources --sourcedir=$(top_srcdir) --target=$@ --generate --manual-register $<
-
-imagedir = $(top_srcdir)/image
-
-pixbuf_csource_data = \
- expert_chat_pb_data \
- $(imagedir)/stock_icons/14x14/x-expert-chat.png \
- expert_error_pb_data \
- $(imagedir)/stock_icons/14x14/x-expert-error.png \
- expert_none_pb_data \
- $(imagedir)/stock_icons/14x14/x-expert-none.png \
- expert_note_pb_data \
- $(imagedir)/stock_icons/14x14/x-expert-note.png \
- expert_warn_pb_data \
- $(imagedir)/stock_icons/14x14/x-expert-warn.png \
- expert_ok_pb_data \
- $(imagedir)/expert_ok.png \
- capture_comment_add_pb_data \
- $(imagedir)/capture_comment_add.png \
- capture_comment_update_pb_data \
- $(imagedir)/capture_comment_update.png \
- capture_comment_disabled_pb_data \
- $(imagedir)/capture_comment_disabled.png \
- network_bluetooth_pb_data \
- $(imagedir)/toolbar/network_bluetooth_16.png \
- network_usb_pb_data \
- $(imagedir)/toolbar/network_usb_16.png \
- network_wired_pb_data \
- $(imagedir)/toolbar/network_wired_16.png \
- network_wireless_pb_data \
- $(imagedir)/toolbar/network_wireless_16.png \
- remote_arrow_pb_data \
- $(imagedir)/toolbar/remote_arrow_16.png \
- remote_globe_pb_data \
- $(imagedir)/toolbar/remote_globe_16.png \
- remote_sat_pb_data \
- $(imagedir)/toolbar/remote_sat_16.png \
- pipe_pb_data \
- $(imagedir)/toolbar/pipe_16.png \
- capture_interfaces_16_pb_data \
- $(imagedir)/toolbar/capture_interfaces_16.png \
- capture_interfaces_24_pb_data \
- $(imagedir)/toolbar/capture_interfaces_24.png \
- gnome_emblem_web_16_pb_data \
- $(imagedir)/toolbar/gnome_emblem_web_16.png \
- gnome_emblem_web_24_pb_data \
- $(imagedir)/toolbar/gnome_emblem_web_24.png \
- toolbar_wireshark_file_16_pb_data \
- $(imagedir)/stock_icons/16x16/x-capture-file-save.png \
- toolbar_wireshark_file_24_pb_data \
- $(imagedir)/stock_icons/24x24/x-capture-file-save.png \
- capture_options_alt1_16_pb_data \
- $(imagedir)/stock_icons/16x16/x-capture-options.png \
- capture_options_alt1_24_pb_data \
- $(imagedir)/stock_icons/24x24/x-capture-options.png \
- capture_restart_16_pb_data \
- $(imagedir)/stock_icons/16x16/x-capture-restart.png \
- capture_restart_24_pb_data \
- $(imagedir)/stock_icons/24x24/x-capture-restart.png \
- capture_start_16_pb_data \
- $(imagedir)/stock_icons/16x16/x-capture-start.png \
- capture_start_24_pb_data \
- $(imagedir)/stock_icons/24x24/x-capture-start.png \
- capture_stop_16_pb_data \
- $(imagedir)/stock_icons/16x16/x-capture-stop.png \
- capture_stop_24_pb_data \
- $(imagedir)/stock_icons/24x24/x-capture-stop.png \
- layout_1_pb_data \
- $(imagedir)/layout_1.png \
- layout_2_pb_data \
- $(imagedir)/layout_2.png \
- layout_3_pb_data \
- $(imagedir)/layout_3.png \
- layout_4_pb_data \
- $(imagedir)/layout_4.png \
- layout_5_pb_data \
- $(imagedir)/layout_5.png \
- layout_6_pb_data \
- $(imagedir)/layout_6.png \
- wsicon_16_pb_data \
- $(imagedir)/wsicon16.png \
- wsicon_24_pb_data \
- $(imagedir)/wsicon24.png \
- wsicon_32_pb_data \
- $(imagedir)/wsicon32.png \
- wsicon_48_pb_data \
- $(imagedir)/wsicon48.png \
- wsicon_64_pb_data \
- $(imagedir)/wsicon64.png \
- wsiconcap_16_pb_data \
- $(imagedir)/wsiconcap16.png \
- wsiconcap_24_pb_data \
- $(imagedir)/wsiconcap24.png \
- wsiconcap_32_pb_data \
- $(imagedir)/wsiconcap32.png \
- wsiconcap_48_pb_data \
- $(imagedir)/wsiconcap48.png \
- wsiconcap_64_pb_data \
- $(imagedir)/wsiconcap64.png \
- wssplash_pb_data \
- $(imagedir)/wssplash_dev.png
-
-pixbuf-csource:
- $(PERL) $(top_srcdir)/tools/make-pixbuf-csource.pl $@ $(pixbuf_csource_data)
-
-doxygen:
-if HAVE_DOXYGEN
- $(DOXYGEN) doxygen.cfg
-endif
-
-checkapi: checkapi-base checkapi-todo
-
-checkapi-base:
- $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g deprecated-gtk -build \
- -sourcedir=$(srcdir) \
- $(WIRESHARK_CLEAN_LIBGTKUI_SRC) \
- capture_if_details_dlg_win32.c
-
-checkapi-todo:
- $(PERL) $(top_srcdir)/tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \
- -sourcedir=$(srcdir) \
- $(WIRESHARK_GTK_SRC) \
- $(WIRESHARK_TAP_SRC) \
- capture_if_details_dlg_win32.c
diff --git a/ui/gtk/Makefile_custom.common b/ui/gtk/Makefile_custom.common
deleted file mode 100644
index 8f9c9b389f..0000000000
--- a/ui/gtk/Makefile_custom.common
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# You can add custom GUI files here
-#
-
-#Add GUI source files here
-WIRESHARK_CUSTOM_GTK_SRC =
-
-#Add your tap source files here:
-WIRESHARK_CUSTOM_TAP_SRC =
-
-#Add headers here:
-WIRESHARK_CUSTOM_HDRS =
diff --git a/ui/gtk/STATUS.gtk3 b/ui/gtk/STATUS.gtk3
deleted file mode 100644
index 8cf160584c..0000000000
--- a/ui/gtk/STATUS.gtk3
+++ /dev/null
@@ -1,41 +0,0 @@
-Status of the GTK+ 3 port :
-===========================
-
-The port is done. We used the methods described in the "Migrating from
-GTK+ 2.x to GTK+ 3" document at:
-http://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
-
-To build Wireshark with GTK3 instead of GTK2, use:
-
- - cmake: ENABLE_GTK3=ON
- - configure: --with-gtk3
- This will only work if building without gtkvumeter.c (which is used on Windows
- only and only in the WLAN code). It also requires GTK3 to be installed.
- GTK3 for Windows (32 and 64 bit) is now available the same way as GTK2 for
- Windows: Via the svn repo for Wireshark for windows builds.
-
-Except in one place we are building on GTK2 using the compat flags
- -DGTK_DISABLE_SINGLE_INCLUDES
- -DGSEAL_ENABLE
- -DGDK_DISABLE_DEPRECATED
- -DGTK_DISABLE_DEPRECATED
-
-Summary: The only known files that cause some sort of problems (or lost
- functionality) are:
- - gtkvumeter.c (removed, only used for wlan on windows)
- - tcp-graph: the crosshairs are not right
- - audiograph doesn't work
-
-----------------------------------------------------------------------
-
-March 11, 2013:
-
-Various Gtk widgets (GtkTable, GtkColorSelection, ...) deprecated in versions
-of Gtk3 newer than Gtk 3.0.0 have been replaced as appropriate.
-
-Wireshark Gtk3 builds with Gtk 3.6.4 without any "deprecated" warnings.
-
-Fixes to handling of 'expand' in GTK3 have been completed.
-(Essentially: When adding a widget to a [V|H]Box, use gtk_box_pack_start()
- with appropriate args instead of gtk_container_add().
-
diff --git a/ui/gtk/about_dlg.c b/ui/gtk/about_dlg.c
deleted file mode 100644
index 17d0fca8f8..0000000000
--- a/ui/gtk/about_dlg.c
+++ /dev/null
@@ -1,628 +0,0 @@
-/* about_dlg.c
- *
- * Ulf Lamping <ulf.lamping@web.de>
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include <wsutil/filesystem.h>
-#include <wsutil/copyright_info.h>
-#include <version_info.h>
-#ifdef HAVE_LIBSMI
-#include <epan/oids.h>
-#endif
-#ifdef HAVE_GEOIP
-#include <epan/geoip_db.h>
-#endif
-#ifdef HAVE_LUA
-#include <epan/wslua/init_wslua.h>
-#endif
-#include "extcap.h"
-
-#include "../../log.h"
-#include "epan/register.h"
-
-#include "ui/last_open_dir.h"
-
-#include "ui/gtk/about_dlg.h"
-#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/file_dlg.h"
-#include "ui/gtk/text_page_utils.h"
-#include "ui/gtk/gtkglobals.h"
-#include "ui/gtk/main.h"
-#include "ui/gtk/plugins_dlg.h"
-#include "ui/gtk/stock_icons.h"
-#ifndef HAVE_GDK_GRESOURCE
-#include "ui/gtk/pixbuf-csource.h"
-#endif
-
-#include "webbrowser.h"
-
-/*
- * Update frequence for the splash screen, given in milliseconds.
- */
-int info_update_freq = 100;
-
-static void about_wireshark_destroy_cb(GtkWidget *, gpointer);
-
-
-/*
- * Keep a static pointer to the current "About Wireshark" window, if any, so
- * that if somebody tries to do "About Wireshark" while there's already an
- * "About Wireshark" window up, we just pop up the existing one, rather than
- * creating a new one.
- */
-static GtkWidget *about_wireshark_w;
-
-
-static void
-about_wireshark(GtkWidget *parent _U_, GtkWidget *main_vb)
-{
- GtkWidget *msg_label, *icon;
- gchar *message;
- const char *title = "Network Protocol Analyzer";
-
- /*icon = xpm_to_widget_from_parent(parent, wssplash_xpm);*/
-#ifdef HAVE_GDK_GRESOURCE
- icon = pixbuf_to_widget("/org/wireshark/image/wssplash_dev.png");
-#else
- icon = pixbuf_to_widget(wssplash_pb_data);
-#endif
-
- gtk_box_pack_start(GTK_BOX(main_vb), icon, TRUE, TRUE, 0);
-
-
- msg_label = gtk_label_new(title);
- message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
- gtk_label_set_markup(GTK_LABEL(msg_label), message);
- g_free(message);
- gtk_box_pack_start(GTK_BOX(main_vb), msg_label, TRUE, TRUE, 0);
-}
-
-static void
-splash_update_label(GtkWidget *win, const char *message)
-{
- GtkWidget *main_lb;
-
- if (win == NULL) return;
-
- main_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "splash_label");
- gtk_label_set_text(GTK_LABEL(main_lb), message);
-
- /* Process all pending GUI events before continuing, so that
- the splash screen window gets updated. */
- while (gtk_events_pending()) gtk_main_iteration();
-}
-
-GtkWidget*
-splash_new(const char *message)
-{
- GtkWidget *win;
- GtkWidget *main_lb;
-
- GtkWidget *main_box;
- GtkWidget *percentage_box;
- GtkWidget *prog_bar;
- GtkWidget *percentage_lb;
-
- win = splash_window_new();
-
- /* When calling about_wireshark(), we must realize the top-level
- widget for the window, otherwise GTK will throw a warning
- because we don't have a colormap associated with that window and
- can't handle the pixmap. */
- gtk_widget_realize(win);
-
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_box), 24);
- gtk_container_add(GTK_CONTAINER(win), main_box);
-
-
- about_wireshark(win, main_box);
-
- main_lb = gtk_label_new(message);
- gtk_box_pack_start(GTK_BOX(main_box), main_lb, TRUE, TRUE, 0);
- g_object_set_data(G_OBJECT(win), "splash_label", main_lb);
-
- main_lb = gtk_label_new("");
- gtk_box_pack_start(GTK_BOX(main_box), main_lb, TRUE, TRUE, 0);
- g_object_set_data(G_OBJECT(win), "protocol_label", main_lb);
-
- percentage_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
- gtk_box_pack_start(GTK_BOX(main_box), percentage_box, TRUE, TRUE, 3);
-
- prog_bar = gtk_progress_bar_new();
- gtk_box_pack_start(GTK_BOX(percentage_box), prog_bar, TRUE, TRUE, 3);
- g_object_set_data(G_OBJECT(win), "progress_bar", prog_bar);
-
- percentage_lb = gtk_label_new(" 0%");
- gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0f, 0.0f);
- gtk_box_pack_start(GTK_BOX(percentage_box), percentage_lb, FALSE, TRUE, 3);
- g_object_set_data(G_OBJECT(win), "percentage_label", percentage_lb);
-
- gtk_widget_show_all(win);
-
- splash_update_label(win, message);
-
- return win;
-}
-
-void
-splash_update(register_action_e action, const char *message, gpointer client_data)
-{
- GtkWidget *win;
- GtkWidget *main_lb;
- GtkWidget *prog_bar;
- GtkWidget *percentage_lb;
- gfloat percentage;
- gulong ul_percentage;
- gchar tmp[100];
- const char *action_msg;
-
- static gulong ul_sofar = 0;
- static gulong ul_count = 0;
-
- static register_action_e last_action = RA_NONE;
-
- static GTimeVal cur_tv;
- static GTimeVal next_tv = {0, 0};
-
- win = (GtkWidget *)client_data;
-
- if (win == NULL) return;
-
- g_get_current_time(&cur_tv);
- if (last_action == action && cur_tv.tv_sec <= next_tv.tv_sec && cur_tv.tv_usec <= next_tv.tv_usec && ul_sofar < ul_count - 1) {
- /* Only update every splash_register_freq milliseconds */
- ul_sofar++;
- return;
- }
- memcpy(&next_tv, &cur_tv, sizeof(next_tv));
- next_tv.tv_usec += info_update_freq * 1000;
- if (next_tv.tv_usec >= 1000000) {
- next_tv.tv_sec++;
- next_tv.tv_usec -= 1000000;
- }
-
- if(last_action != action) {
- /* the action has changed */
- switch(action) {
- case RA_DISSECTORS:
- action_msg = "Initializing dissectors ...";
- break;
- case RA_LISTENERS:
- action_msg = "Initializing tap listeners ...";
- break;
- case RA_EXTCAP:
- action_msg = "Initializing extcap ...";
- break;
- case RA_REGISTER:
- action_msg = "Registering dissector ...";
- break;
- case RA_PLUGIN_REGISTER:
- action_msg = "Registering plugins ...";
- break;
- case RA_HANDOFF:
- action_msg = "Handing off dissector ...";
- break;
- case RA_PLUGIN_HANDOFF:
- action_msg = "Handing off plugins ...";
- break;
- case RA_LUA_PLUGINS:
- action_msg = "Loading Lua plugins ...";
- break;
- case RA_PREFERENCES:
- action_msg = "Loading module preferences ...";
- break;
- case RA_INTERFACES:
- action_msg = "Finding local interfaces ...";
- break;
- default:
- action_msg = "(Unknown action)";
- break;
- }
- splash_update_label(win, action_msg);
- last_action = action;
- }
-
- if(ul_count == 0) { /* get the count of dissectors */
- ul_count = register_count() + 6; /* additional 6 for:
- dissectors, listeners,
- registering plugins, handingoff plugins,
- preferences, and interfaces */
-#ifdef HAVE_LUA
- ul_count += wslua_count_plugins (); /* get count of lua plugins */
-#endif
- ul_count += extcap_count() + 1; /* Count of extcap binaries + registration message */
- }
-
- main_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "protocol_label");
- /* make_dissector_reg.py changed -
- so we need to strip off the leading elements to get back to the protocol */
- if(message) {
- if(!strncmp(message, "proto_register_", 15))
- message += 15;
- else if(!strncmp(message, "proto_reg_handoff_", 18))
- message += 18;
- }
- gtk_label_set_text(GTK_LABEL(main_lb), message ? message : "");
-
- ul_sofar++;
-
- g_assert (ul_sofar <= ul_count);
-
- percentage = (gfloat)ul_sofar/(gfloat)ul_count;
- ul_percentage = (gulong)(percentage * 100);
-
- /* update progress bar */
- prog_bar = (GtkWidget *)g_object_get_data(G_OBJECT(win), "progress_bar");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage);
-
- percentage_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "percentage_label");
- g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage);
- gtk_label_set_text((GtkLabel*)percentage_lb, tmp);
-
- /* Process all pending GUI events before continuing, so that
- the splash screen window gets updated. */
- while (gtk_events_pending()) gtk_main_iteration();
-
-}
-
-gboolean
-splash_destroy(GtkWidget *win)
-{
- if (win == NULL)
- return FALSE;
-
- gtk_widget_destroy(win);
- return FALSE;
-}
-
-static GtkWidget *
-about_wireshark_page_new(void)
-{
- GtkWidget *main_box, *msg_label /*, *icon*/;
- gchar *message;
- GString *comp_info_str, *runtime_info_str;
-
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_box), 12);
-
- g_object_set(gtk_widget_get_settings(main_box),
- "gtk-label-select-on-focus", FALSE, NULL);
-
- about_wireshark(top_level, main_box);
-
- comp_info_str = get_compiled_version_info(get_wireshark_gtk_compiled_info,
- get_gui_compiled_info);
- runtime_info_str = get_runtime_version_info(get_wireshark_runtime_info);
-
- /* Construct the message string */
- message = g_strdup_printf(
- "Version %s\n"
- "\n"
- "%s"
- "\n"
- "%s"
- "\n"
- "%s"
- "\n"
- "Wireshark is Open Source Software released under the GNU General Public License.\n"
- "\n"
- "Check the man page and http://www.wireshark.org for more information.",
- get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str,
- runtime_info_str->str);
-
- msg_label = gtk_label_new(message);
- g_free(message);
- gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
- gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
- gtk_box_pack_start(GTK_BOX (main_box), msg_label, TRUE, TRUE, 0);
-
-
- return main_box;
-}
-
-static GtkWidget *
-about_authors_page_new(void)
-{
- GtkWidget *page;
- char *absolute_path;
-
- absolute_path = get_datafile_path("AUTHORS-SHORT");
- page = text_page_new(absolute_path);
-
- return page;
-}
-
-static gboolean about_folders_callback(GtkWidget *widget, GdkEventButton *event, gint id _U_)
-{
- GtkTreeSelection *tree_selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *path;
-
- tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
-
- if(gtk_tree_selection_count_selected_rows(tree_selection) == 0)
- return FALSE;
-
- if(event->type != GDK_2BUTTON_PRESS)
- /* not a double click */
- return FALSE;
-
- if(gtk_tree_selection_get_selected (tree_selection, &model, &iter)) {
- gtk_tree_model_get(model, &iter, 1, &path, -1);
- filemanager_open_directory(path);
- g_free(path);
- }
-
- return TRUE;
-}
-
-static void
-about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
-{
- simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
-}
-
-static GtkWidget *
-about_folders_page_new(void)
-{
- GtkWidget *table;
- const char *constpath;
- char *path;
- static const gchar *titles[] = { "Name", "Folder", "Typical Files"};
- GtkWidget *scrolledwindow;
- gint i;
- gchar **resultArray;
-#if 0
- const gchar *const *dirs;
-#endif
-
- scrolledwindow = scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
- GTK_SHADOW_IN);
-
- /* Container for our data */
- table = simple_list_new(3, titles);
-
- /* connect a callback so we can spot a double-click */
- g_signal_connect(table, "button_press_event",
- G_CALLBACK(about_folders_callback), NULL);
-
- simple_list_url_col(table, 1);
-
- /* "file open" */
- about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
- "capture files");
-
- /* temp */
- about_folders_row(table, "Temp", g_get_tmp_dir(),
- "untitled capture files");
-
- /* pers conf */
- path = get_persconffile_path("", FALSE);
- about_folders_row(table, "Personal configuration", path,
- "\"dfilters\", \"preferences\", \"ethers\", ...");
- g_free(path);
-
- /* global conf */
- constpath = get_datafile_dir();
- if (constpath != NULL) {
- about_folders_row(table, "Global configuration", constpath,
- "\"dfilters\", \"preferences\", \"manuf\", ...");
- }
-#if 0
- dirs = g_get_system_data_dirs ();
- for (i = 0; dirs[i]; i++){
- g_warning("glibs data path %u %s",i+1,dirs[i]);
- }
-#endif
- /* system */
- constpath = get_systemfile_dir();
- about_folders_row(table, "System", constpath,
- "\"ethers\", \"ipxnets\"");
-
- /* program */
- constpath = get_progfile_dir();
- about_folders_row(table, "Program", constpath,
- "program files");
-
-#ifdef HAVE_PLUGINS
- /* pers plugins */
- about_folders_row(table, "Personal Plugins", get_plugins_pers_dir_with_version(),
- "binary plugins");
-
- /* global plugins */
- about_folders_row(table, "Global Plugins", get_plugins_dir_with_version(),
- "binary plugins");
-#endif
-
-#ifdef HAVE_LUA
- /* pers plugins */
- about_folders_row(table, "Personal Lua Plugins", get_plugins_pers_dir(),
- "lua scripts");
-
- /* global plugins */
- about_folders_row(table, "Global Lua Plugins", get_plugins_dir(),
- "lua scripts");
-#endif
-
- /* extcap */
- constpath = get_extcap_dir();
-
- resultArray = g_strsplit(constpath, G_SEARCHPATH_SEPARATOR_S, 10);
-
- for(i = 0; resultArray[i]; i++)
- about_folders_row(table, "Extcap path", g_strstrip(resultArray[i]),
- "Extcap Plugins search path");
- g_strfreev(resultArray);
-
-#ifdef HAVE_GEOIP
- /* GeoIP */
- path = geoip_db_get_paths();
-
- resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);
-
- for(i = 0; resultArray[i]; i++)
- about_folders_row(table, "GeoIP path", g_strstrip(resultArray[i]),
- "GeoIP database search path");
- g_strfreev(resultArray);
- g_free(path);
-#endif
-
-#ifdef HAVE_LIBSMI
- /* SMI MIBs/PIBs */
- path = oid_get_default_mib_path();
-
- resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 20);
-
- for(i = 0; resultArray[i]; i++)
- about_folders_row(table, "MIB/PIB path", g_strstrip(resultArray[i]),
- "SMI MIB/PIB search path");
- g_strfreev(resultArray);
- g_free(path);
-#endif
-
- gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
-
- return scrolledwindow;
-}
-
-static GtkWidget *
-about_license_page_new(void)
-{
- GtkWidget *page;
- char *absolute_path;
-
-#if defined(_WIN32)
- absolute_path = get_datafile_path("COPYING.txt");
-#else
- absolute_path = get_datafile_path("COPYING");
-#endif
- page = text_page_new(absolute_path);
-
- return page;
-}
-
-void
-about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ )
-{
- GtkWidget *main_box, *main_nb, *bbox, *ok_btn;
- GtkWidget *page_lb, *about_page, *folders_page;
-
-#if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
- GtkWidget *plugins_page;
-#endif
-
- GtkWidget *authors_page, *license_page;
-
- if (about_wireshark_w != NULL) {
- /* There's already an "About Wireshark" dialog box; reactivate it. */
- reactivate_window(about_wireshark_w);
- return;
- }
-
- /*
- * XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
- * Should we use GtkDialog for simple_dialog() as well? Or
- * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
- * not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
- */
- about_wireshark_w = dlg_window_new("About Wireshark");
- /* set the initial position (must be done, before show is called!) */
- /* default position is not appropriate for the about dialog */
- gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_window_set_default_size(GTK_WINDOW(about_wireshark_w), 600, 400);
- gtk_container_set_border_width(GTK_CONTAINER(about_wireshark_w), 6);
-
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_box), 6);
- gtk_container_add(GTK_CONTAINER(about_wireshark_w), main_box);
-
- main_nb = gtk_notebook_new();
- gtk_box_pack_start(GTK_BOX(main_box), main_nb, TRUE, TRUE, 0);
-
- about_page = about_wireshark_page_new();
- page_lb = gtk_label_new("Wireshark");
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
-
- authors_page = about_authors_page_new();
- page_lb = gtk_label_new("Authors");
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
-
- folders_page = about_folders_page_new();
- page_lb = gtk_label_new("Folders");
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
-
-#if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
- plugins_page = about_plugins_page_new();
- page_lb = gtk_label_new("Plugins");
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
-#endif
-
- license_page = about_license_page_new();
- page_lb = gtk_label_new("License");
- /* set a minmum width to avoid a lot of line breaks at the wrong places */
- gtk_widget_set_size_request(license_page, 600, -1);
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), license_page, page_lb);
-
- /* Button row */
- bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
- gtk_box_pack_start(GTK_BOX(main_box), bbox, FALSE, FALSE, 0);
-
- ok_btn = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- gtk_widget_grab_focus(ok_btn);
- gtk_widget_grab_default(ok_btn);
- window_set_cancel_button(about_wireshark_w, ok_btn, window_cancel_button_cb);
-
- g_signal_connect(about_wireshark_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(about_wireshark_w, "destroy", G_CALLBACK(about_wireshark_destroy_cb), NULL);
-
- gtk_widget_show_all(about_wireshark_w);
- window_present(about_wireshark_w);
-}
-
-static void
-about_wireshark_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
-{
- /* Note that we no longer have an "About Wireshark" dialog box. */
- about_wireshark_w = NULL;
-}
-
-/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
- *
- * Local Variables:
- * c-basic-offset: 2
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * vi: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
- */
diff --git a/ui/gtk/about_dlg.h b/ui/gtk/about_dlg.h
deleted file mode 100644
index 271c5ed12e..0000000000
--- a/ui/gtk/about_dlg.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* about_dlg.h
- * Declarations of routines for the "About" dialog
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __ABOUT_DLG_H__
-#define __ABOUT_DLG_H__
-
-/** @file
- * "About" dialog box.
- * @ingroup dialog_group
- */
-
-/** Create a splash screen showed when Wireshark is started.
- *
- * @param message the new message to be displayed
- * @return the newly created window handle
- */
-extern GtkWidget *splash_new(const char *message);
-
-/** Update the splash screen message when loading dissectors and handoffs
- *
- * @param action the initialisation action being performed
- * @param message additional information
- * @param call_data the window handle from splash_new()
- */
-extern void splash_update(register_action_e action, const char *message, void *call_data);
-
-/** Destroy the splash screen.
- *
- * @param win the window handle from splash_new()
- * @return always FALSE, so this function can be used as a callback for gtk_timeout_add()
- */
-extern gboolean splash_destroy(GtkWidget *win);
-
-/** User requested the "About" dialog box by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-extern void about_wireshark_cb( GtkWidget *widget, gpointer data);
-
-
-#endif /* __ABOUT_DLG_H__ */
diff --git a/ui/gtk/addr_resolution_dlg.c b/ui/gtk/addr_resolution_dlg.c
deleted file mode 100644
index 77580470cb..0000000000
--- a/ui/gtk/addr_resolution_dlg.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/* addr_resolution_dlg.c
- * Show current address resolution as a hosts file
- *
- * Copyright 2012 Anders Broman <anders.broman@ericsson.com>
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include <epan/addr_resolv.h>
-#include <epan/wmem/wmem.h>
-
-#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/font_utils.h"
-#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/main.h"
-#include "ui/gtk/addr_resolution_dlg.h"
-
-#include "globals.h"
-
-static GtkWidget *addr_resolution_dlg_w = NULL;
-
-
-#define ADDRESS_STR_MAX 1024
-
-static void
-eth_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- guint8 *eth_addr = (guint8*)key;
- hashether_t* tp = (hashether_t*)value;
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X Status: %u %s %s\n",
- eth_addr[0], eth_addr[1], eth_addr[2],
- eth_addr[3], eth_addr[4], eth_addr[5],
- get_hash_ether_status(tp),
- get_hash_ether_hexaddr(tp),
- get_hash_ether_resolved_name(tp));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
-}
-static void
-manuf_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- hashmanuf_t *manuf = (hashmanuf_t*)value;
- int eth_as_gint = *(int*)key;
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X %s\n",eth_as_gint>>16, (eth_as_gint>>8)&0xff, eth_as_gint&0xff, get_hash_manuf_resolved_name(manuf));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
-}
-
-static void
-wka_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- gchar *name = (gchar *)value;
- guint8 *eth_addr = (guint8*)key;
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s\n",
- eth_addr[0], eth_addr[1], eth_addr[2],
- eth_addr[3], eth_addr[4], eth_addr[5],
- name);
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
-}
-
-static void
-serv_port_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- serv_port_t *serv_port_table = (serv_port_t *)value;
- int port = *(int*)key;
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "Port %u \n"" TCP %s\n"" UDP %s\n"" SCTP %s\n"" DCCP %s\n",
- port,
- serv_port_table->tcp_name,
- serv_port_table->udp_name,
- serv_port_table->sctp_name,
- serv_port_table->dccp_name);
-
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
-}
-
-static void
-ipv4_hash_table_to_texbuff(gpointer key, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
- int addr = GPOINTER_TO_UINT(key);
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "Key:0x%x IP: %s, Name: %s\n",
- addr,
- ipv4_hash_table_entry->ip,
- ipv4_hash_table_entry->name);
-
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
-}
-
-static void
-ipv4_hash_table_resolved_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
-
- if((ipv4_hash_table_entry->flags & NAME_RESOLVED)){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "%s\t%s\n",
- ipv4_hash_table_entry->ip,
- ipv4_hash_table_entry->name);
-
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- }
-
-}
-
-
-
-static void
-ipv6_hash_table_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "IP: %s, Name: %s\n",
- ipv6_hash_table_entry->ip6,
- ipv6_hash_table_entry->name);
-
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
-}
-
-static void
-ipv6_hash_table_resolved_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
- hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
-
- if((ipv6_hash_table_entry->flags & NAME_RESOLVED)){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "%s\t%s\n",
- ipv6_hash_table_entry->ip6,
- ipv6_hash_table_entry->name);
-
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- }
-
-}
-
-static void
-addres_resolution_to_texbuff(GtkTextBuffer *buffer)
-{
- gchar string_buff[ADDRESS_STR_MAX];
- wmem_map_t *manuf_hashtable;
- wmem_map_t *wka_hashtable;
- wmem_map_t *eth_hashtable;
- wmem_map_t *serv_port_hashtable;
- wmem_map_t *ipv4_hash_table;
- wmem_map_t *ipv6_hash_table;
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# Hosts information in Wireshark \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# Host data gathered from %s\n\n", cfile.filename);
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- /* Dump the v4 addresses first, then v6 */
- ipv4_hash_table = get_ipv4_hash_table();
- if(ipv4_hash_table){
- wmem_map_foreach( ipv4_hash_table, ipv4_hash_table_resolved_to_texbuff, buffer);
- }
-
- ipv6_hash_table = get_ipv6_hash_table();
- if(ipv6_hash_table){
- wmem_map_foreach( ipv6_hash_table, ipv6_hash_table_resolved_to_texbuff, buffer);
- }
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Address resolution IPv4 Hash table \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- if(ipv4_hash_table){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(ipv4_hash_table));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- wmem_map_foreach( ipv4_hash_table, ipv4_hash_table_to_texbuff, buffer);
- }
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Address resolution IPv6 Hash table \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- if(ipv6_hash_table){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(ipv6_hash_table));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- wmem_map_foreach( ipv6_hash_table, ipv6_hash_table_to_texbuff, buffer);
- }
-
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Port names information in Wireshark \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- serv_port_hashtable = get_serv_port_hashtable();
- if(serv_port_hashtable){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(serv_port_hashtable));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- wmem_map_foreach( serv_port_hashtable, serv_port_hash_to_texbuff, buffer);
- }
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Eth names information in Wireshark \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- eth_hashtable = get_eth_hashtable();
- if(eth_hashtable){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(eth_hashtable));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- wmem_map_foreach( eth_hashtable, eth_hash_to_texbuff, buffer);
- }
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Manuf information in Wireshark \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- manuf_hashtable = get_manuf_hashtable();
- if(manuf_hashtable){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(manuf_hashtable));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- wmem_map_foreach( manuf_hashtable, manuf_hash_to_texbuff, buffer);
- }
-
- g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# wka information in Wireshark \n#\n");
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
-
- wka_hashtable = get_wka_hashtable();
- if(wka_hashtable){
- g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(wka_hashtable));
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- wmem_map_foreach( wka_hashtable, wka_hash_to_texbuff, buffer);
- }
-
-
-}
-
-void
-addr_resolution_dlg (GtkAction *action _U_, gpointer data _U_)
-{
-
- GtkWidget *vbox;
- GtkWidget *view;
- GtkWidget *scroll;
- GtkWidget *bbox;
- GtkWidget *ok_bt, *cancel_bt, *help_bt;
- GtkTextBuffer *buffer;
-
- addr_resolution_dlg_w = dlg_window_new ("Address Resolution");
- gtk_widget_set_size_request (addr_resolution_dlg_w, 750, 350);
- gtk_window_set_resizable (GTK_WINDOW (addr_resolution_dlg_w), TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (addr_resolution_dlg_w), DLG_OUTER_MARGIN);
-
- vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_add (GTK_CONTAINER (addr_resolution_dlg_w), vbox);
- gtk_widget_show (vbox);
-
- view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_override_font(view, user_font_get_regular());
-#else
- gtk_widget_modify_font(view, user_font_get_regular());
-#endif
- gtk_widget_show (view);
-
- scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(scroll), view);
- gtk_widget_show(scroll);
- gtk_box_pack_start(GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
-
- /* Get the address list */
- addres_resolution_to_texbuff(buffer);
-
- /* Button row. */
- bbox = dlg_button_row_new (GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
- gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
-
- ok_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_OK);
- g_signal_connect(ok_bt, "clicked", G_CALLBACK(window_cancel_button_cb), addr_resolution_dlg_w); /* act as cxl */
- gtk_widget_set_sensitive (ok_bt, TRUE);
-
- cancel_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CANCEL);
- window_set_cancel_button (addr_resolution_dlg_w, cancel_bt, window_cancel_button_cb);
-
- help_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
-#if 0
- g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
-#endif
- gtk_widget_set_sensitive (help_bt, FALSE);
-
- gtk_widget_grab_default (ok_bt);
- /*g_signal_connect (addr_resolution_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);*/
-
-
- gtk_widget_show (addr_resolution_dlg_w);
-}
-
-/*
- * 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:
- */
diff --git a/ui/gtk/addr_resolution_dlg.h b/ui/gtk/addr_resolution_dlg.h
deleted file mode 100644
index 8442b27f24..0000000000
--- a/ui/gtk/addr_resolution_dlg.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* addr_resolution_dlg.h
- * Show current addres resolution as a hosts file
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __ADDR_RESOLUTION_DLG_H__
-#define __ADDR_RESOLUTION_DLG_H__
-
-void addr_resolution_dlg (GtkAction *action, gpointer data);
-
-#endif /* __ADDR_RESOLUTION_DLG_H__ */
diff --git a/ui/gtk/airpcap_dlg.c b/ui/gtk/airpcap_dlg.c
deleted file mode 100644
index 1dc52436f2..0000000000
--- a/ui/gtk/airpcap_dlg.c
+++ /dev/null
@@ -1,2697 +0,0 @@
-/* airpcap_dlg.c
- *
- * Giorgio Tino <giorgio.tino@cacetech.com>
- * Copyright (c) CACE Technologies, LLC 2006
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 2000 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#ifdef HAVE_AIRPCAP
-
-#include <gtk/gtk.h>
-
-#include <string.h>
-
-#include <wsutil/filesystem.h>
-
-#include <epan/prefs.h>
-#include <epan/crypt/wep-wpadefs.h>
-
-#include <wsutil/wspcap.h>
-
-#include "ui/simple_dialog.h"
-
-#include "ui/gtk/main.h"
-#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/dfilter_expr_dlg.h"
-#include "ui/gtk/stock_icons.h"
-#include "ui/gtk/gtkglobals.h"
-#include "ui/gtk/help_dlg.h"
-#include "ui/gtk/keys.h"
-#include "ui/gtk/old-gtk-compat.h"
-#include "ui/gtk/packet_win.h"
-
-#include <caputils/airpcap.h>
-#include <caputils/airpcap_loader.h>
-#include "airpcap_gui_utils.h"
-#include "airpcap_dlg.h"
-
-/*
- * Callback for the select row event in the key list widget
- */
-static void
-on_key_list_select_row(GtkTreeSelection *selection, gpointer data)
-{
- GtkWidget *add_new_key_bt, *edit_key_bt, *remove_key_bt;
- GtkWidget *move_key_up_bt, *move_key_down_bt;
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreePath *path, *path_up, *path_down;
-
- add_new_key_bt = (GtkWidget *)g_object_get_data(G_OBJECT(data), AIRPCAP_KEY_MGMT_NEW_KEY);
- edit_key_bt = (GtkWidget *)g_object_get_data(G_OBJECT(data), AIRPCAP_KEY_MGMT_EDIT_KEY);
- remove_key_bt = (GtkWidget *)g_object_get_data(G_OBJECT(data), AIRPCAP_KEY_MGMT_DELETE_KEY);
- move_key_up_bt = (GtkWidget *)g_object_get_data(G_OBJECT(data), AIRPCAP_KEY_MGMT_UP_KEY);
- move_key_down_bt = (GtkWidget *)g_object_get_data(G_OBJECT(data), AIRPCAP_KEY_MGMT_DOWN_KEY);
-
- if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
- path = gtk_tree_model_get_path(model, &iter);
- path_up = gtk_tree_path_copy(path);
- path_down = gtk_tree_path_copy(path);
- gtk_tree_path_next(path_down);
-
- if (gtk_tree_model_iter_n_children(model, NULL) >= MAX_ENCRYPTION_KEYS) {
- gtk_widget_set_sensitive(add_new_key_bt, FALSE);
- } else {
- gtk_widget_set_sensitive(add_new_key_bt, TRUE);
- }
-
- gtk_widget_set_sensitive(edit_key_bt, TRUE);
- gtk_widget_set_sensitive(remove_key_bt, TRUE);
-
- /* ...and we have to use two different methods to figure out first/last because? */
- if (gtk_tree_path_prev(path_up)) {
- gtk_widget_set_sensitive(move_key_up_bt, TRUE);
- } else {
- gtk_widget_set_sensitive(move_key_up_bt, FALSE);
- }
-
- if (gtk_tree_model_get_iter(model, &iter, path_down)) {
- gtk_widget_set_sensitive(move_key_down_bt, TRUE);
- } else {
- gtk_widget_set_sensitive(move_key_down_bt, FALSE);
- }
-
- gtk_tree_path_free(path);
- gtk_tree_path_free(path_up);
- gtk_tree_path_free(path_down);
- } else {
- gtk_widget_set_sensitive(add_new_key_bt, FALSE);
- gtk_widget_set_sensitive(edit_key_bt, FALSE);
- gtk_widget_set_sensitive(remove_key_bt, FALSE);
- gtk_widget_set_sensitive(move_key_up_bt, FALSE);
- gtk_widget_set_sensitive(move_key_down_bt, FALSE);
- }
-}
-/*
- * Callback for the select row event in the key list widget
- */
-static void
-on_key_list_reorder(GtkTreeModel *model _U_, GtkTreePath *path _U_, GtkTreeIter *iter _U_, gpointer no _U_, gpointer data) {
- GtkTreeSelection *selection;
-
- selection = (GtkTreeSelection *)g_object_get_data(G_OBJECT(data), AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY);
- on_key_list_select_row(selection, data);
-}
-
-/*
- * Callback for the crc checkbox
- */
-static void
-on_fcs_ck_toggled(GtkWidget *w _U_, gpointer user_data _U_)
-
-{
- if (airpcap_if_selected != NULL)
- {
- if (airpcap_if_selected->IsFcsPresent)
- {
- airpcap_if_selected->IsFcsPresent = FALSE;
- airpcap_if_selected->saved = FALSE;
- }
- else
- {
- airpcap_if_selected->IsFcsPresent = TRUE;
- airpcap_if_selected->saved = FALSE;
- }
- }
-}
-
-/*
- * Callback for the wrong crc combo
- */
-static void
-on_edit_type_cb_changed(GtkWidget *w, gpointer data)
-{
- GtkWidget *edit_key_w;
- GtkWidget *edit_ssid_te;
- GtkWidget *type_cb;
- GtkWidget *key_lb;
- GtkWidget *ssid_lb;
-
- gchar* type_text = NULL;
-
- edit_key_w = GTK_WIDGET(data);
- type_cb = w;
-
- edit_ssid_te = (GtkWidget *)g_object_get_data(G_OBJECT(edit_key_w),AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY);
- key_lb = (GtkWidget *)g_object_get_data(G_OBJECT(edit_key_w),AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY);
- ssid_lb = (GtkWidget *)g_object_get_data(G_OBJECT(edit_key_w),AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY);
-
- type_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(type_cb));
-
- if (g_ascii_strcasecmp(type_text, ""))
- {
- /*
- * If it is a WEP key, no SSID is required! Gray out the entry text so
- * it doesn't create confusion ...
- */
- if (g_ascii_strcasecmp(type_text,AIRPCAP_WEP_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(edit_ssid_te,FALSE);
- /*
- * Maybe the user has already entered some text into the SSID field
- * and then switched to WEP...
- */
- gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
- gtk_label_set_text(GTK_LABEL(key_lb),"Key");
- gtk_label_set_text(GTK_LABEL(ssid_lb),"");
- }
- else if (g_ascii_strcasecmp(type_text,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(edit_ssid_te,FALSE);
- /*
- * Maybe the user has already entered some text into the SSID field
- * and then switched to WPA...
- */
- gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
- gtk_label_set_text(GTK_LABEL(key_lb),"Key");
- gtk_label_set_text(GTK_LABEL(ssid_lb),"");
- }
- else if (g_ascii_strcasecmp(type_text,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(edit_ssid_te,TRUE);
- /*
- * Maybe the user has already entered some text into the SSID field
- * and then switched to WPA...
- */
- gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
- gtk_label_set_text(GTK_LABEL(key_lb),"Passphrase");
- gtk_label_set_text(GTK_LABEL(ssid_lb),"SSID");
- }
- }
- gtk_widget_show(edit_ssid_te);
-
- g_free(type_text);
-}
-
-/*
- * Callback for the wrong crc combo
- */
-static void
-on_add_type_cb_changed(GtkWidget *w, gpointer data)
-{
- GtkWidget *add_key_w;
- GtkWidget *add_ssid_te;
- GtkWidget *type_cb;
- GtkWidget *key_lb;
- GtkWidget *ssid_lb;
-
- gchar* type_text = NULL;
-
- add_key_w = GTK_WIDGET(data);
- type_cb = w;
-
- add_ssid_te = (GtkWidget *)g_object_get_data(G_OBJECT(add_key_w),AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY);
- key_lb = (GtkWidget *)g_object_get_data(G_OBJECT(add_key_w),AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY);
- ssid_lb = (GtkWidget *)g_object_get_data(G_OBJECT(add_key_w),AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY);
-
- type_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(type_cb));
-
- if (g_ascii_strcasecmp(type_text, ""))
- {
- /*
- * If it is a WEP key, no SSID is required! Gray out rhe entry text so
- * it doesn't create confusion ...
- */
- if (g_ascii_strcasecmp(type_text,AIRPCAP_WEP_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(add_ssid_te,FALSE);
- /*
- * Maybe the user has already entered some text into the SSID field
- * and then switched to WEP...
- */
- gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
- gtk_label_set_text(GTK_LABEL(key_lb),"Key");
- gtk_label_set_text(GTK_LABEL(ssid_lb),"");
- }
- else if (g_ascii_strcasecmp(type_text,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(add_ssid_te,FALSE);
- /*
- * Maybe the user has already entered some text into the SSID field
- * and then switched to WPA...
- */
- gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
- gtk_label_set_text(GTK_LABEL(key_lb),"Key");
- gtk_label_set_text(GTK_LABEL(ssid_lb),"");
- }
- else if (g_ascii_strcasecmp(type_text,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(add_ssid_te,TRUE);
- /*
- * Maybe the user has already entered some text into the SSID field
- * and then switched to WPA...
- */
- gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
- gtk_label_set_text(GTK_LABEL(key_lb),"Passphrase");
- gtk_label_set_text(GTK_LABEL(ssid_lb),"SSID");
- }
- }
- gtk_widget_show(add_ssid_te);
-
- g_free(type_text);
-}
-
-/*
- * Callback for the wrong crc combo
- */
-static void
-on_fcs_filter_cb_changed(GtkWidget *fcs_filter_cb, gpointer data _U_)
-{
- gchar *fcs_filter_str;
-
- if (fcs_filter_cb != NULL)
- {
- fcs_filter_str = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(fcs_filter_cb));
- if (fcs_filter_str && (g_ascii_strcasecmp("", fcs_filter_str)))
- {
- airpcap_if_selected->CrcValidationOn = airpcap_get_validation_type(fcs_filter_str);
- airpcap_if_selected->saved = FALSE;
- }
- g_free(fcs_filter_str);
- }
-}
-
-
-/*
- * Changed callback for the capture type combobox
- */
-static void
-on_capture_type_cb_changed(GtkWidget *cb, gpointer user_data _U_)
-{
- gchar *s;
-
- if (cb == NULL) {
- return;
- }
-
- s = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(cb));
-
- if ((g_ascii_strcasecmp("",s)))
- {
- airpcap_if_selected->linkType = airpcap_get_link_type(s);
- airpcap_if_selected->saved = FALSE;
- }
- g_free(s);
-}
-
-/*
- * Thread function used to blink the led
- */
-static gboolean
-update_blink(gpointer data)
-{
- airpcap_if_info_t* sel;
- PAirpcapHandle ad;
- gchar ebuf[AIRPCAP_ERRBUF_SIZE];
-
- sel = (airpcap_if_info_t*)data;
-
- ad = airpcap_if_open(sel->name, ebuf);
- if (ad)
- {
- if (sel->led)
- {
- airpcap_if_turn_led_off(ad, 0);
- sel->led = FALSE;
- }
- else
- {
- airpcap_if_turn_led_on(ad, 0);
- sel->led = TRUE;
- }
- airpcap_if_close(ad);
- }
- return TRUE;
-}
-
-/*
- * Blink button callback
- */
-static void
-on_blink_bt_clicked( GtkWidget *blink_bt, gpointer data _U_)
-{
- PAirpcapHandle ad = NULL;
- gchar ebuf[AIRPCAP_ERRBUF_SIZE];
-
- if (airpcap_if_selected != NULL) {
- if (!(airpcap_if_selected->blinking))
- {
- gtk_button_set_label(GTK_BUTTON(blink_bt),"Stop Blinking");
- airpcap_if_selected->tag = g_timeout_add(500,update_blink,airpcap_if_selected);
- airpcap_if_selected->blinking = TRUE;
- }
- else
- {
- gtk_button_set_label(GTK_BUTTON(blink_bt)," Blink Led ");
- g_source_remove(airpcap_if_selected->tag);
- airpcap_if_selected->blinking = FALSE;
- /* Switch on the led! */
- ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
- if (ad)
- {
- g_source_remove(airpcap_if_selected->tag);
- airpcap_if_turn_led_on(ad, 0);
- airpcap_if_selected->blinking = FALSE;
- airpcap_if_selected->led = TRUE;
- airpcap_if_close(ad);
- }
- }
- }
-}
-
-/*
- * Callback for the 'Any' adapter What's This button.
- */
-static void
-on_what_s_this_bt_clicked( GtkWidget *blink_bt _U_, gpointer data _U_)
-{
- simple_dialog(ESD_TYPE_INFO,ESD_BTN_OK,
- "The Multi-Channel Aggregator is a virtual device "
- "that can be used to capture packets from all the "
- "AirPcap adapters at the same time.\n"
- "The Capture Type, FCS and Encryption settings of "
- "this virtual device can be configured as for any "
- "real adapter.\nThe channel cannot be changed for "
- "this adapter.\n"
- "Refer to the AirPcap manual for more information.");
-}
-
-/* the window was closed, cleanup things */
-static void
-on_key_management_destroy(GtkWidget *w _U_, gpointer data)
-{
- GtkWidget *airpcap_advanced_w,
- *toolbar;
-
- gint *from_widget = NULL;
-
- /* Retrieve the GUI object pointers */
- airpcap_advanced_w = GTK_WIDGET(data);
-
- toolbar = GTK_WIDGET(g_object_get_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_TOOLBAR_KEY));
-
- /* ... */
- from_widget = (gint*)g_object_get_data(G_OBJECT(toolbar),AIRPCAP_ADVANCED_FROM_KEY);
- /* gray out the toolbar (if we came here from the toolbar advanced button)*/
- if ( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
- gtk_widget_set_sensitive(toolbar,TRUE);
- else
- gtk_widget_set_sensitive(toolbar,FALSE);
-
- g_free(from_widget);
-
- /* reload the configuration!!! Configuration has not been saved but
- the corresponding structure has been modified probably...*/
- if (airpcap_if_selected != NULL)
- {
- if (!airpcap_if_selected->saved)
- {
- airpcap_load_selected_if_configuration(airpcap_if_selected);
- }
- }
-
-}
-
-/* the Advenced wireless Settings window was closed, cleanup things */
-static void
-on_airpcap_advanced_destroy(GtkWidget *w _U_, gpointer data)
-{
- GtkWidget *airpcap_advanced_w,
- *toolbar;
-
- gint *from_widget = NULL;
-
- /* Retrieve the GUI object pointers */
- airpcap_advanced_w = GTK_WIDGET(data);
-
- toolbar = GTK_WIDGET(g_object_get_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_TOOLBAR_KEY));
-
- /* ... */
- from_widget = (gint*)g_object_get_data(G_OBJECT(toolbar),AIRPCAP_ADVANCED_FROM_KEY);
- /* gray out the toolbar (if we came here from the toolbar advanced button)*/
- if ( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
- gtk_widget_set_sensitive(toolbar,TRUE);
- else
- gtk_widget_set_sensitive(toolbar,FALSE);
-
- g_free(from_widget);
-
- /* reload the configuration!!! Configuration has not been saved but
- the corresponding structure has been modified probably...*/
- if (!airpcap_if_selected->saved)
- {
- airpcap_load_selected_if_configuration(airpcap_if_selected);
- }
-}
-
-/*
- * Callback for the 'Apply' button.
- */
-/*
- * XXX - Pressing 'Apply' has the same effect as pressing 'OK' -- you
- * can't revert back to the old set of keys by pressing 'Cancel'. We
- * either need to fix reversion or get rid of the 'Apply' button.
- */
-static void
-on_key_management_apply_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- /* advenced window */
- GtkWidget *key_management_w;
-
- /* widgets in the toolbar */
- GtkWidget *toolbar_cb;
- GtkWidget *decryption_mode_cb;
-
- GtkListStore *key_list_store;
-
- module_t *wlan_module = prefs_find_module("wlan");
- gchar *decryption_mode_string;
-
- /* retrieve main window */
- key_management_w = GTK_WIDGET(data);
- decryption_mode_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_DECRYPTION_MODE_KEY));
- key_list_store = GTK_LIST_STORE(g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_KEYLIST_KEY));
- toolbar_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_TOOLBAR_DECRYPTION_KEY));
-
-#define CANT_SAVE_ERR_STR "Cannot save configuration. Another application " \
- "might be using AirPcap, or you might not have sufficient privileges."
- /* Set the Decryption Mode */
-
- decryption_mode_string = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(decryption_mode_cb));
- if (g_ascii_strcasecmp(decryption_mode_string, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK) == 0)
- {
- set_wireshark_decryption(TRUE);
- if (!set_airpcap_decryption(FALSE)) g_warning(CANT_SAVE_ERR_STR);
- }
- else if (g_ascii_strcasecmp(decryption_mode_string, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP) == 0)
- {
- set_wireshark_decryption(FALSE);
- if (!set_airpcap_decryption(TRUE)) g_warning(CANT_SAVE_ERR_STR);
- }
- else if (g_ascii_strcasecmp(decryption_mode_string, AIRPCAP_DECRYPTION_TYPE_STRING_NONE) == 0)
- {
- set_wireshark_decryption(FALSE);
- if (!set_airpcap_decryption(FALSE)) g_warning(CANT_SAVE_ERR_STR);
- }
- g_free(decryption_mode_string);
-
- /* Save the configuration */
- airpcap_read_and_save_decryption_keys_from_list_store(key_list_store,airpcap_if_selected,g_airpcap_if_list); /* This will save the keys for every adapter */
-
- /* The update will make redissect al the packets... no need to do it here again */
- update_decryption_mode(toolbar_cb);
-
- /* Redissect all the packets, and re-evaluate the display filter. */
- prefs_apply(wlan_module);
-}
-
-/*
- * Callback used to add a WEP key in the add new key box;
- */
-static void
-on_add_key_ok_bt_clicked(GtkWidget *widget _U_, gpointer data)
-{
- GtkWidget *type_cb,
- *key_en,
- *ssid_en;
-
- GtkListStore *key_list_store;
-
- GString *new_type_string,
- *new_key_string,
- *new_ssid_string;
-
- gchar *type_entered = NULL;
- gchar *key_entered = NULL;
- gchar *ssid_entered = NULL;
-
- unsigned int i;
-
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_ADD_KEY_LIST_KEY);
- type_cb = (GtkWidget *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_ADD_KEY_TYPE_KEY);
- key_en = (GtkWidget *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_ADD_KEY_KEY_KEY);
- ssid_en = (GtkWidget *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY);
-
- type_entered = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(type_cb));
- key_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(key_en)));
- ssid_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(ssid_en)));
-
- /* Check if key is correct */
- new_type_string = g_string_new(type_entered);
- new_key_string = g_string_new(key_entered);
- new_ssid_string = g_string_new(ssid_entered);
-
- g_free(type_entered);
- g_free(key_entered );
- g_free(ssid_entered);
-
- g_strstrip(new_key_string->str);
- g_strstrip(new_ssid_string->str);
-
- /* Check which type of key the user has entered */
- if (g_ascii_strcasecmp(new_type_string->str,AIRPCAP_WEP_KEY_STRING) == 0) /* WEP key */
- {
-
- if ( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range.\nValid key size range is %d-%d characters (%d-%d bits).",WEP_KEY_MIN_CHAR_SIZE,WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MIN_BIT_SIZE,WEP_KEY_MAX_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- if ((new_key_string->len % 2) != 0)
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key.\nThe number of characters must be even.");
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- for (i = 0; i < new_key_string->len; i++)
- {
- if (!g_ascii_isxdigit(new_key_string->str[i]))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key.\nA WEP key must be a hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
- }
-
- /* If so... add key */
- airpcap_add_key_to_list(key_list_store, new_type_string->str, new_key_string->str, new_ssid_string->str);
-
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
- }
- else if (g_ascii_strcasecmp(new_type_string->str,AIRPCAP_WPA_PWD_KEY_STRING) == 0) /* WPA Key */
- {
- /* XXX - Perform some WPA related input fields check */
- /* If everything is ok, modify the entry in the list */
-
- if ( ((new_key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA key size out of range.\nValid key size range is %d-%d ASCII characters (%d-%d bits).",WPA_KEY_MIN_CHAR_SIZE,WPA_KEY_MAX_CHAR_SIZE,WPA_KEY_MIN_BIT_SIZE,WPA_KEY_MAX_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- /*
- * XXX - Maybe we need some check on the characters? I'm not sure if only standard ASCII are ok...
- */
- if ((new_ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE)
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"SSID key size out of range.\nValid SSID size range is %d-%d ASCII characters (%d-%d bits).",WPA_SSID_MIN_CHAR_SIZE,WPA_SSID_MAX_CHAR_SIZE,WPA_SSID_MIN_BIT_SIZE,WPA_SSID_MAX_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- /* If so... add key */
- airpcap_add_key_to_list(key_list_store, new_type_string->str, new_key_string->str, new_ssid_string->str);
-
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
- }
- else if (g_ascii_strcasecmp(new_type_string->str,AIRPCAP_WPA_BIN_KEY_STRING) == 0) /* WPA_BIN Key */
- {
- /* XXX - Perform some WPA_BIN related input fields check */
- /* If everything is ok, modify the entry int he list */
-
- if ( ((new_key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA PSK/PMK key size is wrong.\nValid key size is %d characters (%d bits).",WPA_PSK_KEY_CHAR_SIZE,WPA_PSK_KEY_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- for (i = 0; i < new_key_string->len; i++)
- {
- if (!g_ascii_isxdigit(new_key_string->str[i]))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WPA PSK/PMK key.\nKey must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
- }
-
- /* If so... add key */
- airpcap_add_key_to_list(key_list_store, new_type_string->str, new_key_string->str, new_ssid_string->str);
-
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
- }
- else /* Should never happen!!! */
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field.");
- }
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- window_destroy(GTK_WIDGET(data));
- return;
-}
-
-/*
- * Callback used to edit a WEP key in the edit key box;
- */
-static void
-on_edit_key_ok_bt_clicked(GtkWidget *widget _U_, gpointer data)
-{
- GtkWidget *type_cb,
- *key_en,
- *ssid_en;
-
- GtkListStore *key_list_store;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- GString *new_type_string,
- *new_key_string,
- *new_ssid_string;
-
- gchar *type_entered = NULL;
- gchar *key_entered = NULL;
- gchar *ssid_entered = NULL;
-
- unsigned int i;
-
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY);
- selection = (GtkTreeSelection *)g_object_get_data(G_OBJECT(data), AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY);
- type_cb = (GtkWidget *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY);
- key_en = (GtkWidget *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY);
- ssid_en = (GtkWidget *)g_object_get_data(G_OBJECT(data),AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY);
-
- if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
- return;
-
- type_entered = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(type_cb));
- key_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(key_en)));
- ssid_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(ssid_en)));
-
- g_strstrip(key_entered);
- g_strstrip(ssid_entered);
-
- /* Check if key is correct */
- new_type_string = g_string_new(type_entered);
- new_key_string = g_string_new(key_entered);
- new_ssid_string = g_string_new(ssid_entered);
-
- g_free(type_entered);
- g_free(key_entered );
- g_free(ssid_entered);
-
- /* Check which type of key the user has entered */
- if (g_ascii_strcasecmp(new_type_string->str,AIRPCAP_WEP_KEY_STRING) == 0) /* WEP key */
- {
-
- if ( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range.\nValid key size range is %d-%d characters (%d-%d bits).",WEP_KEY_MIN_CHAR_SIZE,WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MIN_BIT_SIZE,WEP_KEY_MAX_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- if ((new_key_string->len % 2) != 0)
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key.\nThe number of characters must be even.");
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- for (i = 0; i < new_key_string->len; i++)
- {
- if (!g_ascii_isxdigit(new_key_string->str[i]))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key.\nA WEP key must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
- }
-
- /* If so... Modify key */
- gtk_list_store_set(key_list_store, &iter,
- KL_COL_TYPE, new_type_string->str,
- KL_COL_KEY, new_key_string->str,
- KL_COL_SSID, new_ssid_string->str,
- -1);
-
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
- }
- else if (g_ascii_strcasecmp(new_type_string->str,AIRPCAP_WPA_PWD_KEY_STRING) == 0) /* WPA Key */
- {
- /* XXX - Perform some WPA related input fields check */
- /* If everything is ok, modify the entry in the list */
-
- if ( ((new_key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA key size out of range.\nValid key size range is %d-%d ASCII characters (%d-%d bits).",WPA_KEY_MIN_CHAR_SIZE,WPA_KEY_MAX_CHAR_SIZE,WPA_KEY_MIN_BIT_SIZE,WPA_KEY_MAX_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- /*
- * XXX - Maybe we need some check on the characters? I'm not sure if only standard ASCII are ok...
- */
- if ((new_ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE)
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"SSID key size out of range.\nValid SSID size range is %d-%d ASCII characters (%d-%d bits).",WPA_SSID_MIN_CHAR_SIZE,WPA_SSID_MAX_CHAR_SIZE,WPA_SSID_MIN_BIT_SIZE,WPA_SSID_MAX_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- /* If so... Modify key */
- gtk_list_store_set(key_list_store, &iter,
- KL_COL_TYPE, new_type_string->str,
- KL_COL_KEY, new_key_string->str,
- KL_COL_SSID, new_ssid_string->str,
- -1);
-
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
- }
- else if (g_ascii_strcasecmp(new_type_string->str,AIRPCAP_WPA_BIN_KEY_STRING) == 0) /* WPA_BIN Key */
- {
- /* XXX - Perform some WPA_BIN related input fields check */
- /* If everything is ok, modify the entry in the list */
-
- if ( ((new_key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA PSK/PMK key size is wrong.\nValid key size is %d characters (%d bits).",WPA_PSK_KEY_CHAR_SIZE,WPA_PSK_KEY_BIT_SIZE);
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
-
- for (i = 0; i < new_key_string->len; i++)
- {
- if (!g_ascii_isxdigit(new_key_string->str[i]))
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WPA PSK/PMK key.\nKey must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- return;
- }
- }
-
- /* If so... Modify key */
- gtk_list_store_set(key_list_store, &iter,
- KL_COL_TYPE, new_type_string->str,
- KL_COL_KEY, new_key_string->str,
- KL_COL_SSID, new_ssid_string->str,
- -1);
-
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
- }
- else /* Should never happen!!! */
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field.");
- }
-
- g_string_free(new_type_string,TRUE);
- g_string_free(new_key_string, TRUE);
- g_string_free(new_ssid_string,TRUE);
-
- window_destroy(GTK_WIDGET(data));
- return;
-}
-
-/*
- * Add key window destroy callback
- */
-static void
-on_add_key_w_destroy(GtkWidget *button _U_, gpointer data)
-{
- GtkWidget *airpcap_advanced_w;
-
- airpcap_advanced_w = GTK_WIDGET(data);
-
- gtk_widget_set_sensitive(GTK_WIDGET(airpcap_advanced_w),TRUE);
-
- return;
-}
-
-/*
- * Callback for the 'Add Key' button.
- */
-static void
-on_add_new_key_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- GtkWidget *add_key_window;
- GtkWidget *add_frame;
- GtkWidget *main_v_box;
- GtkWidget *add_grid;
- GtkWidget *add_frame_al;
- GtkWidget *add_type_cb;
- GtkWidget *add_key_te;
- GtkWidget *add_ssid_te;
- GtkWidget *add_type_lb;
- GtkWidget *add_key_lb;
- GtkWidget *add_ssid_lb;
- GtkWidget *low_h_button_box;
- GtkWidget *ok_bt;
- GtkWidget *cancel_bt;
- GtkWidget *add_frame_lb;
-
- GtkWidget *airpcap_advanced_w;
-
- GtkListStore *key_list_store;
-
- airpcap_advanced_w = GTK_WIDGET(data);
-
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_ADVANCED_KEYLIST_KEY);
-
- if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(key_list_store), NULL) >= MAX_ENCRYPTION_KEYS)
- {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Maximum number (%d) of decryption keys reached. You cannot add another key.\n",MAX_ENCRYPTION_KEYS);
- return;
- }
-
- /* Gray out the Advanced Wireless Setting window */
- gtk_widget_set_sensitive(airpcap_advanced_w,FALSE);
-
- /* Pop-up a new window */
- add_key_window = dlg_window_new ("Add Decryption Key");
- gtk_window_set_modal(GTK_WINDOW(add_key_window), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(add_key_window), GTK_WINDOW(airpcap_advanced_w));
- gtk_widget_set_name (add_key_window, "add_key_window");
- gtk_container_set_border_width (GTK_CONTAINER (add_key_window), 5);
- gtk_window_set_resizable (GTK_WINDOW (add_key_window), FALSE);
-
- main_v_box = ws_gtk_box_new (GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (main_v_box, "main_v_box");
- gtk_widget_show (main_v_box);
- gtk_container_add (GTK_CONTAINER (add_key_window), main_v_box);
-
- add_frame = gtk_frame_new (NULL);
- gtk_widget_set_name (add_frame, "add_frame");
- gtk_widget_show (add_frame);
- gtk_box_pack_start (GTK_BOX (main_v_box), add_frame, TRUE, TRUE, 0);
-
- add_frame_al = gtk_alignment_new (0.5f, 0.5f, 1, 1);
- gtk_widget_set_name (add_frame_al, "add_frame_al");
- gtk_widget_show (add_frame_al);
- gtk_container_add (GTK_CONTAINER (add_frame), add_frame_al);
- gtk_alignment_set_padding (GTK_ALIGNMENT (add_frame_al), 0, 0, 12, 0);
-
- add_grid = ws_gtk_grid_new ();
- gtk_widget_set_name (add_grid, "add_tb");
- gtk_container_set_border_width(GTK_CONTAINER(add_grid),5);
- gtk_widget_show (add_grid);
- gtk_container_add (GTK_CONTAINER (add_frame_al), add_grid);
-
- add_type_lb = gtk_label_new ("Type");
- gtk_widget_set_name (add_type_lb, "add_type_lb");
- gtk_widget_show (add_type_lb);
- ws_gtk_grid_attach_defaults (GTK_GRID (add_grid), add_type_lb, 0, 0, 1, 1);
- gtk_label_set_justify (GTK_LABEL (add_type_lb), GTK_JUSTIFY_CENTER);
-
- add_key_lb = gtk_label_new ("Key");
- gtk_widget_set_name (add_key_lb, "add_key_lb");
- gtk_widget_show (add_key_lb);
- ws_gtk_grid_attach_defaults (GTK_GRID (add_grid), add_key_lb, 1, 0, 1, 1);
- gtk_label_set_justify (GTK_LABEL (add_key_lb), GTK_JUSTIFY_CENTER);
-
- add_ssid_lb = gtk_label_new ("");
- gtk_widget_set_name (add_ssid_lb, "add_ssid_lb");
- /* XXX - Decomment only when WPA and WPA_BIN will be ready */
- gtk_widget_show (add_ssid_lb);
- ws_gtk_grid_attach_defaults (GTK_GRID (add_grid), add_ssid_lb, 2, 0, 1, 1);
- gtk_label_set_justify (GTK_LABEL (add_ssid_lb), GTK_JUSTIFY_CENTER);
-
- add_type_cb = gtk_combo_box_text_new();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(add_type_cb), AIRPCAP_WEP_KEY_STRING);
-
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(add_type_cb), AIRPCAP_WPA_PWD_KEY_STRING);
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(add_type_cb), AIRPCAP_WPA_BIN_KEY_STRING);
- gtk_combo_box_set_active(GTK_COMBO_BOX(add_type_cb), 0);
- gtk_widget_set_name (add_type_cb, "add_type_cb");
- gtk_widget_show (add_type_cb);
- ws_gtk_grid_attach_defaults (GTK_GRID (add_grid), add_type_cb, 0, 1, 1, 1);
- gtk_widget_set_size_request (add_type_cb, 83, -1);
-
- add_key_te = gtk_entry_new ();
- gtk_widget_set_name (add_key_te, "add_key_te");
-
- gtk_widget_show (add_key_te);
- ws_gtk_grid_attach_defaults (GTK_GRID (add_grid), add_key_te, 1, 1, 1, 1);
- gtk_widget_set_size_request (add_key_te, 178, -1);
-
- add_ssid_te = gtk_entry_new ();
- gtk_widget_set_name (add_ssid_te, "add_ssid_te");
- gtk_widget_set_sensitive(add_ssid_te,FALSE);
- /* XXX - Decomment only when WPA and WPA_BIN will be ready */
- gtk_widget_show (add_ssid_te);
- ws_gtk_grid_attach_defaults (GTK_GRID (add_grid), add_ssid_te, 2, 1, 1, 1);
- low_h_button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_set_name (low_h_button_box, "low_h_button_box");
- gtk_container_set_border_width (GTK_CONTAINER (low_h_button_box), 5);
- gtk_widget_show (low_h_button_box);
- gtk_box_pack_end (GTK_BOX (main_v_box), low_h_button_box, FALSE, FALSE, 0);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
- GTK_BUTTONBOX_END);
-
- ok_bt = gtk_button_new_with_mnemonic ("OK");
- gtk_widget_set_name (ok_bt, "ok_bt");
- gtk_widget_show (ok_bt);
- gtk_container_add (GTK_CONTAINER (low_h_button_box), ok_bt);
- gtk_widget_set_can_default (ok_bt, TRUE);
-
- cancel_bt = gtk_button_new_with_mnemonic ("Cancel");
- gtk_widget_set_name (cancel_bt, "cancel_bt");
- gtk_widget_show (cancel_bt);
- gtk_container_add (GTK_CONTAINER (low_h_button_box), cancel_bt);
- gtk_widget_set_can_default (cancel_bt, TRUE);
-
- add_frame_lb = gtk_label_new ("<b>Modify Selected Key</b>");
- gtk_widget_set_name (add_frame_lb, "add_frame_lb");
- gtk_widget_show (add_frame_lb);
- gtk_frame_set_label_widget (GTK_FRAME (add_frame), add_frame_lb);
- gtk_label_set_use_markup (GTK_LABEL (add_frame_lb), TRUE);
-
- /* Add callbacks */
- g_signal_connect(ok_bt, "clicked", G_CALLBACK(on_add_key_ok_bt_clicked), add_key_window );
- g_signal_connect(cancel_bt, "clicked", G_CALLBACK(window_cancel_button_cb), add_key_window );
- g_signal_connect(add_type_cb, "changed", G_CALLBACK(on_add_type_cb_changed), add_key_window);
- g_signal_connect(add_key_window, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(add_key_window, "destroy", G_CALLBACK(on_add_key_w_destroy), data);
-
- /* Add widget data */
- g_object_set_data(G_OBJECT(add_key_window),AIRPCAP_ADVANCED_ADD_KEY_LIST_KEY,key_list_store);
- g_object_set_data(G_OBJECT(add_key_window),AIRPCAP_ADVANCED_ADD_KEY_TYPE_KEY,add_type_cb);
- g_object_set_data(G_OBJECT(add_key_window),AIRPCAP_ADVANCED_ADD_KEY_KEY_KEY,add_key_te);
- g_object_set_data(G_OBJECT(add_key_window),AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY,add_ssid_te);
- g_object_set_data(G_OBJECT(add_key_window),AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY,add_key_lb);
- g_object_set_data(G_OBJECT(add_key_window),AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY,add_ssid_lb);
-
- gtk_widget_show(add_key_window);
-}
-
-/*
- * Edit key window destroy callback
- */
-static void
-on_edit_key_w_destroy(GtkWidget *button _U_, gpointer data)
-{
- GtkWidget *airpcap_advanced_w;
-
- airpcap_advanced_w = GTK_WIDGET(data);
-
- gtk_widget_set_sensitive(GTK_WIDGET(airpcap_advanced_w),TRUE);
-
- return;
-}
-
-/*
- * Callback for the 'Remove Key' button.
- */
-static void
-on_remove_key_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
-
- /* retrieve needed stuff */
- selection = (GtkTreeSelection *)g_object_get_data(G_OBJECT(data), AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY);
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- return;
-
- /* Remove selected key */
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- gtk_tree_selection_select_iter(selection, &iter);
- /* XXX - select the last item if needed? */
-
- /* Need to save config... */
- if (airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
-}
-
-/*
- * Callback for the 'Edit Key' button.
- */
-static void
-on_edit_key_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- GtkWidget *edit_key_window;
- GtkWidget *edit_frame;
- GtkWidget *main_v_box;
- GtkWidget *edit_grid;
- GtkWidget *edit_frame_al;
- GtkWidget *edit_type_cb;
- GtkWidget *edit_key_te;
- GtkWidget *edit_ssid_te;
- GtkWidget *edit_type_lb;
- GtkWidget *edit_key_lb;
- GtkWidget *edit_ssid_lb;
- GtkWidget *low_h_button_box;
- GtkWidget *ok_bt;
- GtkWidget *cancel_bt;
- GtkWidget *edit_frame_lb;
-
- GtkWidget *airpcap_advanced_w;
-
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
-
- /* Key List Store */
- GtkListStore *key_list_store;
-
- gchar *row_type,
- *row_key,
- *row_ssid = NULL;
-
- airpcap_advanced_w = GTK_WIDGET(data);
-
- /* Retrieve the selected item... if no row is selected, this is null... */
- selection = (GtkTreeSelection *)g_object_get_data(G_OBJECT(data), AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY);
- key_list_store = (GtkListStore *)g_object_get_data (G_OBJECT(data), AIRPCAP_ADVANCED_KEYLIST_KEY);
-
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- return;
-
- gtk_tree_model_get(model, &iter,
- KL_COL_TYPE, &row_type,
- KL_COL_KEY, &row_key,
- KL_COL_SSID, &row_ssid,
- -1);
-
- /* Gray out the Advanced Wireless Setting window */
- gtk_widget_set_sensitive(airpcap_advanced_w,FALSE);
-
- /* Pop-up a new window */
- edit_key_window = dlg_window_new("Edit Decryption Key");
- gtk_window_set_modal(GTK_WINDOW(edit_key_window), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(edit_key_window), GTK_WINDOW(airpcap_advanced_w));
- gtk_widget_set_name (edit_key_window, "edit_key_window");
- gtk_container_set_border_width (GTK_CONTAINER (edit_key_window), 5);
- gtk_window_set_resizable (GTK_WINDOW (edit_key_window), FALSE);
-
- main_v_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (main_v_box, "main_v_box");
- gtk_widget_show (main_v_box);
- gtk_container_add (GTK_CONTAINER (edit_key_window), main_v_box);
-
- edit_frame = gtk_frame_new (NULL);
- gtk_widget_set_name (edit_frame, "edit_frame");
- gtk_widget_show (edit_frame);
- gtk_box_pack_start (GTK_BOX (main_v_box), edit_frame, TRUE, TRUE, 0);
-
- edit_frame_al = gtk_alignment_new (0.5f, 0.5f, 1, 1);
- gtk_widget_set_name (edit_frame_al, "edit_frame_al");
- gtk_widget_show (edit_frame_al);
- gtk_container_add (GTK_CONTAINER (edit_frame), edit_frame_al);
- gtk_alignment_set_padding (GTK_ALIGNMENT (edit_frame_al), 0, 0, 12, 0);
-
- edit_grid = ws_gtk_grid_new();
-
- gtk_widget_set_name (edit_grid, "edit_tb");
- gtk_container_set_border_width(GTK_CONTAINER(edit_grid),5);
- gtk_widget_show (edit_grid);
- gtk_container_add (GTK_CONTAINER (edit_frame_al), edit_grid);
-
- edit_type_lb = gtk_label_new ("Type");
- gtk_widget_set_name (edit_type_lb, "edit_type_lb");
- gtk_widget_show (edit_type_lb);
- ws_gtk_grid_attach_defaults (GTK_GRID (edit_grid), edit_type_lb, 0, 0, 1, 1);
- gtk_label_set_justify (GTK_LABEL (edit_type_lb), GTK_JUSTIFY_CENTER);
-
- edit_key_lb = gtk_label_new ("Key");
- gtk_widget_set_name (edit_key_lb, "edit_key_lb");
- gtk_widget_show (edit_key_lb);
- ws_gtk_grid_attach_defaults (GTK_GRID (edit_grid), edit_key_lb, 1, 0, 1, 1);
- gtk_label_set_justify (GTK_LABEL (edit_key_lb), GTK_JUSTIFY_CENTER);
-
- edit_ssid_lb = gtk_label_new ("");
- gtk_widget_set_name (edit_ssid_lb, "edit_ssid_lb");
- /* XXX - Decomment only when WPA and WPA_BIN will be ready */
- gtk_widget_show (edit_ssid_lb);
- ws_gtk_grid_attach_defaults (GTK_GRID (edit_grid), edit_ssid_lb, 2, 0, 1, 1);
- gtk_label_set_justify (GTK_LABEL (edit_ssid_lb), GTK_JUSTIFY_CENTER);
-
- edit_type_cb = gtk_combo_box_text_new();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(edit_type_cb), AIRPCAP_WEP_KEY_STRING);
-
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(edit_type_cb), AIRPCAP_WPA_PWD_KEY_STRING);
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(edit_type_cb), AIRPCAP_WPA_BIN_KEY_STRING);
- /* Set current type */
- gtk_combo_box_set_active(GTK_COMBO_BOX(edit_type_cb), 0);
- if (g_ascii_strcasecmp(row_type, AIRPCAP_WPA_PWD_KEY_STRING) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(edit_type_cb), 1);
- } else if (g_ascii_strcasecmp(row_type, AIRPCAP_WPA_BIN_KEY_STRING) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(edit_type_cb), 2);
- }
- gtk_widget_set_name (edit_type_cb, "edit_type_cb");
- gtk_widget_show (edit_type_cb);
- ws_gtk_grid_attach_defaults (GTK_GRID (edit_grid), edit_type_cb, 0, 1, 1, 1);
- gtk_widget_set_size_request (edit_type_cb, 83, -1);
-
- edit_key_te = gtk_entry_new ();
- gtk_widget_set_name (edit_key_te, "edit_key_te");
- /* Set current key */
- gtk_entry_set_text(GTK_ENTRY(edit_key_te),row_key);
- gtk_widget_show (edit_key_te);
- ws_gtk_grid_attach_defaults (GTK_GRID (edit_grid), edit_key_te, 1, 1, 1, 1);
- gtk_widget_set_size_request (edit_key_te, 178, -1);
-
- edit_ssid_te = gtk_entry_new ();
- gtk_widget_set_name (edit_ssid_te, "edit_ssid_te");
-
- /* Set current ssid (if key type is not WEP!)*/
- if (g_ascii_strcasecmp(row_type,AIRPCAP_WEP_KEY_STRING) == 0)
- {
- gtk_widget_set_sensitive(edit_ssid_te,FALSE);
- }
- else
- {
- gtk_widget_set_sensitive(edit_ssid_te,TRUE);
- gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),row_ssid?row_ssid:"");
- }
-
- /* XXX - Decomment only when WPA and WPA@ will be ready */
- gtk_widget_show (edit_ssid_te);
- ws_gtk_grid_attach_defaults (GTK_GRID (edit_grid), edit_ssid_te, 2, 1, 1, 1);
-
- low_h_button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_set_name (low_h_button_box, "low_h_button_box");
- gtk_container_set_border_width (GTK_CONTAINER (low_h_button_box), 5);
- gtk_widget_show (low_h_button_box);
- gtk_box_pack_end (GTK_BOX (main_v_box), low_h_button_box, FALSE, FALSE, 0);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
- GTK_BUTTONBOX_END);
-
- ok_bt = gtk_button_new_with_mnemonic ("OK");
- gtk_widget_set_name (ok_bt, "ok_bt");
- gtk_widget_show (ok_bt);
- gtk_container_add (GTK_CONTAINER (low_h_button_box), ok_bt);
- gtk_widget_set_can_default (ok_bt, TRUE);
-
- cancel_bt = gtk_button_new_with_mnemonic ("Cancel");
- gtk_widget_set_name (cancel_bt, "cancel_bt");
- gtk_widget_show (cancel_bt);
- gtk_container_add (GTK_CONTAINER (low_h_button_box), cancel_bt);
- gtk_widget_set_can_default (cancel_bt, TRUE);
-
- edit_frame_lb = gtk_label_new ("<b>Modify Selected Key</b>");
- gtk_widget_set_name (edit_frame_lb, "edit_frame_lb");
- gtk_widget_show (edit_frame_lb);
- gtk_frame_set_label_widget (GTK_FRAME (edit_frame), edit_frame_lb);
- gtk_label_set_use_markup (GTK_LABEL (edit_frame_lb), TRUE);
-
- /* Add callbacks */
- g_signal_connect(ok_bt, "clicked", G_CALLBACK(on_edit_key_ok_bt_clicked), edit_key_window );
- g_signal_connect(cancel_bt, "clicked", G_CALLBACK(window_cancel_button_cb), edit_key_window );
- g_signal_connect(edit_type_cb, "changed", G_CALLBACK(on_edit_type_cb_changed), edit_key_window);
- g_signal_connect(edit_key_window, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(edit_key_window, "destroy", G_CALLBACK(on_edit_key_w_destroy), data);
-
- /* Add widget data */
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY,key_list_store);
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY,selection);
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY,edit_type_cb);
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY,edit_key_te);
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY,edit_ssid_te);
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY,edit_key_lb);
- g_object_set_data(G_OBJECT(edit_key_window),AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY,edit_ssid_lb);
-
-
- g_free(row_type);
- g_free(row_key);
- g_free(row_ssid);
- gtk_widget_show(edit_key_window);
-}
-
-/*
- * Callback for the 'Move Key Up' button.
- */
-static void
-on_move_key_up_bt_clicked(GtkWidget *button _U_, gpointer key_list)
-{
- tree_view_list_store_move_selection(GTK_TREE_VIEW(key_list), TRUE);
-}
-
-/*
- * Callback for the 'Move Key Down' button.
- */
-static void
-on_move_key_down_bt_clicked(GtkWidget *button _U_, gpointer list_view)
-{
- tree_view_list_store_move_selection(GTK_TREE_VIEW(list_view), FALSE);
-}
-
-/* Turns the decryption on or off */
-void
-on_decryption_mode_cb_changed(GtkWidget *cb, gpointer data _U_)
-{
- gint cur_active;
-
- if (cb == NULL) {
- return;
- }
-
- cur_active = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
-
- if (cur_active < 0) {
- return;
- }
-
- switch(cur_active) {
- /* XXX - Don't use magic numbers here */
- case 1: /* Wireshark */
- set_wireshark_decryption(TRUE);
- if (!set_airpcap_decryption(FALSE)) g_warning(CANT_SAVE_ERR_STR);
- break;
- case 2: /* Driver */
- set_wireshark_decryption(FALSE);
- if (!set_airpcap_decryption(TRUE)) g_warning(CANT_SAVE_ERR_STR);
- break;
- default:
- set_wireshark_decryption(FALSE);
- if (!set_airpcap_decryption(FALSE)) g_warning(CANT_SAVE_ERR_STR);
- break;
- }
-
- /* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets();
- redissect_all_packet_windows();
-}
-
-/*
- * Selects the current decryption mode string in the decryption mode combo box
- */
-void
-update_decryption_mode(GtkWidget *cb)
-{
- if (cb == NULL) {
- return;
- }
-
- /* Wireshark decryption is on */
- if (wireshark_decryption_on())
- {
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 1);
- }
- /* AirPcap decryption is on */
- else if (airpcap_decryption_on())
- {
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 2);
- }
- /* No decryption enabled */
- else
- {
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 0);
- }
-
- return;
-}
-
-/*
- * Creates the list of available decryption modes, depending on the adapters found
- */
-void
-update_decryption_mode_list(GtkWidget *cb)
-{
- gchar *current_text;
-
- if (cb == NULL)
- return;
-
- current_text = NULL;
-
- /*
- * XXX - Retrieve the current 'decryption mode'. It would be better just block the
- * signal handler, but it doesn't work... one of these days I'll try to figure out why...
- */
- current_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(cb));
-
- while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(cb)), NULL) > 0) {
- gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(cb), 0);
- }
-
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(cb), AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(cb), AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
-
- if (g_airpcap_if_list != NULL && g_list_length(g_airpcap_if_list) > 0)
- {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(cb), AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP);
- }
- else
- {
- /* The last decryption mode was 'Driver', but no more AirPcap adapter are found */
- if (current_text == NULL || g_ascii_strcasecmp(current_text, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP) == 0)
- {
- g_free(current_text);
- current_text = g_strdup(AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
- }
- }
-
- if (g_ascii_strcasecmp(current_text, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 1);
- } else if (g_ascii_strcasecmp(current_text, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 2);
- } else { /* None / Invalid */
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 0);
- }
-
- g_free(current_text);
-}
-
-
-/*
- * Callback for the Wireless Advanced Settings 'Apply' button.
- */
-static void
-on_advanced_apply_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- /* advenced window */
- GtkWidget *airpcap_advanced_w;
- GtkWidget *channel_cb, *channel_offset_cb;
-
- /* widgets in the toolbar */
- GtkWidget *toolbar,
- *toolbar_if_lb,
- *toolbar_channel_cb,
- *toolbar_channel_offset_cb,
- *toolbar_fcs_filter_cb;
-
- /* retrieve main window */
- airpcap_advanced_w = GTK_WIDGET(data);
-
- /* Set the channel and offset */
- channel_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_ADVANCED_CHANNEL_KEY));
- channel_offset_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_ADVANCED_CHANNEL_OFFSET_KEY));
- airpcap_channel_offset_changed_cb(channel_offset_cb, NULL);
- airpcap_channel_changed_set_cb(channel_cb, channel_offset_cb);
-
-
- toolbar = GTK_WIDGET(g_object_get_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_TOOLBAR_KEY));
-
- /* retrieve toolbar info */
- toolbar_if_lb = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbar),AIRPCAP_TOOLBAR_INTERFACE_KEY));
- toolbar_channel_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbar),AIRPCAP_TOOLBAR_CHANNEL_KEY));
- toolbar_channel_offset_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbar),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY));
- toolbar_fcs_filter_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbar),AIRPCAP_TOOLBAR_FCS_FILTER_KEY));
-
- /* Save the configuration (for all ) */
- airpcap_save_selected_if_configuration(airpcap_if_selected);
-
- /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
- if ( g_ascii_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
- {
- gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
- airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),airpcap_if_selected);
- airpcap_update_channel_offset_combo(airpcap_if_selected, airpcap_if_selected->channelInfo.Frequency, toolbar_channel_offset_cb, TRUE);
- airpcap_validation_type_combo_set_by_type(toolbar_fcs_filter_cb,airpcap_if_selected->CrcValidationOn);
- }
-}
-
-/*
- * Callback for the OK button 'clicked' in the Advanced Wireless Settings window.
- */
-static void
-on_advanced_ok_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- PAirpcapHandle ad = NULL;
- gchar ebuf[AIRPCAP_ERRBUF_SIZE];
-
- /* Retrieve object data */
- GtkWidget *airpcap_advanced_w = GTK_WIDGET(data);
-
- if (airpcap_if_selected == NULL) { /* There's not much we can do. */
- gtk_widget_destroy(airpcap_advanced_w);
- return;
- }
-
- on_advanced_apply_bt_clicked(button, data);
-
- /* Stop blinking our LED */
- ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
- if (ad)
- {
- g_source_remove(airpcap_if_selected->tag);
- airpcap_if_turn_led_on(ad, 0);
- airpcap_if_selected->blinking = FALSE;
- airpcap_if_selected->led = TRUE;
- airpcap_if_close(ad);
- }
-
- /* Remove GLIB timeout */
- g_source_remove(airpcap_if_selected->tag);
-
- gtk_widget_destroy(airpcap_advanced_w);
-}
-
-/*
- * Callback for the CANCEL button 'clicked' in the Advanced Wireless Settings window.
- */
-static void
-on_advanced_cancel_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- PAirpcapHandle ad = NULL;
- gchar ebuf[AIRPCAP_ERRBUF_SIZE];
-
- /* Retrieve object data */
- GtkWidget *airpcap_advanced_w;
-
- /* Retrieve the GUI object pointers */
- airpcap_advanced_w = GTK_WIDGET(data);
-
- /* Stop blinking ALL leds (go through the g_airpcap_if_list) */
- if (airpcap_if_selected != NULL)
- {
- ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
- if (ad)
- {
- g_source_remove(airpcap_if_selected->tag);
- airpcap_if_turn_led_on(ad, 0);
- airpcap_if_selected->blinking = FALSE;
- airpcap_if_selected->led = TRUE;
- airpcap_if_close(ad);
- }
-
- /* reload the configuration!!! Configuration has not been saved but
- the corresponding structure has been modified probably...*/
- if (!airpcap_if_selected->saved)
- {
- airpcap_load_selected_if_configuration(airpcap_if_selected);
- }
- }
-
- gtk_widget_destroy(airpcap_advanced_w);
-}
-
-
-/* Called to create the airpcap settings' window */
-void
-display_airpcap_advanced_cb(GtkWidget *w _U_, gpointer data)
-{
- GtkWidget *airpcap_advanced_w;
- GtkWidget *main_box;
- GtkWidget *settings_sub_box;
- GtkWidget *interface_fr;
- GtkWidget *interface_al;
- GtkWidget *interface_sub_h_box;
- GtkWidget *interface_name_lb;
- GtkWidget *blink_bt;
- GtkWidget *interface_frame_lb;
- GtkWidget *basic_parameters_fr;
- GtkWidget *basic_parameters_al;
- GtkWidget *basic_parameters_grid;
- GtkWidget *channel_lb;
- GtkWidget *channel_offset_lb;
- GtkWidget *capture_type_lb;
- GtkWidget *channel_cb;
- GtkWidget *channel_offset_cb;
- GtkWidget *capture_type_cb;
- GtkWidget *fcs_ck;
- GtkWidget *basic_parameters_fcs_h_box;
- GtkWidget *basic_parameters_fcs_filter_lb;
- GtkWidget *fcs_filter_cb;
- GtkWidget *basic_parameters_frame_lb;
- GtkWidget *low_buttons_h_box;
- GtkWidget *left_h_button_box;
- GtkWidget *right_h_button_box;
- GtkWidget *ok_bt;
- GtkWidget *apply_bt;
- GtkWidget *cancel_bt;
-
- /* widgets in the toolbar */
- GtkWidget *toolbar;
-
- /* user data - RETRIEVE pointers of toolbar widgets */
- toolbar = GTK_WIDGET(data);
-
- /* gray out the toolbar */
- gtk_widget_set_sensitive(toolbar,FALSE);
-
- /* main window */
- /* global */
-
- /* the selected is the active, for now */
- airpcap_if_selected = airpcap_if_active;
-
- /* Create the new window */
- airpcap_advanced_w = dlg_window_new("Advanced Wireless Settings"); /* transient_for top_level */
- gtk_window_set_modal(GTK_WINDOW(airpcap_advanced_w), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(airpcap_advanced_w), GTK_WINDOW(gtk_widget_get_toplevel(w)));
- gtk_window_set_destroy_with_parent (GTK_WINDOW(airpcap_advanced_w), TRUE);
-
- gtk_container_set_border_width (GTK_CONTAINER (airpcap_advanced_w), 5);
- gtk_window_set_position (GTK_WINDOW (airpcap_advanced_w),
- GTK_WIN_POS_CENTER);
-
- gtk_window_set_resizable (GTK_WINDOW (airpcap_advanced_w), FALSE);
- gtk_window_set_type_hint (GTK_WINDOW (airpcap_advanced_w), GDK_WINDOW_TYPE_HINT_DIALOG);
-
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (main_box, "main_box");
- gtk_widget_show (main_box);
- gtk_container_add (GTK_CONTAINER (airpcap_advanced_w), main_box);
-
- settings_sub_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (settings_sub_box, "settings_sub_box");
- gtk_widget_show (settings_sub_box);
- gtk_box_pack_start (GTK_BOX (main_box), settings_sub_box, FALSE, TRUE, 0);
-
- interface_fr = gtk_frame_new (NULL);
- gtk_widget_set_name (interface_fr, "interface_fr");
- gtk_widget_show (interface_fr);
- gtk_box_pack_start (GTK_BOX (settings_sub_box), interface_fr, FALSE, FALSE,
- 0);
- gtk_container_set_border_width (GTK_CONTAINER (interface_fr), 10);
-
- interface_al = gtk_alignment_new (0.5f, 0.5f, 1, 1);
- gtk_widget_set_name (interface_al, "interface_al");
- gtk_widget_show (interface_al);
- gtk_container_add (GTK_CONTAINER (interface_fr), interface_al);
- gtk_alignment_set_padding (GTK_ALIGNMENT (interface_al), 5, 5, 0, 0);
-
- interface_sub_h_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_widget_set_name (interface_sub_h_box, "interface_sub_h_box");
- gtk_widget_show (interface_sub_h_box);
- gtk_container_add (GTK_CONTAINER (interface_al), interface_sub_h_box);
- gtk_container_set_border_width (GTK_CONTAINER (interface_sub_h_box), 5);
-
- /* Fill the interface_box */
- if (airpcap_if_active != NULL)
- {
- interface_name_lb = gtk_label_new(airpcap_if_active->description);
- }
- else
- {
- interface_name_lb = gtk_label_new("Couldn't find an airpcap interface.");
- gtk_widget_set_sensitive(main_box,FALSE);
- }
-
- gtk_widget_set_name (interface_name_lb, "interface_name_lb");
- gtk_widget_show (interface_name_lb);
- gtk_box_pack_start (GTK_BOX (interface_sub_h_box), interface_name_lb, TRUE,
- FALSE, 0);
-
- /* If it is NOT the 'Any' Interface */
- if (!airpcap_if_is_any(airpcap_if_selected))
- {
- blink_bt = gtk_button_new_with_mnemonic ("Blink Led");
- }
- else /* It is the any interface, so it doesn't make sense to have 'Blink' button... */
- {
- blink_bt = gtk_button_new_with_mnemonic ("What's This?");
- }
- gtk_widget_set_name (blink_bt, "blink_bt");
- gtk_widget_show (blink_bt);
- gtk_box_pack_end (GTK_BOX (interface_sub_h_box), blink_bt, FALSE, FALSE, 0);
-
- interface_frame_lb = gtk_label_new ("<b>Interface</b>");
- gtk_widget_set_name (interface_frame_lb, "interface_frame_lb");
- gtk_widget_show (interface_frame_lb);
- gtk_frame_set_label_widget (GTK_FRAME (interface_fr), interface_frame_lb);
- gtk_label_set_use_markup (GTK_LABEL (interface_frame_lb), TRUE);
-
- basic_parameters_fr = gtk_frame_new (NULL);
- gtk_widget_set_name (basic_parameters_fr, "basic_parameters_fr");
- gtk_widget_show (basic_parameters_fr);
- gtk_box_pack_start (GTK_BOX (settings_sub_box), basic_parameters_fr, TRUE,FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (basic_parameters_fr), 10);
-
- basic_parameters_al = gtk_alignment_new (0.5f, 0.5f, 1, 1);
- gtk_widget_set_name (basic_parameters_al, "basic_parameters_al");
- gtk_widget_show (basic_parameters_al);
- gtk_container_add (GTK_CONTAINER (basic_parameters_fr),basic_parameters_al);
- gtk_alignment_set_padding (GTK_ALIGNMENT (basic_parameters_al), 10, 10, 0, 0);
-
- basic_parameters_grid = ws_gtk_grid_new ();
- gtk_widget_set_name (basic_parameters_grid, "basic_parameters_grid");
- gtk_widget_show (basic_parameters_grid);
- gtk_container_add (GTK_CONTAINER (basic_parameters_al),
- basic_parameters_grid);
- gtk_container_set_border_width (GTK_CONTAINER (basic_parameters_grid), 5);
- ws_gtk_grid_set_column_spacing(GTK_GRID(basic_parameters_grid), 20);
-
- channel_lb = gtk_label_new ("Channel:");
- gtk_widget_set_name (channel_lb, "channel_lb");
- gtk_widget_show (channel_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), channel_lb, 0, 0, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (channel_lb), 0, 0.5f);
-
- capture_type_lb = gtk_label_new ("Capture Type:");
- gtk_widget_set_name (capture_type_lb, "capture_type_lb");
- gtk_widget_show (capture_type_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), capture_type_lb, 0, 2, 1,
- 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0),
- 0, 0);
- gtk_misc_set_alignment (GTK_MISC (capture_type_lb), 0, 0.5f);
-
- /* Start: Channel offset label */
- channel_offset_lb = gtk_label_new ("Channel Offset:");
- gtk_widget_set_name (channel_offset_lb, "channel_offset_lb");
- gtk_widget_show (channel_offset_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), channel_offset_lb, 0, 1, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (channel_offset_lb), 0, 0.5f);
- /* End: Channel offset label */
-
- /* Start: Channel offset combo box */
- channel_offset_cb = gtk_combo_box_text_new();
- gtk_widget_set_name (channel_offset_cb, "channel_offset_cb");
-
- airpcap_update_channel_offset_combo(airpcap_if_selected, airpcap_if_selected->channelInfo.Frequency, channel_offset_cb, FALSE);
-
- gtk_widget_show(channel_offset_cb);
-
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), channel_offset_cb, 1, 1, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- /* End: Channel offset combo box */
-
- channel_cb = gtk_combo_box_text_new();
- gtk_widget_set_name (channel_cb, "channel_cb");
- gtk_widget_show (channel_cb);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), channel_cb, 1, 0, 1, 1,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
-
- /* Select the current channel */
- airpcap_update_channel_combo(GTK_WIDGET(channel_cb), airpcap_if_selected);
-
- capture_type_cb = gtk_combo_box_text_new();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(capture_type_cb), AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(capture_type_cb), AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
- if (airpcap_get_dll_state() == AIRPCAP_DLL_OK) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(capture_type_cb), AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI);
- }
-
- gtk_widget_set_name (capture_type_cb, "capture_type_cb");
- gtk_widget_show (capture_type_cb);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), capture_type_cb, 1, 2, 1,
- 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
-
- /* Current interface value */
- if (airpcap_if_selected != NULL)
- {
- if (airpcap_if_selected->linkType == AIRPCAP_LT_802_11_PLUS_RADIO){
- gtk_combo_box_set_active(GTK_COMBO_BOX(capture_type_cb), AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_RADIO);
- }else if (airpcap_if_selected->linkType == AIRPCAP_LT_802_11_PLUS_PPI){
- gtk_combo_box_set_active(GTK_COMBO_BOX(capture_type_cb), AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_PPI);
- } else {
- gtk_combo_box_set_active(GTK_COMBO_BOX(capture_type_cb), AIRPCAP_LINK_TYPE_NUM_802_11_ONLY);
- }
- }
-
- fcs_ck = gtk_check_button_new_with_label ("Include 802.11 FCS in Frames");
-
- gtk_widget_set_name (fcs_ck, "fcs_ck");
-
- /* Fcs Presence check box */
- if (airpcap_if_selected != NULL)
- {
- if (airpcap_if_selected->IsFcsPresent)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fcs_ck),TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fcs_ck),FALSE);
- }
-
- gtk_widget_show (fcs_ck);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid), fcs_ck, 3, 0, 2, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
-
- basic_parameters_fcs_h_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
- gtk_widget_set_name (basic_parameters_fcs_h_box,
- "basic_parameters_fcs_h_box");
- gtk_widget_show (basic_parameters_fcs_h_box);
- ws_gtk_grid_attach_extended (GTK_GRID (basic_parameters_grid),
- basic_parameters_fcs_h_box, 3, 2, 2, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (GTK_FILL), 3, 0);
-
- basic_parameters_fcs_filter_lb = gtk_label_new ("FCS Filter:");
- gtk_widget_set_name (basic_parameters_fcs_filter_lb,
- "basic_parameters_fcs_filter_lb");
- gtk_widget_show (basic_parameters_fcs_filter_lb);
- gtk_box_pack_start (GTK_BOX (basic_parameters_fcs_h_box),
- basic_parameters_fcs_filter_lb, FALSE, FALSE, 0);
-
- fcs_filter_cb = gtk_combo_box_text_new();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fcs_filter_cb), airpcap_get_validation_name(AIRPCAP_VT_ACCEPT_EVERYTHING));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fcs_filter_cb), airpcap_get_validation_name(AIRPCAP_VT_ACCEPT_CORRECT_FRAMES));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fcs_filter_cb), airpcap_get_validation_name(AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES));
- gtk_combo_box_set_active(GTK_COMBO_BOX(fcs_filter_cb), 0);
- gtk_widget_set_name (fcs_filter_cb, "fcs_filter_cb");
- gtk_widget_show (fcs_filter_cb);
- gtk_box_pack_start (GTK_BOX (basic_parameters_fcs_h_box), fcs_filter_cb,
- FALSE, FALSE, 0);
- gtk_widget_set_size_request (fcs_filter_cb, 112, -1);
-
- if (airpcap_if_selected != NULL)
- {
- airpcap_validation_type_combo_set_by_type(fcs_filter_cb, airpcap_if_selected->CrcValidationOn);
- }
-
- basic_parameters_frame_lb = gtk_label_new ("<b>Basic Parameters</b>");
- gtk_widget_set_name (basic_parameters_frame_lb,
- "basic_parameters_frame_lb");
- gtk_widget_show (basic_parameters_frame_lb);
-
- gtk_frame_set_label_widget (GTK_FRAME (basic_parameters_fr),basic_parameters_frame_lb);
- gtk_label_set_use_markup (GTK_LABEL (basic_parameters_frame_lb), TRUE);
-
- low_buttons_h_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_widget_set_name (low_buttons_h_box, "low_buttons_h_box");
- gtk_widget_show (low_buttons_h_box);
- gtk_box_pack_end (GTK_BOX (main_box), low_buttons_h_box, FALSE, FALSE, 0);
-
- left_h_button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_set_name (left_h_button_box, "left_h_button_box");
- gtk_widget_show (left_h_button_box);
- gtk_box_pack_start (GTK_BOX (low_buttons_h_box), left_h_button_box, FALSE,
- FALSE, 0);
-
- /* dlg_button_row_new() returns an (h)box */
- right_h_button_box = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_CANCEL, NULL);
- gtk_widget_show (right_h_button_box);
- gtk_box_pack_end (GTK_BOX (low_buttons_h_box), right_h_button_box, FALSE,
- FALSE, 0);
-
- ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(right_h_button_box), GTK_STOCK_OK);
- apply_bt = (GtkWidget *)g_object_get_data(G_OBJECT(right_h_button_box), GTK_STOCK_APPLY);
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(right_h_button_box), GTK_STOCK_CANCEL);
-
- /* Connect the callbacks */
- g_signal_connect (airpcap_advanced_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect (airpcap_advanced_w, "destroy", G_CALLBACK(on_airpcap_advanced_destroy), airpcap_advanced_w);
-
- if (!airpcap_if_is_any(airpcap_if_selected))
- {
- g_signal_connect (blink_bt, "clicked", G_CALLBACK(on_blink_bt_clicked), NULL);
- }
- else
- {
- g_signal_connect (blink_bt, "clicked", G_CALLBACK(on_what_s_this_bt_clicked), NULL);
- }
-
- g_signal_connect (channel_cb, "changed", G_CALLBACK(airpcap_channel_changed_noset_cb), channel_offset_cb);
- /* We don't attach the channel offset combo because we don't want it changing anything yet. */
- g_signal_connect (capture_type_cb, "changed", G_CALLBACK(on_capture_type_cb_changed), NULL);
- g_signal_connect (fcs_ck, "toggled", G_CALLBACK(on_fcs_ck_toggled), NULL);
- g_signal_connect (fcs_filter_cb, "changed", G_CALLBACK(on_fcs_filter_cb_changed), NULL);
- g_signal_connect (apply_bt, "clicked", G_CALLBACK(on_advanced_apply_bt_clicked), airpcap_advanced_w);
- g_signal_connect (ok_bt,"clicked", G_CALLBACK(on_advanced_ok_bt_clicked), airpcap_advanced_w);
- g_signal_connect (cancel_bt,"clicked", G_CALLBACK(on_advanced_cancel_bt_clicked), airpcap_advanced_w);
-
- /* Different because the window will be closed ... */
- /*window_set_cancel_button(airpcap_advanced_w, ok_bt, window_cancel_button_cb);
- window_set_cancel_button(airpcap_advanced_w, cancel_bt, window_cancel_button_cb);*/
-
-
- /* Store pointers to all widgets, for use by lookup_widget(). */
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_BLINK_KEY, blink_bt);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_CHANNEL_KEY,channel_cb);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_CHANNEL_OFFSET_KEY, channel_offset_cb);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_LINK_TYPE_KEY,capture_type_cb);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_FCS_CHECK_KEY, fcs_ck);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_FCS_FILTER_KEY, fcs_filter_cb);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_OK_KEY, ok_bt);
- g_object_set_data (G_OBJECT(airpcap_advanced_w), AIRPCAP_ADVANCED_CANCEL_KEY, cancel_bt);
-
- /*
- * I will need the toolbar and the main widget in some callback,
- * so I will add the toolbar pointer to the airpcap_advanced_w
- */
- g_object_set_data(G_OBJECT(airpcap_advanced_w),AIRPCAP_TOOLBAR_KEY,toolbar);
-
- /* At the end, so that it appears completely all together ... */
- gtk_widget_show (airpcap_advanced_w);
-}
-
-/*
- * Callback for the OK button 'clicked' in the Decryption Key Management window.
- */
-static void
-on_key_management_ok_bt_clicked(GtkWidget *button, gpointer data)
-{
- /* advanced window */
- GtkWidget *key_management_w;
-
- /* retrieve main window */
- key_management_w = GTK_WIDGET(data);
-
- /* Apply the current decryption preferences */
- on_key_management_apply_bt_clicked(button, data);
-
- gtk_widget_destroy(key_management_w);
-}
-
-/*
- * Callback for the CANCEL button 'clicked' in the Decryption Key Management window.
- */
-static void
-on_key_management_cancel_bt_clicked(GtkWidget *button _U_, gpointer data)
-{
- /* Retrieve object data */
- GtkWidget *key_management_w;
-
- /* Retrieve the GUI object pointers */
- key_management_w = GTK_WIDGET(data);
-
- gtk_widget_destroy(key_management_w);
-}
-
-/* Called to create the key management window */
-void
-display_airpcap_key_management_cb(GtkWidget *w _U_, gpointer data)
-{
- GtkWidget *key_management_w;
- GtkWidget *main_box;
- GtkWidget *keys_fr;
- GtkWidget *keys_al;
- GtkWidget *keys_h_sub_box;
- GtkWidget *decryption_mode_grid;
- GtkWidget *decryption_mode_lb;
- GtkWidget *decryption_mode_cb;
- GtkWidget *keys_v_sub_box;
- GtkWidget *keys_scrolled_w;
- GtkListStore *key_list_store;
- GtkWidget *key_list;
- GtkWidget *key_v_button_box;
- GtkWidget *add_new_key_bt;
- GtkWidget *remove_key_bt;
- GtkWidget *edit_key_bt;
- GtkWidget *move_key_up_bt;
- GtkWidget *move_key_down_bt;
- GtkWidget *keys_frame_lb;
- GtkWidget *low_buttons_h_box;
- GtkWidget *left_h_button_box;
- GtkWidget *right_h_button_box;
- GtkWidget *ok_bt;
- GtkWidget *apply_bt;
- GtkWidget *cancel_bt;
-
- /* widgets in the toolbar */
- GtkWidget *toolbar,
- *toolbar_decryption_ck;
-
- /* key list */
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- /* user data - RETRIEVE pointers of toolbar widgets */
- toolbar = GTK_WIDGET(data);
- toolbar_decryption_ck = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbar),AIRPCAP_TOOLBAR_DECRYPTION_KEY));
-
- /* gray out the toolbar */
- gtk_widget_set_sensitive(toolbar,FALSE);
-
- /* main window */
- /* global */
-
- /* the selected is the active, for now */
- airpcap_if_selected = airpcap_if_active;
-
- /* Create the new window */
- key_management_w = dlg_window_new("Decryption Key Management"); /* transient_for top_level */
- gtk_window_set_destroy_with_parent(GTK_WINDOW(key_management_w), TRUE);
- gtk_window_set_modal(GTK_WINDOW(key_management_w), TRUE);
-
- gtk_container_set_border_width (GTK_CONTAINER (key_management_w), 5);
- gtk_window_set_position (GTK_WINDOW (key_management_w),
- GTK_WIN_POS_CENTER);
-
- gtk_window_set_resizable (GTK_WINDOW (key_management_w), FALSE);
- gtk_window_set_type_hint (GTK_WINDOW (key_management_w), GDK_WINDOW_TYPE_HINT_DIALOG);
-
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (main_box, "main_box");
- gtk_widget_show (main_box);
- gtk_container_add (GTK_CONTAINER (key_management_w), main_box);
-
- keys_fr = gtk_frame_new (NULL);
- gtk_widget_set_name (keys_fr, "keys_fr");
- gtk_widget_show (keys_fr);
- gtk_box_pack_start (GTK_BOX (main_box), keys_fr, FALSE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (keys_fr), 10);
-
- keys_al = gtk_alignment_new (0.5f, 0.5f, 1, 1);
- gtk_widget_set_name (keys_al, "keys_al");
- gtk_widget_show (keys_al);
- gtk_container_add (GTK_CONTAINER (keys_fr), keys_al);
- gtk_container_set_border_width (GTK_CONTAINER (keys_al), 5);
-
- gtk_alignment_set_padding (GTK_ALIGNMENT (keys_al), 0, 0, 12, 0);
-
- keys_h_sub_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (keys_h_sub_box, "keys_h_sub_box");
- gtk_widget_show (keys_h_sub_box);
- gtk_container_add (GTK_CONTAINER (keys_al), keys_h_sub_box);
-
- decryption_mode_grid = ws_gtk_grid_new ();
- gtk_widget_set_name (decryption_mode_grid, "decryption_mode_grid");
- gtk_widget_show (decryption_mode_grid);
- gtk_box_pack_start (GTK_BOX (keys_h_sub_box), decryption_mode_grid, FALSE,
- FALSE, 0);
- ws_gtk_grid_set_row_spacing(GTK_GRID(decryption_mode_grid), 6);
-
- decryption_mode_lb = gtk_label_new ("Select Decryption Mode");
- gtk_widget_set_name (decryption_mode_lb, "decryption_mode_lb");
- gtk_widget_show (decryption_mode_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (decryption_mode_grid), decryption_mode_lb, 1,
- 0, 1, 1, (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (decryption_mode_lb), 0, 0.5f);
-
- decryption_mode_cb = gtk_combo_box_text_new();
- update_decryption_mode_list(decryption_mode_cb);
- gtk_widget_set_name (decryption_mode_cb, "decryption_mode_cb");
- gtk_widget_show (decryption_mode_cb);
- ws_gtk_grid_attach_extended (GTK_GRID (decryption_mode_grid), decryption_mode_cb, 0,
- 0, 1, 1, (GtkAttachOptions) (0), (GtkAttachOptions) (0),
- 0, 0);
- gtk_widget_set_size_request (decryption_mode_cb, 83, -1);
-
- /* Set correct decryption mode!!!! */
- update_decryption_mode(decryption_mode_cb);
-
- keys_v_sub_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_widget_set_name (keys_v_sub_box, "keys_v_sub_box");
- gtk_widget_show (keys_v_sub_box);
- gtk_box_pack_start (GTK_BOX (keys_h_sub_box), keys_v_sub_box, TRUE, TRUE, 0);
-
- keys_scrolled_w = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_set_name (keys_scrolled_w, "keys_scrolled_w");
- gtk_widget_show (keys_scrolled_w);
- gtk_box_pack_start (GTK_BOX (keys_v_sub_box), keys_scrolled_w, TRUE, TRUE,
- 0);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (keys_scrolled_w), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
-
-
- /* Create the store */
- key_list_store = gtk_list_store_new(KL_NUM_COLS,
- G_TYPE_STRING, /* Type */
- G_TYPE_STRING /* Key */
- , G_TYPE_STRING /* SSID */
- );
-
- /* Create a view */
- key_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(key_list_store));
-
- /* Speed up the list display */
- gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(key_list), TRUE);
-
- /* Setup the sortable columns */
- gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(key_list), FALSE);
-
- /* The view now holds a reference. We can get rid of our own reference */
- g_object_unref(G_OBJECT(key_list_store));
-
- /*
- * Create the first column packet, associating the "text" attribute of the
- * cell_renderer to the first column of the model
- */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Type", renderer,
- "text", KL_COL_TYPE, NULL);
- gtk_tree_view_column_set_sort_column_id(column, KL_COL_TYPE);
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_min_width(column, 60);
- gtk_tree_view_column_set_fixed_width(column, 100);
- /* Add the column to the view. */
- gtk_tree_view_append_column(GTK_TREE_VIEW(key_list), column);
-
- /* Key */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Key", renderer,
- "text", KL_COL_KEY, NULL);
- gtk_tree_view_column_set_sort_column_id(column, KL_COL_KEY);
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_min_width(column, 120);
- gtk_tree_view_column_set_fixed_width(column, 200);
- gtk_tree_view_append_column(GTK_TREE_VIEW(key_list), column);
-
- /* SSID */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("SSID", renderer,
- "text", KL_COL_SSID,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, KL_COL_SSID);
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_min_width(column, 80);
- gtk_tree_view_column_set_fixed_width(column, 150);
- gtk_tree_view_append_column(GTK_TREE_VIEW(key_list), column);
-
- /* Now enable the sorting of each column */
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(key_list), TRUE);
- gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(key_list), TRUE);
-
- /* Setup the selection handler */
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(key_list));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
-
- gtk_widget_show (key_list);
-
- gtk_container_add (GTK_CONTAINER (keys_scrolled_w), key_list);
-
- key_v_button_box = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
- gtk_widget_set_name (key_v_button_box, "key_v_button_box");
- gtk_widget_show (key_v_button_box);
- gtk_box_pack_start (GTK_BOX (keys_v_sub_box), key_v_button_box, FALSE, TRUE,
- 0);
-
- add_new_key_bt = ws_gtk_button_new_from_stock(GTK_STOCK_NEW);
- gtk_widget_set_name (add_new_key_bt, "add_new_key_bt");
- gtk_widget_show (add_new_key_bt);
- gtk_container_add (GTK_CONTAINER (key_v_button_box), add_new_key_bt);
- gtk_widget_set_can_default (add_new_key_bt, TRUE);
-
- edit_key_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_EDIT);
- gtk_widget_set_name (edit_key_bt, "edit_key_bt");
- gtk_widget_show (edit_key_bt);
- gtk_container_add (GTK_CONTAINER (key_v_button_box), edit_key_bt);
- gtk_widget_set_can_default (edit_key_bt, TRUE);
-
- remove_key_bt = ws_gtk_button_new_from_stock(GTK_STOCK_DELETE);
- gtk_widget_set_name (remove_key_bt, "remove_key_bt");
- gtk_widget_show (remove_key_bt);
- gtk_container_add (GTK_CONTAINER (key_v_button_box), remove_key_bt);
- gtk_widget_set_can_default (remove_key_bt, TRUE);
-
- move_key_up_bt = ws_gtk_button_new_from_stock(GTK_STOCK_GO_UP);
- gtk_widget_set_name (move_key_up_bt, "move_key_up_bt");
- gtk_widget_show (move_key_up_bt);
- gtk_container_add (GTK_CONTAINER (key_v_button_box), move_key_up_bt);
- gtk_widget_set_can_default (move_key_up_bt, TRUE);
-
- move_key_down_bt = ws_gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
- gtk_widget_set_name (move_key_down_bt, "move_key_down_bt");
- gtk_widget_show (move_key_down_bt);
- gtk_container_add (GTK_CONTAINER (key_v_button_box), move_key_down_bt);
- gtk_widget_set_can_default (move_key_down_bt, TRUE);
-
- keys_frame_lb = gtk_label_new ("<b>Decryption Keys</b>");
- gtk_widget_set_name (keys_frame_lb, "keys_frame_lb");
- gtk_widget_show (keys_frame_lb);
-
- gtk_frame_set_label_widget (GTK_FRAME (keys_fr), keys_frame_lb);
- gtk_label_set_use_markup (GTK_LABEL (keys_frame_lb), TRUE);
-
- low_buttons_h_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_widget_set_name (low_buttons_h_box, "low_buttons_h_box");
- gtk_widget_show (low_buttons_h_box);
- gtk_box_pack_end (GTK_BOX (main_box), low_buttons_h_box, FALSE, FALSE, 0);
-
- left_h_button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_set_name (left_h_button_box, "left_h_button_box");
- gtk_widget_show (left_h_button_box);
- gtk_box_pack_start (GTK_BOX (low_buttons_h_box), left_h_button_box, FALSE,
- FALSE, 0);
-
- /* dlg_button_row_new() returns an (h)box */
- right_h_button_box = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_CANCEL, NULL);
- gtk_widget_set_name (right_h_button_box, "right_h_button_box");
- gtk_widget_show (right_h_button_box);
- gtk_box_pack_end (GTK_BOX (low_buttons_h_box), right_h_button_box, FALSE,
- FALSE, 0);
-
- ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(right_h_button_box), GTK_STOCK_OK);
- apply_bt = (GtkWidget *)g_object_get_data(G_OBJECT(right_h_button_box), GTK_STOCK_APPLY);
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(right_h_button_box), GTK_STOCK_CANCEL);
-
- /* Connect the callbacks */
- g_signal_connect (key_management_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect (key_management_w, "destroy", G_CALLBACK(on_key_management_destroy), key_management_w);
- g_signal_connect (add_new_key_bt, "clicked", G_CALLBACK(on_add_new_key_bt_clicked), key_management_w);
- g_signal_connect (remove_key_bt, "clicked", G_CALLBACK(on_remove_key_bt_clicked), key_management_w);
- g_signal_connect (edit_key_bt, "clicked", G_CALLBACK(on_edit_key_bt_clicked), key_management_w);
- g_signal_connect (move_key_up_bt, "clicked", G_CALLBACK(on_move_key_up_bt_clicked), key_list);
- g_signal_connect (move_key_down_bt, "clicked", G_CALLBACK(on_move_key_down_bt_clicked), key_list);
- g_signal_connect (apply_bt, "clicked", G_CALLBACK(on_key_management_apply_bt_clicked), key_management_w);
- g_signal_connect (ok_bt, "clicked", G_CALLBACK(on_key_management_ok_bt_clicked), key_management_w);
- g_signal_connect (cancel_bt, "clicked", G_CALLBACK(on_key_management_cancel_bt_clicked), key_management_w);
- g_signal_connect (selection, "changed", G_CALLBACK(on_key_list_select_row), key_management_w);
- g_signal_connect (key_list_store, "rows_reordered", G_CALLBACK(on_key_list_reorder), key_management_w);
-
- /* Different because the window will be closed ... */
- /*window_set_cancel_button(key_management_w, ok_bt, window_cancel_button_cb);
- window_set_cancel_button(key_management_w, cancel_bt, window_cancel_button_cb);*/
-
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY,selection);
-
- /* Store pointers to all widgets, for use by lookup_widget(). */
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_ADVANCED_DECRYPTION_MODE_KEY, decryption_mode_cb);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_ADVANCED_KEYLIST_KEY, key_list_store);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_ADVANCED_OK_KEY, ok_bt);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_ADVANCED_CANCEL_KEY, cancel_bt);
-
- /* Enable / disable buttons */
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_KEY_MGMT_NEW_KEY, add_new_key_bt);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_KEY_MGMT_EDIT_KEY, edit_key_bt);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_KEY_MGMT_DELETE_KEY, remove_key_bt);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_KEY_MGMT_UP_KEY, move_key_up_bt);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_KEY_MGMT_DOWN_KEY, move_key_down_bt);
-
- /*
- * I will need the toolbar and the main widget in some callback,
- * so I will add the toolbar pointer to the key_management_w
- */
- g_object_set_data(G_OBJECT(key_management_w),AIRPCAP_TOOLBAR_KEY,toolbar);
- g_object_set_data (G_OBJECT(key_management_w), AIRPCAP_TOOLBAR_DECRYPTION_KEY, toolbar_decryption_ck);
-
- /* FIRST OF ALL, CHECK THE KEY COLLECTIONS */
- /*
- * This will read the decryption keys from the preferences file, and will store
- * them into the registry...
- */
- if (!airpcap_check_decryption_keys(g_airpcap_if_list))
- {
- /* Ask the user what to do ...*/
- airpcap_keys_check_w(key_management_w,NULL);
- }
- else /* Keys from lists are equals, or Wireshark has got no keys */
- {
- airpcap_load_decryption_keys(g_airpcap_if_list);
- airpcap_fill_key_list(key_list_store);
- /* At the end, so that it appears completely all together ... */
- gtk_widget_show (key_management_w);
- }
-
- if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(key_list_store), &iter))
- {
- gtk_tree_selection_select_iter(selection, &iter);
- }
-}
-
-
-static void
-on_keys_check_cancel_bt_clicked (GtkWidget *button _U_, gpointer user_data)
-{
- GtkWidget *key_management_w;
- GtkWidget *keys_check_w;
- GtkListStore *key_list_store;
-
- keys_check_w = GTK_WIDGET(user_data);
-
- key_management_w = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_KEY);
-
- /* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
- and is not NULL if it was called when the Key Management widget has been clicked */
- if (key_management_w != NULL)
- {
- /* ... */
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_KEYLIST_KEY);
- airpcap_fill_key_list(key_list_store);
- gtk_widget_show (key_management_w);
- }
-
- gtk_widget_destroy(keys_check_w);
-}
-
-static void
-on_merge_bt_clicked (GtkWidget* button _U_, gpointer user_data)
-{
- GtkWidget *key_management_w;
- GtkWidget *keys_check_w;
- GtkListStore *key_list_store;
-
- guint n_adapters = 0;
- guint i = 0;
-
- GList* wireshark_keys=NULL;
- GList* driver_keys=NULL;
- GList* current_adapter_keys=NULL;
- GList* merged_list = NULL;
- GList* merged_list_tmp = NULL;
-
- airpcap_if_info_t* curr_adapter;
-
- keys_check_w = GTK_WIDGET(user_data);
-
- key_management_w = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_KEY);
-
- n_adapters = g_list_length(g_airpcap_if_list);
-
- /* Retrieve Wireshark keys */
- wireshark_keys = get_wireshark_keys();
-
- merged_list = merge_key_list(wireshark_keys,NULL);
-
- /* Retrieve AirPcap driver's keys */
- driver_keys = get_airpcap_driver_keys();
-
- merged_list = merge_key_list(merged_list,driver_keys);
-
- /* NOW wireshark_keys and driver_keys ARE no more needed... at the end, we will have to free them! */
- for (i = 0; i<n_adapters; i++)
- {
- curr_adapter = (airpcap_if_info_t*)g_list_nth_data(g_airpcap_if_list,i);
- current_adapter_keys = get_airpcap_device_keys(curr_adapter);
-
- merged_list_tmp = merged_list;
- merged_list = merge_key_list(merged_list_tmp,current_adapter_keys);
- free_key_list(merged_list_tmp);
-
- }
-
- /* Set up this new list as default for Wireshark and Adapters... */
- airpcap_save_decryption_keys(merged_list,g_airpcap_if_list);
-
- free_key_list(wireshark_keys);
- free_key_list(driver_keys);
-
- gtk_widget_destroy(keys_check_w);
-
- /* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
- and is not NULL if it was called when the Key Management widget has been clicked */
- if (key_management_w != NULL)
- {
- /* ... */
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_KEYLIST_KEY);
- airpcap_fill_key_list(key_list_store);
- gtk_widget_show (key_management_w);
- }
-}
-
-static void
-on_keep_bt_clicked (GtkWidget *button _U_, gpointer user_data)
-{
- GtkWidget *key_management_w;
- GtkWidget *keys_check_w;
- GtkListStore *key_list_store=NULL;
-
- GList* wireshark_keys=NULL;
-
- GList* merged_keys=NULL;
-
- keys_check_w = GTK_WIDGET(user_data);
-
- key_management_w = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_KEY);
-
- /* Retrieve Wireshark keys */
- wireshark_keys = get_wireshark_keys();
-
- merged_keys = merge_key_list(wireshark_keys,NULL);
-
- /* Set up this new list as default for Wireshark and Adapters... */
- airpcap_save_decryption_keys(merged_keys,g_airpcap_if_list);
-
- /* Free the memory */
- free_key_list(wireshark_keys);
-
- /* Close the window */
- gtk_widget_destroy(keys_check_w);
-
- /* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
- and is not NULL if it was called when the Key Management widget has been clicked */
- if (key_management_w != NULL)
- {
- /* ... */
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_KEYLIST_KEY);
- airpcap_fill_key_list(key_list_store);
- gtk_widget_show (key_management_w);
- }
-}
-
-static void
-on_import_bt_clicked (GtkWidget* button _U_, gpointer user_data)
-{
- GtkWidget *key_management_w;
- GtkWidget *keys_check_w;
- GtkListStore *key_list_store;
-
- guint n_adapters = 0;
- guint i = 0;
-
- GList* wireshark_keys=NULL;
- GList* driver_keys=NULL;
- GList* current_adapter_keys=NULL;
- GList* merged_list = NULL;
- GList* merged_list_tmp = NULL;
-
- airpcap_if_info_t* curr_adapter;
-
- keys_check_w = GTK_WIDGET(user_data);
-
- key_management_w = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_KEY);
-
- n_adapters = g_list_length(g_airpcap_if_list);
-
- wireshark_keys = get_wireshark_keys();
-
- /* Retrieve AirPcap driver's keys */
- driver_keys = get_airpcap_driver_keys();
-
- merged_list = merge_key_list(merged_list,driver_keys);
-
- /* NOW wireshark_keys IS no more needed... at the end, we will have to free it! */
- for (i = 0; i<n_adapters; i++)
- {
- curr_adapter = (airpcap_if_info_t*)g_list_nth_data(g_airpcap_if_list,i);
- current_adapter_keys = get_airpcap_device_keys(curr_adapter);
-
- merged_list_tmp = merged_list;
- merged_list = merge_key_list(merged_list_tmp,current_adapter_keys);
- free_key_list(merged_list_tmp);
-
- }
-
- /* Set up this new list as default for Wireshark and Adapters... */
- airpcap_save_decryption_keys(merged_list,g_airpcap_if_list);
-
- free_key_list(wireshark_keys);
- free_key_list(driver_keys);
-
- gtk_widget_destroy(keys_check_w);
-
- /* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
- and is not NULL if it was called when the Key Management widget has been clicked */
- if (key_management_w != NULL)
- {
- /* ... */
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_KEYLIST_KEY);
- airpcap_fill_key_list(key_list_store);
- gtk_widget_show (key_management_w);
- }
-}
-
-static void
-on_ignore_bt_clicked (GtkWidget* button _U_, gpointer user_data)
-{
- GtkWidget *key_management_w;
- GtkWidget *keys_check_w;
- GtkListStore *key_list_store;
-
- keys_check_w = GTK_WIDGET(user_data);
-
- key_management_w = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_KEY);
-
- /* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
- and is not NULL if it was called when the Key Management widget has been clicked */
- if (key_management_w != NULL)
- {
- /* ... */
- key_list_store = (GtkListStore *)g_object_get_data(G_OBJECT(key_management_w),AIRPCAP_ADVANCED_KEYLIST_KEY);
- airpcap_fill_key_list(key_list_store);
- gtk_widget_show (key_management_w);
- }
-
- gtk_widget_destroy(keys_check_w);
-}
-
-static void
-on_keys_check_ok_bt_clicked (GtkWidget *button _U_, gpointer user_data)
-{
- GtkWidget *keys_check_w;
-
- GtkWidget *merge_rb,
- *keep_rb,
- *import_rb,
- *ignore_rb;
-
- keys_check_w = GTK_WIDGET(user_data);
-
- merge_rb = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_MERGE_KEY);
- keep_rb = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_KEEP_KEY);
- import_rb = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_IMPORT_KEY);
- ignore_rb = (GtkWidget *)g_object_get_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_IGNORE_KEY);
-
- /* Find out which radio button is selected and call the correct function */
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(merge_rb)))
- on_merge_bt_clicked (merge_rb,keys_check_w);
- else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(keep_rb)))
- on_keep_bt_clicked (keep_rb,keys_check_w);
- else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(import_rb)))
- on_import_bt_clicked (import_rb,keys_check_w);
- else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ignore_rb)))
- on_ignore_bt_clicked (ignore_rb,keys_check_w);
- else on_keys_check_cancel_bt_clicked(NULL,keys_check_w);
-}
-
-static void
-on_keys_check_w_destroy (GtkWidget *w _U_, gpointer user_data)
-{
- gtk_widget_set_sensitive(top_level,TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(user_data),TRUE);
-}
-
-/*
- * Dialog box that appears whenever keys are not consistent between Wireshark and AirPcap
- */
-void
-airpcap_keys_check_w(GtkWidget *w, gpointer data _U_)
-{
- GtkWidget *keys_check_w;
- GtkWidget *main_v_box;
- GtkWidget *warning_lb;
- GtkWidget *radio_grid;
- GtkWidget *keep_rb;
- GSList *radio_bt_group = NULL;
- GtkWidget *merge_rb;
- GtkWidget *import_rb;
- GtkWidget *ignore_rb;
- GtkWidget *keep_lb;
- GtkWidget *merge_lb;
- GtkWidget *import_lb;
- GtkWidget *ignore_lb;
- GtkWidget *low_h_button_box;
- GtkWidget *ok_bt;
- GtkWidget *cancel_bt;
-
- keys_check_w = window_new (GTK_WINDOW_TOPLEVEL, "Decryption Key Warning");
- gtk_widget_set_name (keys_check_w, "keys_check_w");
- gtk_window_set_resizable (GTK_WINDOW (keys_check_w), FALSE);
-
- main_v_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_widget_set_name (main_v_box, "main_v_box");
- gtk_widget_show (main_v_box);
- gtk_container_add (GTK_CONTAINER (keys_check_w), main_v_box);
-
- warning_lb = gtk_label_new("<b>WARNING</b> Decryption keys specified in Wireshark's preferences file differ from those specified for the AirPcap adapter(s). You can choose to:");
- gtk_label_set_use_markup (GTK_LABEL (warning_lb), TRUE);
- gtk_widget_set_name (warning_lb, "warning_lb");
- gtk_widget_show (warning_lb);
- gtk_box_pack_start (GTK_BOX (main_v_box), warning_lb, FALSE, FALSE, 0);
- gtk_label_set_justify (GTK_LABEL (warning_lb), GTK_JUSTIFY_CENTER);
- gtk_label_set_line_wrap (GTK_LABEL (warning_lb), TRUE);
-
- radio_grid = ws_gtk_grid_new();
- gtk_widget_set_name (radio_grid, "radio_grid");
- gtk_widget_show (radio_grid);
- gtk_box_pack_start (GTK_BOX (main_v_box), radio_grid, TRUE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (radio_grid), 5);
- ws_gtk_grid_set_column_spacing (GTK_GRID (radio_grid), 8);
-
- keep_rb = gtk_radio_button_new_with_mnemonic (NULL, "Keep");
- gtk_widget_set_name (keep_rb, "keep_rb");
- gtk_widget_show (keep_rb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), keep_rb, 0, 0, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_radio_button_set_group (GTK_RADIO_BUTTON (keep_rb), radio_bt_group);
- radio_bt_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (keep_rb));
-
- merge_rb = gtk_radio_button_new_with_mnemonic (NULL, "Merge");
- gtk_widget_set_name (merge_rb, "merge_rb");
- gtk_widget_show (merge_rb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), merge_rb, 0, 1, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_radio_button_set_group (GTK_RADIO_BUTTON (merge_rb), radio_bt_group);
- radio_bt_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (merge_rb));
-
- import_rb = gtk_radio_button_new_with_mnemonic (NULL, "Import");
- gtk_widget_set_name (import_rb, "import_rb");
- gtk_widget_show (import_rb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), import_rb, 0, 2, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_radio_button_set_group (GTK_RADIO_BUTTON (import_rb), radio_bt_group);
- radio_bt_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (import_rb));
-
- ignore_rb = gtk_radio_button_new_with_mnemonic (NULL, "Ignore");
- gtk_widget_set_name (ignore_rb, "ignore_rb");
- gtk_widget_show (ignore_rb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), ignore_rb, 0, 3, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_radio_button_set_group (GTK_RADIO_BUTTON (ignore_rb), radio_bt_group);
- radio_bt_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (ignore_rb));
-
- keep_lb =
- gtk_label_new
- ("Use Wireshark keys, thus overwriting AirPcap adapter(s) ones.");
- gtk_widget_set_name (keep_lb, "keep_lb");
- gtk_widget_show (keep_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), keep_lb, 1, 0, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (keep_lb), 0, 0.5f);
-
- merge_lb = gtk_label_new ("Merge Wireshark and AirPcap adapter(s) keys.");
- gtk_widget_set_name (merge_lb, "merge_lb");
- gtk_widget_show (merge_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), merge_lb, 1, 1, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (merge_lb), 0, 0.5f);
-
- import_lb =
- gtk_label_new
- ("Use AirPcap adapter(s) keys, thus overwriting Wireshark ones.");
- gtk_widget_set_name (import_lb, "import_lb");
- gtk_widget_show (import_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), import_lb, 1, 2, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (import_lb), 0, 0.5f);
-
- ignore_lb =
- gtk_label_new
- ("Keep using different set of keys. Remember that in this case, this dialog box will appear whenever you will attempt to modify/add/remove decryption keys.");
- gtk_widget_set_name (ignore_lb, "ignore_lb");
- gtk_widget_show (ignore_lb);
- ws_gtk_grid_attach_extended (GTK_GRID (radio_grid), ignore_lb, 1, 3, 1, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_label_set_line_wrap (GTK_LABEL (ignore_lb), TRUE);
- gtk_misc_set_alignment (GTK_MISC (ignore_lb), 0, 0.5f);
-
- low_h_button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_set_name (low_h_button_box, "low_h_button_box");
- gtk_widget_show (low_h_button_box);
- gtk_box_pack_start (GTK_BOX (main_v_box), low_h_button_box, FALSE, FALSE,
- 0);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
- GTK_BUTTONBOX_SPREAD);
-
- ok_bt = gtk_button_new_with_mnemonic ("OK");
- gtk_widget_set_name (ok_bt, "ok_bt");
- gtk_widget_show (ok_bt);
- gtk_container_add (GTK_CONTAINER (low_h_button_box), ok_bt);
- gtk_widget_set_can_default (ok_bt, TRUE);
-
- cancel_bt = gtk_button_new_with_mnemonic ("Cancel");
- gtk_widget_set_name (cancel_bt, "cancel_bt");
- gtk_widget_show (cancel_bt);
- gtk_container_add (GTK_CONTAINER (low_h_button_box), cancel_bt);
- gtk_widget_set_can_default (cancel_bt, TRUE);
-
- /* Store pointers to all widgets, for use by lookup_widget(). */
- g_signal_connect (ok_bt, "clicked", G_CALLBACK(on_keys_check_ok_bt_clicked), keys_check_w);
- g_signal_connect (cancel_bt, "clicked", G_CALLBACK(on_keys_check_cancel_bt_clicked), keys_check_w);
- g_signal_connect (keys_check_w, "destroy", G_CALLBACK(on_keys_check_w_destroy), keys_check_w);
-
- /* Store pointers to all widgets, for use by lookup_widget(). */
- g_object_set_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_KEY,w);
- g_object_set_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_MERGE_KEY,merge_rb);
- g_object_set_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_KEEP_KEY,keep_rb);
- g_object_set_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_IMPORT_KEY,import_rb);
- g_object_set_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_IGNORE_KEY,ignore_rb);
- g_object_set_data(G_OBJECT(keys_check_w),AIRPCAP_CHECK_WINDOW_RADIO_GROUP_KEY,radio_bt_group);
-
- gtk_widget_set_sensitive(top_level,FALSE);
- gtk_widget_show(keys_check_w);
-}
-
-
-#endif /* HAVE_AIRPCAP */
-
-/*
- * 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:
- */
diff --git a/ui/gtk/airpcap_dlg.h b/ui/gtk/airpcap_dlg.h
deleted file mode 100644
index d90cccaa98..0000000000
--- a/ui/gtk/airpcap_dlg.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* airpcap_dlg.h
- * Declarations of routines for the "Airpcap" dialog
- *
- * Giorgio Tino <giorgio.tino@cacetech.com>
- * Copyright (c) CACE Technologies, LLC 2006
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __AIRPCAP_DLG_H__
-#define __AIRPCAP_DLG_H__
-
-#define AIRPCAP_ADVANCED_FROM_TOOLBAR 0
-#define AIRPCAP_ADVANCED_FROM_OPTIONS 1
-
-/*
- * Creates the list of available decryption modes, depending on the adapters found
- */
-void update_decryption_mode_list(GtkWidget *w);
-
-/*
- * Selects the current decryption mode in the given combo box
- */
-void update_decryption_mode(GtkWidget *w);
-
-/*
- * Turns the decryption on or off
- */
-void on_decryption_mode_cb_changed(GtkWidget *w, gpointer data _U_);
-
-/** Create a "Airpcap" dialog box caused by a button click.
- *
- * @param widget parent widget
- * @param construct_args_ptr parameters to construct the dialog (construct_args_t)
- */
-void display_airpcap_advanced_cb(GtkWidget *widget, gpointer construct_args_ptr);
-
-/* Called to create the key management window */
-void display_airpcap_key_management_cb(GtkWidget *w, gpointer data);
-
-/**/
-/*
- * Dialog box that appears whenever keys are not consistent between wieshark and airpcap
- */
-void airpcap_keys_check_w(GtkWidget *w, gpointer data);
-
-#endif
diff --git a/ui/gtk/airpcap_gui_utils.c b/ui/gtk/airpcap_gui_utils.c
deleted file mode 100644
index 5d67ecab92..0000000000
--- a/ui/gtk/airpcap_gui_utils.c
+++ /dev/null
@@ -1,2377 +0,0 @@
-/* airpcap_gui_utils.c
- *
- * Giorgio Tino <giorgio.tino@cacetech.com>
- * Copyright (c) CACE Technologies, LLC 2006
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 2000 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <wsutil/filesystem.h>
-#include <wsutil/frequency-utils.h>
-
-#include <epan/prefs.h>
-#include <epan/prefs-int.h>
-#include <epan/uat-int.h>
-#include <epan/strutil.h>
-#include <epan/crypt/dot11decrypt_ws.h>
-#include <epan/crypt/wep-wpadefs.h>
-
-#include <epan/packet.h>
-#include <epan/dissectors/packet-ieee80211.h>
-
-#include "ui/capture_ui_utils.h"
-#include "ui/simple_dialog.h"
-
-#include "ui/gtk/main.h"
-#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/dfilter_expr_dlg.h"
-#include "ui/gtk/help_dlg.h"
-#include "ui/gtk/keys.h"
-#include "ui/gtk/old-gtk-compat.h"
-
-#include <caputils/airpcap.h>
-#include <caputils/airpcap_loader.h>
-#include "airpcap_gui_utils.h"
-
-
-/* Controls the releay of settings back to the adapter. */
-gboolean change_airpcap_settings = FALSE;
-
-/* WLAN preferences pointer */
-module_t *wlan_prefs = NULL;
-
-/*
- * Set up the airpcap toolbar for the new capture interface
- */
-void
-airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
-{
- GtkWidget *airpcap_toolbar_label;
- GtkWidget *toolbar_channel_cb;
- GtkWidget *airpcap_toolbar_channel_lb;
- GtkWidget *airpcap_toolbar_channel_offset;
- GtkWidget *airpcap_toolbar_channel_offset_lb;
- GtkWidget *airpcap_toolbar_button;
- GtkWidget *airpcap_toolbar_fcs;
- GtkWidget *airpcap_toolbar_fcs_lb;
- GtkWidget *airpcap_toolbar_decryption;
- GtkWidget *airpcap_toolbar_decryption_lb;
- GtkWidget *airpcap_toolbar_keys_button;
-
- gchar *if_label_text;
-
- airpcap_toolbar_label = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
- toolbar_channel_cb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
- airpcap_toolbar_channel_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
- airpcap_toolbar_channel_offset = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
- airpcap_toolbar_channel_offset_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
- airpcap_toolbar_fcs = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
- airpcap_toolbar_fcs_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
- airpcap_toolbar_button = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_ADVANCED_KEY);
- airpcap_toolbar_decryption = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
- airpcap_toolbar_decryption_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY);
- airpcap_toolbar_keys_button = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_KEY_MANAGEMENT_KEY);
-
- /* The current interface is an airpcap interface */
- if (if_info != NULL)
- {
- gtk_widget_set_sensitive(wireless_tb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_label,TRUE);
- gtk_widget_set_sensitive(toolbar_channel_cb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
-
- /*decryption check box*/
- g_signal_handlers_block_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, wireless_tb);
- if (if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
- g_signal_handlers_unblock_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, wireless_tb);
-
- if_label_text = g_strdup_printf("Current Wireless Interface: #%s", airpcap_get_if_string_number(if_info));
- gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
- g_free(if_label_text);
-
- change_airpcap_settings = FALSE;
- if (if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0) {
- guint i = 0;
-
- for (; i<if_info->numSupportedChannels; i++) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(toolbar_channel_cb), ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
- }
- }
-
- airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),if_info);
- airpcap_update_channel_offset_combo(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset, TRUE);
- change_airpcap_settings = TRUE;
- }
- else /* Current interface is NOT an AirPcap one... */
- {
- gtk_widget_set_sensitive(wireless_tb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
- gtk_widget_set_sensitive(toolbar_channel_cb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
- }
-}
-
-/*
- * Set up the airpcap toolbar for the new capture interface
- */
-void
-airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
-{
- GtkWidget *airpcap_toolbar_crc_filter_combo;
- GtkWidget *airpcap_toolbar_label;
- GtkWidget *toolbar_channel_cb;
- GtkWidget *airpcap_toolbar_channel_lb;
- GtkWidget *airpcap_toolbar_channel_offset;
- GtkWidget *airpcap_toolbar_channel_offset_lb;
- GtkWidget *airpcap_toolbar_button;
- GtkWidget *airpcap_toolbar_fcs;
- GtkWidget *airpcap_toolbar_fcs_lb;
- GtkWidget *airpcap_toolbar_decryption;
- GtkWidget *airpcap_toolbar_decryption_lb;
- GtkWidget *airpcap_toolbar_keys_button;
-
- gchar *if_label_text;
-
- airpcap_toolbar_crc_filter_combo = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
- airpcap_toolbar_label = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
- toolbar_channel_cb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
- airpcap_toolbar_channel_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
- airpcap_toolbar_channel_offset = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
- airpcap_toolbar_channel_offset_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
- airpcap_toolbar_fcs = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
- airpcap_toolbar_fcs_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
- airpcap_toolbar_button = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_ADVANCED_KEY);
- airpcap_toolbar_decryption = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
- airpcap_toolbar_decryption_lb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY);
- airpcap_toolbar_keys_button = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_KEY_MANAGEMENT_KEY);
-
- /* The current interface is an airpcap interface */
- if (if_info != NULL)
- {
- gtk_widget_set_sensitive(wireless_tb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_label,TRUE);
- gtk_widget_set_sensitive(toolbar_channel_cb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_button,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_keys_button,TRUE);
- airpcap_validation_type_combo_set_by_type(airpcap_toolbar_crc_filter_combo, if_info->CrcValidationOn);
-
- /*decription check box*/
- g_signal_handlers_block_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, wireless_tb);
- if (if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
- g_signal_handlers_unblock_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, wireless_tb);
-
- if_label_text = g_strdup_printf("Current Wireless Interface: #%s", airpcap_get_if_string_number(if_info));
- gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
- g_free(if_label_text);
-
- change_airpcap_settings = FALSE;
- if (if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0) {
- guint i = 0;
-
- for (; i<if_info->numSupportedChannels; i++) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(toolbar_channel_cb), ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
- }
- }
-
- airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),if_info);
- airpcap_update_channel_offset_combo(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset, TRUE);
- change_airpcap_settings = TRUE;
- }
- else
- {
- gtk_widget_set_sensitive(wireless_tb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
- gtk_widget_set_sensitive(toolbar_channel_cb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,FALSE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,TRUE);
- gtk_widget_set_sensitive(airpcap_toolbar_keys_button,TRUE);
- change_airpcap_settings = FALSE;
- }
-}
-
-#if 0
-/* Returs TRUE if the WEP key is valid, false otherwise */
-gboolean
-wep_key_is_valid(char* key)
-{
- size_t strsize, i;
-
- if (key == NULL)
- return FALSE;
-
- strsize = strlen(key);
-
- if ( (strsize > WEP_KEY_MAX_CHAR_SIZE) || (strsize < 2))
- {
- return FALSE;
- }
- if ((strsize % 2) != 0)
- {
- return FALSE;
- }
- for(i = 0; i < strsize; i++)
- {
- if (!g_ascii_isxdigit(key[i]))
- {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-#endif
-
-/*
- * Callback used by the load_wlan_keys() routine in order to read a WEP decryption key
- */
-static guint
-get_wep_key(pref_t *pref, gpointer ud)
-{
- gchar *key_string = NULL;
- guint8 key_type = DOT11DECRYPT_KEY_TYPE_WEP;
- keys_cb_data_t* user_data;
- uat_t *uat;
- guint i;
- char* err = NULL;
- uat_wep_key_record_t* wep_keys;
- decryption_key_t* new_key;
-
- /* Retrieve user data info */
- user_data = (keys_cb_data_t*)ud;
-
- if (g_ascii_strcasecmp(prefs_get_name(pref), "wep_key_table") == 0 && prefs_get_type(pref) == PREF_UAT)
- {
- uat = prefs_get_uat_value(pref);
- /* This is just a sanity check. UAT should be loaded */
- if (!uat->loaded)
- {
- if (!uat_load(uat, &err))
- {
- /* XXX - report the error */
- g_free(err);
- return 1;
- }
- }
-
- for (i = 0, wep_keys = (uat_wep_key_record_t*)*uat->user_ptr; i < *uat->nrows_p; i++, wep_keys++)
- {
- /* strip out key type if present */
- if (g_ascii_strncasecmp(wep_keys->string, STRING_KEY_TYPE_WEP ":", 4) == 0) {
- key_type = DOT11DECRYPT_KEY_TYPE_WEP;
- key_string = (gchar*)wep_keys->string+4;
- }
- else if (g_ascii_strncasecmp(wep_keys->string, STRING_KEY_TYPE_WPA_PWD ":", 8) == 0) {
- key_string = (gchar*)wep_keys->string+8;
- key_type = DOT11DECRYPT_KEY_TYPE_WPA_PWD;
- }
- else if (g_ascii_strncasecmp(wep_keys->string, STRING_KEY_TYPE_WPA_PSK ":", 8) == 0) {
- key_string = (gchar*)wep_keys->string+8;
- key_type = DOT11DECRYPT_KEY_TYPE_WPA_PSK;
- }
- else {
- key_type = wep_keys->key;
- key_string = (gchar*)wep_keys->string;
- }
-
- /* Here we have the string describing the key... */
- new_key = parse_key_string(key_string, key_type);
-
- if (new_key != NULL)
- {
- /* Key is added only if not null ... */
- user_data->list = g_list_append(user_data->list,new_key);
- user_data->number_of_keys++;
- user_data->current_index++;
- }
- }
- }
- return 0;
-}
-
-/* Callback used by the save_wlan_keys() routine in order to write a decryption key */
-static guint
-set_wep_key(pref_t *pref, gpointer ud _U_)
-{
- keys_cb_data_t* user_data;
- uat_t *uat;
- gint i;
- char* err = NULL;
- uat_wep_key_record_t uat_key;
-
- decryption_key_t* new_key;
-
- /* Retrieve user data info */
- user_data = (keys_cb_data_t*)ud;
-
- if (g_ascii_strcasecmp(prefs_get_name(pref), "wep_key_table") == 0 && prefs_get_type(pref) == PREF_UAT)
- {
- uat = prefs_get_uat_value(pref);
- if (!uat->loaded)
- {
- /* UAT will only be loaded if previous keys exist, so it may need
- to be loaded now */
- if (!uat_load(uat, &err))
- {
- /* XXX - report the error */
- g_free(err);
- return 1;
- }
- uat->loaded = 1;
- }
- /* Free the old records */
- uat_clear(uat);
-
- for (i = 0; i < user_data->number_of_keys; i++)
- {
- new_key = (decryption_key_t*)g_list_nth_data(user_data->list,i);
-
- uat_key.string = get_key_string(new_key);
- uat_key.key = new_key->type;
- uat_add_record(uat, &uat_key, TRUE);
- }
-
- if (!uat_save(uat, &err))
- {
- /* XXX - report the error */
- g_free(err);
- return 1;
- }
- }
-
- return 0;
-}
-
-/*
- * This function will tell the airpcap driver the key list to use
- * This will be stored into the registry...
- */
-static gboolean
-write_wlan_driver_wep_keys_to_registry(GList* key_list)
-{
- guint i,j,k,n,y;
- GString *new_key;
- gchar s[3];
- PAirpcapKeysCollection KeysCollection;
- guint KeysCollectionSize;
- guint8 KeyByte;
- guint keys_in_list = 0;
- decryption_key_t* key_item = NULL;
- airpcap_if_info_t* fake_info_if = NULL;
-
- /* Create the fake_info_if from the first adapter of the list */
- fake_info_if = airpcap_driver_fake_if_info_new();
-
- if (fake_info_if == NULL)
- return FALSE;
-
- /*
- * XXX - When WPA will be supported, change this to: keys_in_list = g_list_length(key_list);
- * but right now we will have to count only the WEP keys (or we will have a malloc-mess :-) )
- */
- n = g_list_length(key_list);
- for(k = 0; k < n; k++ )
- if (((decryption_key_t*)g_list_nth_data(key_list,k))->type == DOT11DECRYPT_KEY_TYPE_WEP)
- keys_in_list++;
-
- /*
- * Calculate the size of the keys collection
- */
- KeysCollectionSize = (guint)AirpcapKeysCollectionSize(keys_in_list);
-
- /*
- * Allocate the collection
- */
- KeysCollection = (PAirpcapKeysCollection)g_malloc(KeysCollectionSize);
- if (!KeysCollection)
- {
- return FALSE;
- }
-
- /*
- * Populate the key collection
- */
- KeysCollection->nKeys = keys_in_list;
-
- /*
- * XXX - If we have, let's say, six keys, the first three are WEP, then two are WPA, and the
- * last is WEP, we have to scroll the whole list (n) but increment the array counter only
- * when a WEP key is found (y) .. When WPA will be supported by the driver, I'll have to change
- * this
- */
- y = 0; /* Current position in the key list */
-
- for(i = 0; i < n; i++)
- {
- /* Retrieve the Item corresponding to the i-th key */
- key_item = (decryption_key_t*)g_list_nth_data(key_list,i);
-
- /*
- * XXX - The DOT11DECRYPT_KEY_TYPE_WEP is the only supported right now!
- * We will have to modify the AirpcapKey structure in order to
- * support the other two types! What happens now, is that simply the
- * not supported keys will just be discarded (they will be saved in Wireshark though)
- */
- if (key_item->type == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- KeysCollection->Keys[y].KeyType = DOT11DECRYPT_KEY_TYPE_WEP;
-
- new_key = g_string_new(key_item->key->str);
-
- KeysCollection->Keys[y].KeyLen = (guint) new_key->len / 2;
- memset(&KeysCollection->Keys[y].KeyData, 0, sizeof(KeysCollection->Keys[y].KeyData));
-
- for(j = 0 ; j < new_key->len; j += 2)
- {
- s[0] = new_key->str[j];
- s[1] = new_key->str[j+1];
- s[2] = '\0';
- KeyByte = (guint8)strtol(s, NULL, 16);
- KeysCollection->Keys[y].KeyData[j / 2] = KeyByte;
- }
- /* XXX - Change when WPA will be supported!!! */
- y++;
- g_string_free(new_key,TRUE);
- }
- else if (key_item->type == DOT11DECRYPT_KEY_TYPE_WPA_PWD)
- {
- /* XXX - The driver cannot deal with this kind of key yet... */
- }
- else if (key_item->type == DOT11DECRYPT_KEY_TYPE_WPA_PMK)
- {
- /* XXX - The driver cannot deal with this kind of key yet... */
- }
- }
-
- /*
- * Free the old adapter key collection!
- */
- g_free(fake_info_if->keysCollection);
-
- /*
- * Set this collection ad the new one
- */
- fake_info_if->keysCollection = KeysCollection;
- fake_info_if->keysCollectionSize = KeysCollectionSize;
-
- /*
- * Configuration must be saved
- */
- fake_info_if->saved = FALSE;
-
- /*
- * Write down the changes to the registry
- */
- airpcap_save_driver_if_configuration(fake_info_if);
-
- airpcap_if_info_free(fake_info_if);
-
- return TRUE;
-}
-
-/*
- * Function used to read the Decryption Keys from the preferences and store them
- * properly into the airpcap adapter.
- */
-static gboolean
-load_wlan_driver_wep_keys(void)
-{
- keys_cb_data_t* user_data;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Allocate a structure used to keep infos between the callbacks */
- user_data = (keys_cb_data_t*)g_malloc(sizeof(keys_cb_data_t));
-
- /* Fill the structure */
- user_data->list = NULL;
- user_data->current_index = 0;
- user_data->number_of_keys= 0; /* Still unknown */
-
- /* Run the callback on each 802.11 preference */
- prefs_pref_foreach(wlan_prefs, get_wep_key, (gpointer)user_data);
-
- /* Now the key list should be filled */
-
- /*
- * Signal that we've changed things, and run the 802.11 dissector's
- * callback
- */
- wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
-
- prefs_apply(wlan_prefs);
-
- write_wlan_driver_wep_keys_to_registry(user_data->list);
-
- /* FREE MEMORY */
- /* free the WEP key string */
- g_list_foreach(user_data->list, (GFunc)free_key_string, NULL);
-
- /* free the (empty) list */
- g_list_free(user_data->list);
-
- /* free the user_data structure */
- g_free(user_data);
-
- /* airpcap_if_info_free(fake_info_if); */
-
- return TRUE;
-}
-
-/*
- * This function will tell the airpcap driver the key list to use
- * This will be stored into the registry...
- */
-static gboolean
-write_wlan_wep_keys_to_registry(airpcap_if_info_t* info_if, GList* key_list)
-{
- guint i,j;
- GString *new_key;
- gchar s[3];
- PAirpcapKeysCollection KeysCollection;
- guint KeysCollectionSize;
- guint8 KeyByte;
- guint keys_in_list = 0;
- decryption_key_t* key_item = NULL;
-
- keys_in_list = g_list_length(key_list);
-
- /*
- * Calculate the size of the keys collection
- */
- KeysCollectionSize = (guint)AirpcapKeysCollectionSize(keys_in_list);
-
- /*
- * Allocate the collection
- */
- KeysCollection = (PAirpcapKeysCollection)g_malloc(KeysCollectionSize);
- if (!KeysCollection)
- {
- return FALSE;
- }
-
- /*
- * Populate the key collection
- */
- KeysCollection->nKeys = keys_in_list;
-
- for(i = 0; i < keys_in_list; i++)
- {
- KeysCollection->Keys[i].KeyType = DOT11DECRYPT_KEY_TYPE_WEP;
-
- /* Retrieve the Item corresponding to the i-th key */
- key_item = (decryption_key_t*)g_list_nth_data(key_list,i);
- new_key = g_string_new(key_item->key->str);
-
- KeysCollection->Keys[i].KeyLen = (guint) new_key->len / 2;
- memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
-
- for(j = 0 ; j < new_key->len; j += 2)
- {
- s[0] = new_key->str[j];
- s[1] = new_key->str[j+1];
- s[2] = '\0';
- KeyByte = (guint8)strtol(s, NULL, 16);
- KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
- }
-
- g_string_free(new_key,TRUE);
-
- }
- /*
- * Free the old adapter key collection!
- */
- g_free(info_if->keysCollection);
-
- /*
- * Set this collection ad the new one
- */
- info_if->keysCollection = KeysCollection;
- info_if->keysCollectionSize = KeysCollectionSize;
-
- /*
- * Configuration must be saved
- */
- info_if->saved = FALSE;
-
- /*
- * Write down the changes to the registry
- */
- airpcap_save_selected_if_configuration(info_if);
-
- return TRUE;
-}
-
-/*
- * Returns the ASCII string of a key given the key bytes
- */
-static gchar*
-airpcap_get_key_string(AirpcapKey key)
-{
- unsigned int j = 0;
- gchar *dst,*src;
-
- dst = NULL;
- src = NULL;
-
- if (key.KeyType == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- if (key.KeyLen != 0)
- {
- /* Allocate the string used to store the ASCII representation of the WEP key */
- dst = (gchar*)g_malloc(sizeof(gchar)*WEP_KEY_MAX_CHAR_SIZE + 1);
- /* Make sure that the first char is '\0' in order to make g_strlcat() work */
- dst[0]='\0';
-
- for(j = 0; j < key.KeyLen; j++)
- {
- src = g_strdup_printf("%.2x", key.KeyData[j]);
- /*
- * XXX - use g_strconcat() or GStrings instead ???
- */
- g_strlcat(dst, src, WEP_KEY_MAX_CHAR_SIZE+1);
- }
- g_free(src);
- }
- }
- else if (key.KeyType == DOT11DECRYPT_KEY_TYPE_WPA_PWD)
- {
- /* XXX - Add code here */
- }
- else if (key.KeyType == DOT11DECRYPT_KEY_TYPE_WPA_PMK)
- {
- /* XXX - Add code here */
- }
- else
- {
- /* XXX - Add code here */
- }
-
- return dst;
-}
-
-/*
- * Function used to save to the preference file the Decryption Keys.
- */
-static int
-save_wlan_driver_wep_keys(void)
-{
- GList* key_list = NULL;
- char* tmp_key = NULL;
- guint keys_in_list,i;
- keys_cb_data_t* user_data;
- airpcap_if_info_t* fake_info_if = NULL;
-
- /* Create the fake_info_if from the first adapter of the list */
- fake_info_if = airpcap_driver_fake_if_info_new();
-
- if (fake_info_if == NULL)
- return 0;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Allocate a structure used to keep infos between the callbacks */
- user_data = (keys_cb_data_t*)g_malloc(sizeof(keys_cb_data_t));
-
- /* Number of keys in key list */
- if (fake_info_if->keysCollectionSize != 0)
- keys_in_list = AirpcapKeysCollectionSizeToKeyCount(fake_info_if->keysCollectionSize);
- else
- keys_in_list = 0;
-
- for(i=0; i<keys_in_list; i++)
- {
- /* Only if it is a WEP key... */
- if (fake_info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- tmp_key = airpcap_get_key_string(fake_info_if->keysCollection->Keys[i]);
- key_list = g_list_append(key_list,g_strdup(tmp_key));
- g_free(tmp_key);
- }
- }
-
- /* Now we know the exact number of WEP keys in the list, so store it ... */
- keys_in_list = g_list_length(key_list);
-
- /* Fill the structure */
- user_data->list = key_list;
- user_data->current_index = 0;
- user_data->number_of_keys= keys_in_list;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Run the callback on each 802.11 preference */
- prefs_pref_foreach(wlan_prefs, set_wep_key, (gpointer)user_data);
-
- /* Signal that we've changed things, and run the 802.11 dissector's
- * callback */
- wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
-
- /* Apply changes for the specified preference */
- prefs_apply(wlan_prefs);
-
- /* FREE MEMORY */
- /* free the WEP key string */
- for(i=0;i<g_list_length(user_data->list);i++)
- {
- g_free(g_list_nth(user_data->list,i)->data);
- }
-
- /* free the (empty) list */
- g_list_free(user_data->list);
-
- /* free the user_data structure */
- g_free(user_data);
-
- airpcap_if_info_free(fake_info_if);
-
- return keys_in_list;
-}
-
-/*
- * Function used to save to the preference file the Decryption Keys.
- */
-static int
-save_wlan_wireshark_wep_keys(GList* key_ls)
-{
- GList* key_list = NULL;
- guint keys_in_list,i;
- keys_cb_data_t* user_data;
- decryption_key_t* tmp_dk;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Allocate a structure used to keep infos between the callbacks */
- user_data = (keys_cb_data_t*)g_malloc(sizeof(keys_cb_data_t));
-
- keys_in_list = g_list_length(key_ls);
-
- key_list = key_ls;
-
- /* Fill the structure */
- user_data->list = key_list;
- user_data->current_index = 0;
- user_data->number_of_keys= keys_in_list;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Run the callback on each 802.11 preference */
- prefs_pref_foreach(wlan_prefs, set_wep_key, (gpointer)user_data);
-
- /* Signal that we've changed things, and run the 802.11 dissector's
- * callback */
- wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
-
- /* Apply changes for the specified preference */
- prefs_apply(wlan_prefs);
-
- /* FREE MEMORY */
- /* free the WEP key string */
- for(i=0;i<g_list_length(user_data->list);i++)
- {
- tmp_dk = (decryption_key_t*)g_list_nth(user_data->list,i)->data;
- g_string_free(tmp_dk->key,TRUE);
- if (tmp_dk->ssid != NULL) g_byte_array_free(tmp_dk->ssid,TRUE);
- }
-
- /* free the (empty) list */
- g_list_free(user_data->list);
-
- /* free the user_data structure */
- g_free(user_data);
-
- return keys_in_list;
-}
-
-/*
- * Returns the default airpcap interface of a list, NULL if list is empty
- */
-airpcap_if_info_t*
-airpcap_get_default_if(GList* airpcap_if_list_p)
-{
- airpcap_if_info_t* if_info = NULL;
-
- if ((prefs.capture_device != NULL) && (*prefs.capture_device != '\0'))
- {
- if_info = get_airpcap_if_from_name(airpcap_if_list_p,
- get_if_name(prefs.capture_device));
- }
- return if_info;
-}
-
-/*
- * DECRYPTION KEYS FUNCTIONS
- */
-#if 0
-/*
- * This function is used for DEBUG POURPOSES ONLY!!!
- */
-void
-print_key_list(GList* key_list)
-{
- gint n,i;
- decryption_key_t* tmp;
- gchar* ssid;
-
- if (key_list == NULL)
- {
- g_print("\n\n******* KEY LIST NULL *******\n\n");
- return;
- }
-
- n = g_list_length(key_list);
-
- g_print("\n\n********* KEY LIST **********\n\n");
-
- g_print("NUMBER OF KEYS IN LIST : %d\n\n",n);
-
- for(i =0; i < n; i++)
- {
- g_print("[%d] :\n",i+1);
- tmp = (decryption_key_t*)(g_list_nth_data(key_list,i));
- g_print("KEY : %s\n",tmp->key->str);
-
- g_print("BITS: %d\n",tmp->bits);
-
- if (tmp->type == DOT11DECRYPT_KEY_TYPE_WEP)
- g_print("TYPE: %s\n",AIRPCAP_WEP_KEY_STRING);
- else if (tmp->type == DOT11DECRYPT_KEY_TYPE_WPA_PWD)
- g_print("TYPE: %s\n",AIRPCAP_WPA_PWD_KEY_STRING);
- else if (tmp->type == DOT11DECRYPT_KEY_TYPE_WPA_PMK)
- g_print("TYPE: %s\n",AIRPCAP_WPA_BIN_KEY_STRING);
- else
- g_print("TYPE: %s\n","???");
-
- ssid = format_text(NULL, (guchar *)tmp->ssid->data, tmp->ssid->len);
- g_print("SSID: %s\n",(tmp->ssid != NULL) ? ssid : "---");
- g_print("\n");
- wmem_free(NULL, ssid);
- }
-
- g_print("\n*****************************\n\n");
-}
-#endif
-
-/*
- * Retrieves a GList of decryption_key_t structures containing infos about the
- * keys for the given adapter... returns NULL if no keys are found.
- */
-GList *
-get_airpcap_device_keys(airpcap_if_info_t* info_if)
-{
- /* tmp vars */
- char* tmp_key = NULL;
- guint i,keys_in_list = 0;
-
- /* real vars*/
- decryption_key_t *new_key = NULL;
- GList *key_list = NULL;
-
- /* Number of keys in key list */
- if (info_if->keysCollectionSize != 0)
- keys_in_list = AirpcapKeysCollectionSizeToKeyCount(info_if->keysCollectionSize);
- else
- keys_in_list = 0;
-
- for(i=0; i<keys_in_list; i++)
- {
- /* Different things to do depending on the key type */
- if (info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- /* allocate memory for the new key item */
- new_key = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
-
- /* fill the fields */
- /* KEY */
- tmp_key = airpcap_get_key_string(info_if->keysCollection->Keys[i]);
- new_key->key = g_string_new(tmp_key);
- g_free(tmp_key);
-
- /* BITS */
- new_key->bits = (guint) new_key->key->len *4; /* every char is 4 bits in WEP keys (it is an hexadecimal number) */
-
- /* SSID not used in WEP keys */
- new_key->ssid = NULL;
-
- /* TYPE (WEP in this case) */
- new_key->type = info_if->keysCollection->Keys[i].KeyType;
-
- /* Append the new element in the list */
- key_list = g_list_append(key_list,(gpointer)new_key);
- }
- else if (info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WPA_PWD)
- {
- /* XXX - Not supported yet */
- }
- else if (info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WPA_PMK)
- {
- /* XXX - Not supported yet */
- }
- }
-
- return key_list;
-}
-
-/*
- * Retrieves a GList of decryption_key_t structures containing infos about the
- * keys for the global AirPcap driver... returns NULL if no keys are found.
- */
-GList *
-get_airpcap_driver_keys(void)
-{
- /* tmp vars */
- char *tmp_key = NULL;
- guint i,keys_in_list = 0;
-
- /* real vars*/
- decryption_key_t *new_key = NULL;
- GList *key_list = NULL;
-
- /*
- * To read the drivers general settings we need to create and use one airpcap adapter...
- * The only way to do that is to instantiate a fake adapter, and then close it and delete it.
- */
- airpcap_if_info_t* fake_info_if = NULL;
-
- /* Create the fake_info_if from the first adapter of the list */
- fake_info_if = airpcap_driver_fake_if_info_new();
-
- if (fake_info_if == NULL)
- return NULL;
-
- /* Number of keys in key list */
- if (fake_info_if->keysCollectionSize != 0)
- keys_in_list = AirpcapKeysCollectionSizeToKeyCount(fake_info_if->keysCollectionSize);
- else
- keys_in_list = 0;
-
- for(i=0; i<keys_in_list; i++)
- {
- /* Different things to do depending on the key type */
- if (fake_info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- /* allocate memory for the new key item */
- new_key = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
-
- /* fill the fields */
- /* KEY */
- tmp_key = airpcap_get_key_string(fake_info_if->keysCollection->Keys[i]);
- new_key->key = g_string_new(tmp_key);
- g_free(tmp_key);
-
- /* BITS */
- new_key->bits = (guint) new_key->key->len *4; /* every char is 4 bits in WEP keys (it is an hexadecimal number) */
-
- /* SSID not used in WEP keys */
- new_key->ssid = NULL;
-
- /* TYPE (WEP in this case) */
- new_key->type = fake_info_if->keysCollection->Keys[i].KeyType;
-
- /* Append the new element in the list */
- key_list = g_list_append(key_list,(gpointer)new_key);
- }
- else if (fake_info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WPA_PWD)
- {
- /* XXX - Not supported yet */
- }
- else if (fake_info_if->keysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WPA_PMK)
- {
- /* XXX - Not supported yet */
- }
- }
-
- airpcap_if_info_free(fake_info_if);
-
- return key_list;
-}
-
-/*
- * Returns the list of the decryption keys specified for wireshark, NULL if
- * no key is found
- */
-GList *
-get_wireshark_keys(void)
-{
- keys_cb_data_t *wep_user_data = NULL;
-
- GList *final_list = NULL;
- GList *wep_final_list = NULL;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Allocate a structure used to keep infos between the callbacks */
- wep_user_data = (keys_cb_data_t*)g_malloc(sizeof(keys_cb_data_t));
-
- /* Fill the structure */
- wep_user_data->list = NULL;
- wep_user_data->current_index = 0;
- wep_user_data->number_of_keys= 0; /* Still unknown */
-
- /* Run the callback on each 802.11 preference */
- /* XXX - Right now, only WEP keys will be loaded */
- prefs_pref_foreach(wlan_prefs, get_wep_key, (gpointer)wep_user_data);
-
- /* Copy the list field in the user data structure pointer into the final_list */
- wep_final_list = wep_user_data->list;
-
- /* XXX - Merge the three lists!!!!! */
- final_list = wep_final_list;
-
- /* free the wep_user_data structure */
- g_free(wep_user_data);
-
- return final_list;
-}
-
-
-static guint
-test_if_on(pref_t *pref, gpointer ud)
-{
- gboolean *is_on;
-
- /* Retrieve user data info */
- is_on = (gboolean*)ud;
-
- if (g_ascii_strncasecmp(prefs_get_name(pref), "enable_decryption", 17) == 0 && prefs_get_gui_type(pref) == PREF_BOOL)
- {
- *is_on = prefs_get_bool_value(pref, pref_current);
-
- return 1;
- }
- return 0;
-}
-
-/*
- * Merges two lists of keys and return a newly created GList. If a key is
- * found multiple times, it will just appear once!
- * list1 and list 2 pointer will have to be freed manually if needed!!!
- * If the total number of keys exceeeds the maximum number allowed,
- * exceeding keys will be discarded...
- */
-GList *
-merge_key_list(GList* list1, GList* list2)
-{
- guint n1=0,n2=0;
- guint i;
- decryption_key_t *dk1=NULL,
- *dk2=NULL,
- *new_dk=NULL;
-
- GList* merged_list = NULL;
-
- if ( (list1 == NULL) && (list2 == NULL) )
- return NULL;
-
- if (list1 == NULL)
- {
- n2 = g_list_length(list2);
-
- for(i=0;i<n2;i++)
- {
- new_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
- dk2 = (decryption_key_t *)g_list_nth_data(list2,i);
-
- new_dk->bits = dk2->bits;
- new_dk->type = dk2->type;
- new_dk->key = g_string_new(dk2->key->str);
- new_dk->ssid = byte_array_dup(dk2->ssid);
-
- /* Check the total length of the merged list */
- if (g_list_length(merged_list) < MAX_ENCRYPTION_KEYS)
- merged_list = g_list_append(merged_list,(gpointer)new_dk);
- }
- }
- else if (list2 == NULL)
- {
- n1 = g_list_length(list1);
-
- for(i=0;i<n1;i++)
- {
- new_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
- dk1 = (decryption_key_t*)g_list_nth_data(list1,i);
-
- new_dk->bits = dk1->bits;
- new_dk->type = dk1->type;
- new_dk->key = g_string_new(dk1->key->str);
- new_dk->ssid = byte_array_dup(dk1->ssid);
-
- /* Check the total length of the merged list */
- if (g_list_length(merged_list) < MAX_ENCRYPTION_KEYS)
- merged_list = g_list_append(merged_list,(gpointer)new_dk);
- }
- }
- else
- {
- n1 = g_list_length(list1);
- n2 = g_list_length(list2);
-
- /* Copy the whole list1 into merged_list */
- for(i=0;i<n1;i++)
- {
- new_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
- dk1 = (decryption_key_t *)g_list_nth_data(list1,i);
-
- new_dk->bits = dk1->bits;
- new_dk->type = dk1->type;
- new_dk->key = g_string_new(dk1->key->str);
- new_dk->ssid = byte_array_dup(dk1->ssid);
-
- /* Check the total length of the merged list */
- if (g_list_length(merged_list) < MAX_ENCRYPTION_KEYS)
- merged_list = g_list_append(merged_list,(gpointer)new_dk);
- }
-
- /* Look for keys that are present in list2 but aren't in list1 yet...
- * Add them to merged_list
- */
- for(i=0;i<n2;i++)
- {
- dk2 = (decryption_key_t *)g_list_nth_data(list2,i);
-
- if (!key_is_in_list(dk2,merged_list))
- {
- new_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
-
- new_dk->bits = dk2->bits;
- new_dk->type = dk2->type;
- new_dk->key = g_string_new(dk2->key->str);
- new_dk->ssid = byte_array_dup(dk2->ssid);
-
- /* Check the total length of the merged list */
- if (g_list_length(merged_list) < MAX_ENCRYPTION_KEYS)
- merged_list = g_list_append(merged_list,(gpointer)new_dk);
- }
- }
- }
-
- return merged_list;
-}
-
-/*
- * Use this function to free a key list.
- */
-void
-free_key_list(GList *list)
-{
- guint i,n;
- decryption_key_t *curr_key;
-
- if (list == NULL)
- return;
-
- n = g_list_length(list);
-
- for(i = 0; i < n; i++)
- {
- curr_key = (decryption_key_t*)g_list_nth_data(list,i);
-
- /* Free all the strings */
- if (curr_key->key != NULL)
- g_string_free(curr_key->key, TRUE);
-
- if (curr_key->ssid != NULL)
- g_byte_array_free(curr_key->ssid, TRUE);
-
- /* free the decryption_key_t structure*/
- g_free(curr_key);
- curr_key = NULL;
- }
-
- /* Free the list */
- g_list_free(list);
-
- return;
-}
-
-
-/*
- * If the given key is contained in the list, returns TRUE.
- * Returns FALSE otherwise.
- */
-gboolean
-key_is_in_list(decryption_key_t *dk,GList *list)
-{
- guint i,n;
- decryption_key_t *curr_key = NULL;
- gboolean found = FALSE;
-
- if ( (list == NULL) || (dk == NULL) )
- return FALSE;
-
- n = g_list_length(list);
-
- if (n < 1)
- return FALSE;
-
- for(i = 0; i < n; i++)
- {
- curr_key = (decryption_key_t*)g_list_nth_data(list,i);
- if (keys_are_equals(dk,curr_key))
- found = TRUE;
- }
-
- return found;
-}
-
-/*
- * Returns TRUE if keys are equals, FALSE otherwise
- */
-gboolean
-keys_are_equals(decryption_key_t *k1,decryption_key_t *k2)
-{
-
- if ((k1==NULL) || (k2==NULL))
- return FALSE;
-
- /* XXX - Remove this check when we will have the WPA/WPA2 decryption in the Driver! */
- /** if ( (k1->type == DOT11DECRYPT_KEY_TYPE_WPA_PWD) || (k2->type == DOT11DECRYPT_KEY_TYPE_WPA_PWD) || (k1->type == DOT11DECRYPT_KEY_TYPE_WPA_PMK) || (k2->type == DOT11DECRYPT_KEY_TYPE_WPA_PMK) ) **/
- /** return TRUE; **/
-
- if (g_string_equal(k1->key,k2->key) &&
- (k1->bits == k2->bits) && /* If the previous is TRUE, this must be TRUE as well */
- (k1->type == k2->type))
- {
- /* Check the ssid... if the key type is WEP, the two fields should be NULL */
- if ((k1->ssid == NULL) && (k2->ssid == NULL))
- return TRUE;
-
- /* If they are not null, they must share the same ssid */
- return byte_array_equal(k1->ssid,k2->ssid);
- }
-
- /* Some field is not equal ... */
- return FALSE;
-}
-
-/*
- * Tests if two collection of keys are equal or not, to be considered equals, they have to
- * contain the same keys in the SAME ORDER! (If both lists are NULL, which means empty will
- * return TRUE)
- */
-gboolean
-key_lists_are_equal(GList* list1, GList* list2)
-{
- guint n1 = 0,n2=0;
- /* XXX - Remove */
- guint wep_n1 = 0,wep_n2=0;
- GList *wep_list1 = NULL;
- GList *wep_list2 = NULL;
- /* XXX - END*/
- guint i/*,j*/;
- decryption_key_t *dk1=NULL,*dk2=NULL;
-
- n1 = g_list_length(list1);
- n2 = g_list_length(list2);
-
- /*
- * XXX - START : Retrieve the aublists of WEP keys!!! This is needed only 'till Driver WPA decryption
- * is implemented.
- */
- for(i=0;i<n1;i++)
- {
- dk1=(decryption_key_t*)g_list_nth_data(list1,i);
- if (dk1->type == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- wep_list1 = g_list_append(wep_list1,(gpointer)dk1);
- wep_n1++;
- }
- }
- for(i=0;i<n2;i++)
- {
- dk2=(decryption_key_t*)g_list_nth_data(list2,i);
- if (dk2->type == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- wep_list2 = g_list_append(wep_list2,(gpointer)dk2);
- wep_n2++;
- }
- }
-
- /*
- * XXX - END : Remove from START to END when the WPA/WPA2 decryption will be implemented in
- * the Driver
- */
-
- /*
- * Commented, because in the new AirPcap version all the keys will be saved
- * into the driver, and all the keys for every specific adapter will be
- * removed. This means that this check will always fail... and the user will
- * always be asked what to do... and it doesn't make much sense.
- */
- /* if (n1 != n2) return FALSE; */
- if (wep_n1 != wep_n2) return FALSE;
-
- n2 = wep_n2;
-
- /*for(i=0;i<n1;i++)
- {
- dk1=(decryption_key_t*)g_list_nth_data(list1,i);
- dk2=(decryption_key_t*)g_list_nth_data(list2,i);
-
- if (!g_string_equal(dk1->key,dk2->key)) return FALSE;
- }*/
- for(i=0;i<n2;i++)
- {
- dk2=(decryption_key_t*)g_list_nth_data(wep_list2,i);
- if (!key_is_in_list(dk2,wep_list1)) return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Returns TRUE if the Wireshark decryption is active, false otherwise
- * XXX - Should we just add a routine to packet-ieee80211.c to grab this directly?
- */
-gboolean
-wireshark_decryption_on(void)
-{
- gboolean is_on;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Run the callback on each 802.11 preference */
- prefs_pref_foreach(wlan_prefs, test_if_on, (gpointer)&is_on);
-
- return is_on;
-}
-
-/*
- * Returns TRUE if the AirPcap decryption for the current adapter is active, false otherwise
- */
-gboolean
-airpcap_decryption_on(void)
-{
- gboolean is_on = FALSE;
-
- airpcap_if_info_t* fake_if_info = NULL;
-
- fake_if_info = airpcap_driver_fake_if_info_new();
-
- if (fake_if_info != NULL)
- {
- if (fake_if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
- is_on = TRUE;
- else if (fake_if_info->DecryptionOn == AIRPCAP_DECRYPTION_OFF)
- is_on = FALSE;
- }
-
- airpcap_if_info_free(fake_if_info);
-
- return is_on;
-}
-
-static guint
-set_on_off(pref_t *pref, gpointer ud)
-{
- gboolean *is_on;
-
- /* Retrieve user data info */
- is_on = (gboolean*)ud;
-
- if (g_ascii_strncasecmp(prefs_get_name(pref), "enable_decryption", 17) == 0 && prefs_get_type(pref) == PREF_BOOL)
- {
- prefs_set_bool_value(pref, *is_on, pref_current);
- return 1;
- }
- return 0;
-}
-
-/*
- * Enables decryption for Wireshark if on_off is TRUE, disables it otherwise.
- */
-void
-set_wireshark_decryption(gboolean on_off)
-{
- gboolean is_on;
-
- is_on = on_off;
-
- /* Retrieve the wlan preferences */
- wlan_prefs = prefs_find_module("wlan");
-
- /* Run the callback on each 802.11 preference */
- prefs_pref_foreach(wlan_prefs, set_on_off, (gpointer)&is_on);
-
- /*
- * Signal that we've changed things, and run the 802.11 dissector's
- * callback
- */
- wlan_prefs->prefs_changed_flags |= PREF_EFFECT_DISSECTION;
-
- prefs_apply(wlan_prefs);
-}
-
-/*
- * Enables decryption for all the adapters if on_off is TRUE, disables it otherwise.
- */
-gboolean
-set_airpcap_decryption(gboolean on_off)
-{
- /* We need to directly access the .dll functions here... */
- gchar ebuf[AIRPCAP_ERRBUF_SIZE];
- PAirpcapHandle ad,ad_driver;
-
- gboolean success = TRUE;
-
- gint n = 0;
- gint i = 0;
- airpcap_if_info_t* curr_if = NULL;
- airpcap_if_info_t* fake_if_info = NULL;
-
- fake_if_info = airpcap_driver_fake_if_info_new();
-
- if (fake_if_info == NULL)
- /* We apparently don't have any adapters installed.
- * This isn't a failure, so return TRUE
- */
- return TRUE;
-
- /* Set the driver decryption */
- ad_driver = airpcap_if_open(fake_if_info->name, ebuf);
- if (ad_driver)
- {
- if (on_off)
- airpcap_if_set_driver_decryption_state(ad_driver,AIRPCAP_DECRYPTION_ON);
- else
- airpcap_if_set_driver_decryption_state(ad_driver,AIRPCAP_DECRYPTION_OFF);
-
- airpcap_if_close(ad_driver);
- }
-
- airpcap_if_info_free(fake_if_info);
-
- n = g_list_length(g_airpcap_if_list);
-
- /* Set to FALSE the decryption for all the adapters */
- /* Apply this change to all the adapters !!! */
- for(i = 0; i < n; i++)
- {
- curr_if = (airpcap_if_info_t*)g_list_nth_data(g_airpcap_if_list,i);
-
- if (curr_if != NULL)
- {
- ad = airpcap_if_open(curr_if->name, ebuf);
- if (ad)
- {
- curr_if->DecryptionOn = AIRPCAP_DECRYPTION_OFF;
- airpcap_if_set_decryption_state(ad,curr_if->DecryptionOn);
- /* Save configuration for the curr_if */
- if (!airpcap_if_store_cur_config_as_adapter_default(ad))
- {
- success = FALSE;
- }
- airpcap_if_close(ad);
- }
- }
- }
-
- return success;
-}
-
-
-
-/*
- * Add a key (string) to the given list
- */
-void
-airpcap_add_key_to_list(GtkListStore *key_list_store, gchar* type, gchar* key, gchar* ssid)
-{
- GtkTreeIter iter;
-
- gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
- KL_COL_TYPE, type,
- KL_COL_KEY, key,
- KL_COL_SSID, ssid,
- -1);
-}
-
-/*
- * Fill the list with the keys. BEWARE! At this point, Wireshark and Drivers
- * keys should be EQUALS! But is better to load keys from Wireshark, because
- * the driver is not always present, and maybe that cannot support some keys
- * (i.e. the WPA problem)
- */
-void
-airpcap_fill_key_list(GtkListStore *key_list_store)
-{
- gchar* s = NULL;
- unsigned int i,n;
- airpcap_if_info_t* fake_if_info;
- GList* wireshark_key_list = NULL;
- decryption_key_t* curr_key = NULL;
- GtkTreeIter iter;
-
- fake_if_info = airpcap_driver_fake_if_info_new();
-
- /* We can retrieve the driver's key list (i.e. we have the right .dll)*/
- wireshark_key_list = get_wireshark_keys();
- n = g_list_length(wireshark_key_list);
-
- for(i = 0; i < n; i++)
- {
- curr_key = (decryption_key_t*)g_list_nth_data(wireshark_key_list,i);
-
- if (curr_key->type == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
- KL_COL_TYPE, AIRPCAP_WEP_KEY_STRING,
- KL_COL_KEY, curr_key->key->str,
- KL_COL_SSID, "",
- -1);
- }
- else if (curr_key->type == DOT11DECRYPT_KEY_TYPE_WPA_PWD)
- {
- if (curr_key->ssid != NULL)
- {
- s = format_uri(NULL, curr_key->ssid, ":");
- gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
- KL_COL_TYPE, AIRPCAP_WPA_PWD_KEY_STRING,
- KL_COL_KEY, curr_key->key->str,
- KL_COL_SSID, s,
- -1);
- wmem_free(NULL, s);
- }
- else
- {
- gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
- KL_COL_TYPE, AIRPCAP_WPA_PWD_KEY_STRING,
- KL_COL_KEY, curr_key->key->str,
- KL_COL_SSID, "",
- -1);
- }
- }
- else if (curr_key->type == DOT11DECRYPT_KEY_TYPE_WPA_PMK)
- {
- gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
- KL_COL_TYPE, AIRPCAP_WPA_BIN_KEY_STRING,
- KL_COL_KEY, curr_key->key->str,
- KL_COL_SSID, "",
- -1);
-
- }
- }
-
- airpcap_if_info_free(fake_if_info);
- return;
-}
-
-/*
- * Function used to retrieve the AirpcapValidationType given the string name.
- */
-AirpcapValidationType
-airpcap_get_validation_type(const gchar* name)
-{
- if (!(g_ascii_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_ALL,name)))
- {
- return AIRPCAP_VT_ACCEPT_EVERYTHING;
- }
- else if (!(g_ascii_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRECT,name)))
- {
- return AIRPCAP_VT_ACCEPT_CORRECT_FRAMES;
- }
- else if (!(g_ascii_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT,name)))
- {
- return AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES;
- }
- return AIRPCAP_VT_UNKNOWN;
-}
-
-/*
- * Function used to retrieve the string name given an AirpcapValidationType,
- * or NULL in case of error
- */
-const gchar*
-airpcap_get_validation_name(AirpcapValidationType vt)
-{
- if (vt == AIRPCAP_VT_ACCEPT_EVERYTHING)
- {
- return AIRPCAP_VALIDATION_TYPE_NAME_ALL;
- }
- else if (vt == AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)
- {
- return AIRPCAP_VALIDATION_TYPE_NAME_CORRECT;
- }
- else if (vt == AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES)
- {
- return AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT;
- }
- else if (vt == AIRPCAP_VT_UNKNOWN)
- {
- return AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN;
- }
- return NULL;
-}
-
-/*
- * Return an appropriate combo box entry number for the given an AirpcapValidationType,
- * defaulting to 0
- */
-gint
-airpcap_get_validation_combo_entry(AirpcapValidationType vt)
-{
- switch (vt) {
- case AIRPCAP_VT_ACCEPT_CORRECT_FRAMES:
- return 1;
- break;
- case AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES:
- return 2;
- break;
- default:
- return 0;
- break;
- }
-}
-
-/*
- * Returns the AirpcapLinkType corresponding to the given string name.
- */
-AirpcapLinkType
-airpcap_get_link_type(const gchar* name)
-{
- if (!(g_ascii_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_ONLY,name))) {
- return AIRPCAP_LT_802_11;
- }else if (!(g_ascii_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO,name))) {
- return AIRPCAP_LT_802_11_PLUS_RADIO;
- }else if (!(g_ascii_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI,name))) {
- return AIRPCAP_LT_802_11_PLUS_PPI;
- }else{
- return AIRPCAP_LT_UNKNOWN;
- }
-}
-
-/*
- * Returns the string name corresponding to the given AirpcapLinkType, or
- * NULL in case of error.
- */
-const gchar*
-airpcap_get_link_name(AirpcapLinkType lt)
-{
- if (lt == AIRPCAP_LT_802_11) {
- return AIRPCAP_LINK_TYPE_NAME_802_11_ONLY;
- }else if (lt == AIRPCAP_LT_802_11_PLUS_RADIO) {
- return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO;
- }else if (lt == AIRPCAP_LT_802_11_PLUS_PPI) {
- return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI;
- }else if (lt == AIRPCAP_LT_UNKNOWN) {
- return AIRPCAP_LINK_TYPE_NAME_UNKNOWN;
- }
- return NULL;
-}
-
-/*
- * Sets the entry of the validation combo using the AirpcapValidationType.
- */
-void
-airpcap_validation_type_combo_set_by_type(GtkWidget* c, AirpcapValidationType type)
-{
- gtk_combo_box_set_active(GTK_COMBO_BOX(c), airpcap_get_validation_combo_entry(type));
-}
-
-/*
- * Returns the string corresponding to the given guint (1-14, for channel only)
- */
-gchar*
-airpcap_get_channel_name(guint n)
-{
- return g_strdup_printf("%d",n);
-}
-
-
-/*
- * Set the combo box entry string given a channel frequency
- */
-void
-airpcap_channel_combo_set_by_frequency(GtkWidget* cb, guint chan_freq)
-{
- guint i;
-
- for (i = 0; i < airpcap_if_selected->numSupportedChannels; i++) {
- if (airpcap_if_selected->pSupportedChannels[i].Frequency == chan_freq) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(cb), i);
- break;
- }
- }
-}
-
-/*
- * Change channel of Airpcap Adapter
- */
-static gboolean
-airpcap_update_frequency_and_offset(airpcap_if_info_t* if_info)
-{
- gchar ebuf[AIRPCAP_ERRBUF_SIZE];
- PAirpcapHandle ad;
- gboolean return_value = FALSE;
-
- if (if_info != NULL) {
- ad = airpcap_if_open(if_info->name, ebuf);
-
- if (ad != NULL) {
- return_value = airpcap_if_set_device_channel_ex(ad,if_info->channelInfo);
- airpcap_if_close(ad);
- }
- }
-
- return return_value;
-}
-
-/*
- * Changed callback for the channel combobox - common routine
- */
-static void
-airpcap_channel_changed_common(GtkWidget *channel_cb, gpointer channel_offset_cb, gboolean set)
-{
- gint cur_chan_idx;
-
- if (channel_cb && channel_offset_cb && change_airpcap_settings && airpcap_if_active) {
- cur_chan_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(channel_cb));
- if (cur_chan_idx >= 0 && cur_chan_idx < (gint) airpcap_if_active->numSupportedChannels) {
- if (set) {
- airpcap_if_active->channelInfo.Frequency = airpcap_if_active->pSupportedChannels[cur_chan_idx].Frequency;
- }
- airpcap_update_channel_offset_combo(airpcap_if_active,
- airpcap_if_active->channelInfo.Frequency,
- GTK_WIDGET(channel_offset_cb), set);
- }
- }
-}
-
-/*
- * Changed callback for the channel combobox - set channel and offset
- */
-void
-airpcap_channel_changed_set_cb(GtkWidget *channel_cb, gpointer channel_offset_cb)
-{
- airpcap_channel_changed_common(channel_cb, channel_offset_cb, TRUE);
-}
-
-/*
- * Changed callback for the channel combobox - don't set channel and offset
- */
-void
-airpcap_channel_changed_noset_cb(GtkWidget *channel_cb, gpointer channel_offset_cb)
-{
- airpcap_channel_changed_common(channel_cb, channel_offset_cb, FALSE);
-}
-
-static int
-airpcap_get_selected_channel_offset(GtkWidget *channel_offset_cb) {
- int offset;
- gchar *off_str;
- int retval = 0;
-
-
- if (channel_offset_cb == NULL || !gtk_widget_get_sensitive(channel_offset_cb)) {
- return 0;
- }
-
- off_str = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(channel_offset_cb));
- if (off_str && (g_ascii_strcasecmp("", off_str)))
- {
- if (airpcap_if_selected != NULL)
- {
- if (sscanf(off_str, "%d", &offset) == 1) {
- if (offset >= -1 && offset <= 1) {
- retval = offset;
- }
- }
- }
- }
- g_free(off_str);
- return retval;
-}
-
-/*
- * Changed callback for the channel offset combobox
- */
-void
-airpcap_channel_offset_changed_cb(GtkWidget *channel_offset_cb, gpointer data _U_)
-{
- airpcap_if_selected->channelInfo.ExtChannel = airpcap_get_selected_channel_offset(channel_offset_cb);
- airpcap_if_selected->saved = FALSE;
- change_airpcap_settings = TRUE;
- if (!airpcap_update_frequency_and_offset(airpcap_if_selected)) {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,
- "Unable to set extension channel %d",
- airpcap_if_selected->channelInfo.ExtChannel);
- }
-}
-
-
-/*
- * Update the channel offset of the given combobox according to the given frequency.
- */
-void
-airpcap_update_channel_offset_combo(airpcap_if_info_t* if_info, guint chan_freq, GtkWidget *channel_offset_cb, gboolean set)
-{
- gint current_offset;
- gint new_offset;
- guint i;
- gint active_idx = 0;
- gint idx_count = -1;
-
- if (!if_info || airpcap_if_is_any(if_info) || if_info->pSupportedChannels == NULL || if_info->numSupportedChannels < 1) {
- gtk_widget_set_sensitive(GTK_WIDGET(channel_offset_cb),FALSE);
- gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), -1);
- return;
- }
-
- new_offset = current_offset = if_info->channelInfo.ExtChannel;
-
- /* Clear out the list */
- while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(channel_offset_cb)), NULL) > 0) {
- gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(channel_offset_cb), 0);
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(channel_offset_cb), TRUE);
-
- for (i = 0; i < if_info->numSupportedChannels; i++) {
- if (if_info->pSupportedChannels[i].Frequency == chan_freq) {
-
- /* If we can't be low or high, nudge the offset to 0 */
- if (current_offset == -1 && !(if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)) {
- new_offset = 0;
- } else if (current_offset == 1 && !(if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)) {
- new_offset = 0;
- }
-
- if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_offset_cb), "-1");
- idx_count++;
- if (new_offset == -1) {
- active_idx = idx_count;
- }
- }
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_offset_cb), "0");
- idx_count++;
- if (new_offset == 0) {
- active_idx = idx_count;
- }
- if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_offset_cb), "+1");
- idx_count++;
- if (new_offset == 1) {
- active_idx = idx_count;
- }
- }
- break;
- }
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), active_idx);
-
-
- if (set) {
- change_airpcap_settings = TRUE;
-
- if_info->channelInfo.ExtChannel = new_offset;
- if (!airpcap_update_frequency_and_offset(if_info)) {
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Adapter failed to be set with the following settings: Frequency - %d Extension Channel - %d", if_info->channelInfo.Frequency, if_info->channelInfo.ExtChannel);
- }
- }
-
- if (idx_count < 1) {
- gtk_widget_set_sensitive(channel_offset_cb, FALSE);
- }
-}
-
-/*
- * Returns '1' if this is the "Any" adapter, '0' otherwise
- */
-int
-airpcap_if_is_any(airpcap_if_info_t* if_info)
-{
- if (g_ascii_strcasecmp(if_info->name,AIRPCAP_DEVICE_ANY_EXTRACT_STRING)==0)
- return 1;
- else
- return 0;
-}
-
-/*
- * Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
- */
-void
-airpcap_update_channel_combo(GtkWidget* channel_cb, airpcap_if_info_t* if_info)
-{
- if (!if_info || airpcap_if_is_any(if_info) || !airpcap_if_selected)
- {
- gtk_combo_box_set_active(GTK_COMBO_BOX(channel_cb), -1);
- change_airpcap_settings = FALSE;
- gtk_widget_set_sensitive(GTK_WIDGET(channel_cb),FALSE);
- }
- else
- {
- while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(channel_cb)), NULL) > 0) {
- gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(channel_cb), 0);
- }
-
- if (if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0) {
- guint i;
- for (i = 0; i<(if_info->numSupportedChannels); i++) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_cb), ieee80211_mhz_to_str(airpcap_if_selected->pSupportedChannels[i].Frequency));
- }
- }
-
- airpcap_channel_combo_set_by_frequency(channel_cb, if_info->channelInfo.Frequency);
- change_airpcap_settings = TRUE;
- gtk_widget_set_sensitive(GTK_WIDGET(channel_cb), TRUE);
- }
-}
-
-/*
- * Takes the keys from the GtkList widget, and add them to the interface list
- */
-static void
-airpcap_add_keys_to_driver_from_list(GtkListStore *key_list_store, airpcap_if_info_t *fake_if_info)
-{
- GtkTreePath *path;
- GtkTreeIter iter;
- GtkTreeModel *model = GTK_TREE_MODEL(key_list_store);
-
- /* airpcap stuff */
- guint i, j;
- gchar s[3];
- PAirpcapKeysCollection KeysCollection;
- guint KeysCollectionSize;
- guint8 KeyByte;
-
- guint keys_in_list = 0;
-
- gchar *row_type, *row_key; /* SSID not needed for AirPcap */
- size_t key_len;
-
- if (fake_if_info == NULL)
- return;
-
- keys_in_list = gtk_tree_model_iter_n_children(model, NULL);
-
- /*
- * Calculate the size of the keys collection
- */
- KeysCollectionSize = (guint)AirpcapKeysCollectionSize(keys_in_list);
-
- /*
- * Allocate the collection
- */
- KeysCollection = (PAirpcapKeysCollection)g_malloc(KeysCollectionSize);
-
- /*
- * Populate the key collection
- */
- KeysCollection->nKeys = keys_in_list;
-
- for(i = 0; i < keys_in_list; i++)
- {
- path = gtk_tree_path_new_from_indices(i, -1);
- gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_path_free(path);
- gtk_tree_model_get(model, &iter,
- KL_COL_TYPE, &row_type,
- KL_COL_KEY, &row_key,
- -1);
-
- if (g_ascii_strcasecmp(row_type,AIRPCAP_WEP_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = DOT11DECRYPT_KEY_TYPE_WEP;
- else if (g_ascii_strcasecmp(row_type,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = DOT11DECRYPT_KEY_TYPE_WPA_PWD;
- else if (g_ascii_strcasecmp(row_type,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = DOT11DECRYPT_KEY_TYPE_WPA_PMK;
-
- /* Retrieve the Item corresponding to the i-th key */
- key_len = strlen(row_key);
-
- KeysCollection->Keys[i].KeyLen = (guint) key_len / 2;
- memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
-
- /* Key must be saved in a different way, depending on its type... */
- if (KeysCollection->Keys[i].KeyType == DOT11DECRYPT_KEY_TYPE_WEP)
- {
- for(j = 0 ; j < key_len; j += 2)
- {
- s[0] = row_key[j];
- s[1] = row_key[j+1];
- s[2] = '\0';
- KeyByte = (guint8)strtol(s, NULL, 16);
- KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
- }
- }
- g_free(row_type);
- g_free(row_key);
- }
-
- /*
- * Free the old adapter key collection!
- */
- g_free(fake_if_info->keysCollection);
-
- /*
- * Set this collection ad the new one
- */
- fake_if_info->keysCollection = KeysCollection;
- fake_if_info->keysCollectionSize = KeysCollectionSize;
- return;
-}
-
-/*
- * This function will take the current keys (widget list), specified for the
- * current adapter, and save them as default for ALL the others.
- */
-void
-airpcap_read_and_save_decryption_keys_from_list_store(GtkListStore* key_list_store, airpcap_if_info_t* info_if, GList* if_list)
-{
- GtkTreeIter iter;
- GtkTreeModel *model = GTK_TREE_MODEL(key_list_store);
- gboolean items_left;
- gint if_n = 0;
- gint i = 0;
- airpcap_if_info_t* curr_if = NULL;
- airpcap_if_info_t* fake_info_if = NULL;
- GList* key_list = NULL;
-
- char* tmp_type = NULL;
- char* tmp_key = NULL;
- char* tmp_ssid = NULL;
-
- decryption_key_t* tmp_dk=NULL;
-
- /*
- * Save the keys for Wireshark...
- */
-
- /* Create a list of keys from the list store */
- for (items_left = gtk_tree_model_get_iter_first (model, &iter);
- items_left;
- items_left = gtk_tree_model_iter_next (model, &iter)) {
-
- gtk_tree_model_get(model, &iter,
- KL_COL_TYPE, &tmp_type,
- KL_COL_KEY, &tmp_key,
- KL_COL_SSID, &tmp_ssid,
- -1);
-
- if (g_ascii_strcasecmp(tmp_type, AIRPCAP_WEP_KEY_STRING) == 0)
- {
- tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
- tmp_dk->key = g_string_new(tmp_key);
- tmp_dk->ssid = NULL;
- tmp_dk->type = DOT11DECRYPT_KEY_TYPE_WEP;
- tmp_dk->bits = (guint) tmp_dk->key->len * 4;
- key_list = g_list_append(key_list,tmp_dk);
- }
- else if (g_ascii_strcasecmp(tmp_type, AIRPCAP_WPA_PWD_KEY_STRING) == 0)
- {
- tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
- tmp_dk->key = g_string_new(tmp_key);
- tmp_dk->ssid = g_byte_array_new();
- uri_str_to_bytes(tmp_ssid?tmp_ssid:"", tmp_dk->ssid);
- tmp_dk->type = DOT11DECRYPT_KEY_TYPE_WPA_PWD;
- tmp_dk->bits = 256;
- key_list = g_list_append(key_list,tmp_dk);
- }
- else if (g_ascii_strcasecmp(tmp_type, AIRPCAP_WPA_BIN_KEY_STRING) == 0)
- {
- tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
- tmp_dk->key = g_string_new(tmp_key);
- tmp_dk->ssid = NULL; /* No SSID in this case */
- tmp_dk->type = DOT11DECRYPT_KEY_TYPE_WPA_PMK;
- tmp_dk->bits = 256;
- key_list = g_list_append(key_list,tmp_dk);
- }
- g_free(tmp_type);
- g_free(tmp_ssid);
- }
-
- save_wlan_wireshark_wep_keys(key_list);
- /* The key_list has been freed!!! */
-
- /*
- * Save the key list for driver.
- */
- if ( (if_list == NULL) || (info_if == NULL) ) return;
-
- fake_info_if = airpcap_driver_fake_if_info_new();
-
- airpcap_add_keys_to_driver_from_list(key_list_store,fake_info_if);
- airpcap_save_driver_if_configuration(fake_info_if);
- airpcap_if_info_free(fake_info_if);
-
- if_n = g_list_length(if_list);
-
- /* For all the adapters in the list, empty the key list */
- for(i = 0; i < if_n; i++)
- {
- curr_if = (airpcap_if_info_t*)g_list_nth_data(if_list,i);
-
- if (curr_if != NULL)
- {
- /* XXX - Set an empty collection */
- airpcap_if_clear_decryption_settings(curr_if);
-
- /* Save to registry */
- airpcap_save_selected_if_configuration(curr_if);
- }
- }
-}
-
-/*
- * This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA_BIN) and will set them as default for
- * each adapter. To do this, it will save the keys in the registry...
- * A check will be performed, to make sure that keys found in
- * registry and keys found in Wireshark preferences are the same. If not,
- * the user will be asked to choose if use all keys (merge them),
- * or use Wireshark preferences ones. In the last case, registry keys will
- * be overwritten for all the connected AirPcap adapters.
- * In the first case, adapters will use their own keys, but those
- * keys will not be accessible via Wireshark...
- */
-gboolean
-airpcap_check_decryption_keys(GList* if_list)
-{
- gint if_n = 0;
- gint i = 0;
- gint n_adapters_keys = 0;
- gint n_driver_keys = 0;
- airpcap_if_info_t* curr_if = NULL;
-
- GList* wireshark_key_list;
- GList* driver_key_list;
- GList* curr_adapter_key_list;
-
- gboolean equals = TRUE;
- gboolean adapters_keys_equals=TRUE;
-
- /*
- * If no AirPcap interface is found, return TRUE, so Wireshark
- * will use HIS OWN keys.
- */
- if (if_list == NULL)
- return TRUE;
-
- if_n = g_list_length(if_list);
-
- /* Get Wireshark preferences keys */
- wireshark_key_list = get_wireshark_keys();
-
- /* Retrieve AirPcap driver's keys */
- driver_key_list = get_airpcap_driver_keys();
- n_driver_keys = g_list_length(driver_key_list);
-
- equals &= key_lists_are_equal(wireshark_key_list,driver_key_list);
-
- for(i = 0; i < if_n; i++)
- {
- curr_if = (airpcap_if_info_t*)g_list_nth_data(if_list,i);
- curr_adapter_key_list = get_airpcap_device_keys(curr_if);
- n_adapters_keys += g_list_length(curr_adapter_key_list);
- adapters_keys_equals &= key_lists_are_equal(wireshark_key_list,curr_adapter_key_list);
- }
-
- if (n_adapters_keys != 0) /* If for some reason at least one specific key has been found */
- equals &= adapters_keys_equals; /* */
-
- if (n_driver_keys == 0) /* No keys set in any of the AirPcap adapters... */
- return TRUE; /* Use Wireshark keys and set them ad default for airpcap devices */
-
- return equals;
-}
-
-/*
- * This function will load from the preferences file ALL the
- * keys (WEP, WPA_PWD and WPA_BIN) and will set them as default for
- * each adapter. To do this, it will save the keys in the registry...
- * A check will be performed, to make sure that keys found in
- * registry and keys found in Wireshark preferences are the same. If not,
- * the user will be asked to choose if use all keys (merge them),
- * or use Wireshark preferences ones. In the last case, registry keys will
- * be overwritten for all the connected AirPcap adapters.
- * In the first case, adapters will use their own keys, but those
- * keys will not be accessible via Wireshark...
- */
-void
-airpcap_load_decryption_keys(GList* if_list)
-{
- gint if_n = 0;
- gint i = 0;
-
- if (if_list == NULL) return;
-
- if_n = g_list_length(if_list);
-
- for(i = 0; i < if_n; i++)
- {
- load_wlan_driver_wep_keys();
- }
-}
-
-/*
- * This function will set the gibven GList of decryption_key_t structures
- * as the defoult for both Wireshark and the AirPcap adapters...
- */
-void
-airpcap_save_decryption_keys(GList* key_list, GList* adapters_list)
-{
- gint if_n = 0;
- gint i = 0;
- airpcap_if_info_t* curr_if = NULL;
- GList* empty_key_list = NULL;
-
- if ( (key_list == NULL) || (adapters_list == NULL)) return;
-
- if_n = g_list_length(adapters_list);
-
- /* Set the driver's global list of keys. */
- write_wlan_driver_wep_keys_to_registry(key_list);
-
- /* Empty the key list for each interface */
- for(i = 0; i < if_n; i++)
- {
- curr_if = (airpcap_if_info_t*)g_list_nth_data(adapters_list,i);
- write_wlan_wep_keys_to_registry(curr_if,empty_key_list);
- }
-
- /*
- * This will set the keys of the current adapter as Wireshark default...
- * Now all the adapters have the same keys, so curr_if is ok as any other...
- */
- save_wlan_wireshark_wep_keys(key_list);
-}
-
-/*
- * This function is used to enable/disable the toolbar widgets
- * depending on the type of interface selected... Not the whole
- * toolbar must be grayed/enabled ... Only some widgets...
- */
-void
-airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en)
-{
- GtkWidget *toolbar_tb,
- *if_description_lb,
- *toolbar_channel_cb,
- *channel_lb,
- *channel_offset_cb,
- *channel_offset_lb,
- *fcs_cb,
- *fcs_lb,
- *advanced_bt;
-
- if (w == NULL)
- return;
-
- toolbar_tb = w;
-
- if_description_lb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
- channel_lb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
- toolbar_channel_cb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
- channel_offset_cb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
- channel_offset_lb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
- fcs_lb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
- fcs_cb = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
- advanced_bt = (GtkWidget *)g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_ADVANCED_KEY);
-
-
- if (if_description_lb != NULL)
- gtk_widget_set_sensitive(if_description_lb,en);
- if (channel_lb != NULL)
- gtk_widget_set_sensitive(channel_lb,en);
- if (toolbar_channel_cb != NULL)
- gtk_widget_set_sensitive(toolbar_channel_cb,en);
- if (channel_offset_cb != NULL)
- gtk_widget_set_sensitive(channel_offset_cb,en);
- if (channel_offset_lb != NULL)
- gtk_widget_set_sensitive(channel_offset_lb,en);
- if (fcs_lb != NULL)
- gtk_widget_set_sensitive(fcs_lb,en);
- if (fcs_cb != NULL)
- gtk_widget_set_sensitive(fcs_cb,en);
- if (advanced_bt != NULL)
- gtk_widget_set_sensitive(advanced_bt,en);
-
- return;
-}
-
-/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
- *
- * Local variables:
- * c-basic-offset: 4
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * vi: set shiftwidth=4 tabstop=8 expandtab:
- * :indentSize=4:tabSize=8:noTabs=true:
- */
diff --git a/ui/gtk/airpcap_gui_utils.h b/ui/gtk/airpcap_gui_utils.h
deleted file mode 100644
index d5cd0a0632..0000000000
--- a/ui/gtk/airpcap_gui_utils.h
+++ /dev/null
@@ -1,305 +0,0 @@
-/* airpcap_utils.h
- * Declarations of utility routines for the "Airpcap" dialog widgets
- *
- * Giorgio Tino <giorgio.tino@cacetech.com>
- * Copyright (c) CACE Technologies, LLC 2006
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __AIRPCAP_GUI_UTILS_H__
-#define __AIRPCAP_GUI_UTILS_H__
-
-#define AIRPCAP_VALIDATION_TYPE_NAME_ALL "All Frames"
-#define AIRPCAP_VALIDATION_TYPE_NAME_CORRECT "Valid Frames"
-#define AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT "Invalid Frames"
-#define AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN "Unknown"
-
-#define AIRPCAP_LINK_TYPE_NAME_802_11_ONLY "802.11 Only"
-#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO "802.11 + Radio"
-#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI "802.11 + PPI"
-#define AIRPCAP_LINK_TYPE_NAME_UNKNOWN "Unknown"
-
-#define AIRPCAP_LINK_TYPE_NUM_802_11_ONLY 0
-#define AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_RADIO 1
-#define AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_PPI 2
-
-#define AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK "Wireshark"
-#define AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP "Driver"
-#define AIRPCAP_DECRYPTION_TYPE_STRING_NONE "None"
-
-/* Key list columns */
-enum {
- KL_COL_TYPE,
- KL_COL_KEY,
- KL_COL_SSID,
- KL_NUM_COLS
-};
-
-/* Controls the releay of settings back to the adapter. */
-extern gboolean change_airpcap_settings;
-
-/*
- * set up the airpcap toolbar for the new capture interface
- */
-void
-airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info);
-
-/*
- * Set up the airpcap toolbar for the new capture interface
- */
-void
-airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info);
-
-/*
- * Add a key (string) to the given list
- */
-void
-airpcap_add_key_to_list(GtkListStore *key_list_store, gchar* type, gchar* key, gchar* ssid);
-
-/*
- * Fill the list with the keys
- */
-void
-airpcap_fill_key_list(GtkListStore *key_list_store);
-
-/*
- * Function used to retrieve the AirpcapValidationType given the string name.
- */
-AirpcapValidationType
-airpcap_get_validation_type(const gchar* name);
-
-/*
- * Function used to retrieve the string name given an AirpcapValidationType.
- */
-const gchar*
-airpcap_get_validation_name(AirpcapValidationType vt);
-
-/*
- * Return an appropriate combo box entry number for the given an AirpcapValidationType.
- */
-gint
-airpcap_get_validation_combo_entry(AirpcapValidationType vt);
-
-/*
- * Returns the AirpcapLinkType corresponding to the given string name.
- */
-AirpcapLinkType
-airpcap_get_link_type(const gchar* name);
-
-/*
- * Returns the string name corresponding to the given AirpcapLinkType.
- */
-const gchar*
-airpcap_get_link_name(AirpcapLinkType lt);
-
-/*
- * Sets the entry of the validation combo using the AirpcapValidationType.
- */
-void
-airpcap_validation_type_combo_set_by_type(GtkWidget* c,AirpcapValidationType type);
-
-/*
- * Update channel offset combo box to 'offset'.
- */
-void
-airpcap_update_channel_offset_combo(airpcap_if_info_t* if_info, guint32 ch_freq, GtkWidget *channel_offset_cb, gboolean set);
-
-
-/*
- * Retrieve the guint corresponding to the given string (channel only, handle with care!)
- */
-gchar*
-airpcap_get_channel_name(guint n);
-
-/*
- * Set the combo box entry string given an guint channel number
- */
-void
-airpcap_channel_combo_set_by_frequency(GtkWidget* w,guint channel);
-
-/** Respond to the user changing the channel combo box.
- * Update the active interface channel and update the offset
- * combo box.
- * Requires AirPcap globals.
- *
- * @param channel_cb The channel GtkComboBox
- * @param channel_offset_cb The channel offset GtkComboBox
- */
-void
-airpcap_channel_changed_set_cb(GtkWidget *channel_cb, gpointer channel_offset_cb);
-
-/** Respond to the user changing the channel combo box.
- * Update the offset combo box but not the channel.
- * Requires AirPcap globals.
- *
- * @param channel_cb The channel GtkComboBox
- * @param channel_offset_cb The channel offset GtkComboBox
- */
-void
-airpcap_channel_changed_noset_cb(GtkWidget *channel_cb, gpointer channel_offset_cb);
-
-/** Respond to the user changing the channel offset combo box.
- * Update the active interface channel offset.
- * Requires AirPcap globals.
- *
- * @param channel_offset_cb The channel offset GtkComboBox
- * @param data Unused
- */
-void
-airpcap_channel_offset_changed_cb(GtkWidget *channel_offset_cb, gpointer data);
-
-/*
- * Returns '1' if this is the "Any" adapter, '0' otherwise
- */
-int
-airpcap_if_is_any(airpcap_if_info_t* if_info);
-
-/*
- * Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
- */
-void
-airpcap_update_channel_combo(GtkWidget* channel_cb, airpcap_if_info_t* if_info);
-
-/*
- * This function will take the current keys (widget list), specified for the
- * current adapter, and save them as default for ALL the others.
- */
-void
-airpcap_read_and_save_decryption_keys_from_list_store(GtkListStore* key_list_store, airpcap_if_info_t* info_if, GList* if_list);
-
-/*
- * This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA_BIN) and will set them as default for
- * each adapter. To do this, it will save the keys in the registry...
- */
-void
-airpcap_load_decryption_keys(GList* if_list);
-
-/*
- * This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA_BIN) and will set them as default for
- * each adapter. To do this, it will save the keys in the registry...
- */
-gboolean
-airpcap_check_decryption_keys(GList* if_list);
-
-/*
- * This function will set the gibven GList of decryption_key_t structures
- * as the defoult for both Wireshark and the AirPcap adapters...
- */
-void
-airpcap_save_decryption_keys(GList* key_list, GList* adapters_list);
-
-/*
- * This function is used to enable/disable the toolbar widgets
- * depending on the type of interface selected...
- */
-void
-airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en);
-
-/*
- * Returns the default airpcap interface of a list, NULL if list is empty
- */
-airpcap_if_info_t*
-airpcap_get_default_if(GList* airpcap_if_list);
-
-/*
- * DECRYPTION KEYS FUNCTIONS
- */
-
-/*
- * Retrieves a GList of decryption_key_t structures containing infos about the
- * keys for the given adapter... returns NULL if no keys are found.
- */
-GList*
-get_airpcap_device_keys(airpcap_if_info_t* if_info);
-
-/*
- * Retrieves a GList of decryption_key_t structures containing infos about the
- * keys for the global AirPcap driver... returns NULL if no keys are found.
- */
-GList*
-get_airpcap_driver_keys(void);
-
-/*
- * Returns the list of the decryption keys specified for wireshark, NULL if
- * no key is found
- */
-GList*
-get_wireshark_keys(void);
-
-/*
- * Tests if two collection of keys are equal or not, to be considered equals, they have to
- * contain the same keys in the SAME ORDER! (If both lists are NULL, which means empty will
- * return TRUE)
- */
-gboolean
-key_lists_are_equal(GList* list1, GList* list2);
-
-/*
- * Merges two lists of keys. If a key is found multiple times, it will just appear once!
- */
-GList*
-merge_key_list(GList* list1, GList* list2);
-
-/*
- * If the given key is contained in the list, returns TRUE.
- * Returns FALSE otherwise.
- */
-gboolean
-key_is_in_list(decryption_key_t *dk,GList *list);
-
-/*
- * Returns TRUE if keys are equals, FALSE otherwise
- */
-gboolean
-keys_are_equals(decryption_key_t *k1,decryption_key_t *k2);
-
-/*
- * Use this function to free a key list.
- */
-void
-free_key_list(GList *list);
-
-/*
- * Returns TRUE if the Wireshark decryption is active, FALSE otherwise
- */
-gboolean
-wireshark_decryption_on(void);
-
-/*
- * Returns TRUE if the AirPcap decryption for the current adapter is active, FALSE otherwise
- */
-gboolean
-airpcap_decryption_on(void);
-
-/*
- * Enables decryption for Wireshark if on_off is TRUE, disables it otherwise.
- */
-void
-set_wireshark_decryption(gboolean on_off);
-
-/*
- * Enables decryption for all the adapters if on_off is TRUE, disables it otherwise.
- */
-gboolean
-set_airpcap_decryption(gboolean on_off);
-
-#endif
diff --git a/ui/gtk/bytes_view.c b/ui/gtk/bytes_view.c
deleted file mode 100644
index 86fff12865..0000000000
--- a/ui/gtk/bytes_view.c
+++ /dev/null
@@ -1,1499 +0,0 @@
-/* bytes_view.c
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- */
-
-/* Code based on:
- * xtext, the text widget used by X-Chat. Peter Zelezny <zed@xchat.org>.
- * GtkTextView. Copyright (C) 2000 Red Hat, Inc.
- * GtkHex. Jaka Mocnik <jaka@gnu.org>.
- * pango-layout.c: High-level layout driver. Copyright (C) 2000, 2001, 2006 Red Hat Software
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include "ui/gtk/old-gtk-compat.h"
-
-#include <string.h>
-#include <stddef.h>
-
-#include <epan/wmem/wmem.h>
-#include <epan/charsets.h>
-#include <epan/packet.h>
-
-#include "ui/recent.h"
-
-#define MARGIN 2
-#define REFRESH_TIMEOUT 10
-
-static GtkWidgetClass *parent_class = NULL;
-
-struct _BytesView
-{
- GtkWidget widget;
-
- PangoContext *context;
-
- PangoFontDescription *font;
- int font_ascent;
- int font_descent;
- int fontsize;
-
- GtkAdjustment *vadj;
- GtkAdjustment *hadj;
-#if GTK_CHECK_VERSION(3, 0, 0)
- guint hscroll_policy : 1;
- guint vscroll_policy : 1;
-#endif
- gint adj_tag;
- int max_width;
-
- gboolean bold_highlight;
- int state;
-
-/* data */
- packet_char_enc encoding; /* ASCII or EBCDIC */
- bytes_view_type format; /* bytes in hex or bytes as bits */
- guint8 *pd; /* packet data */
- int len; /* length of packet data in bytes */
-/* data-highlight (field, appendix, protocol) */
- int start[3];
- int end[3];
-
- int per_line; /* number of bytes shown per line */
- int use_digits; /* number of hex digits of byte offset */
-};
-
-#include "bytes_view.h"
-
-typedef struct _BytesViewClass
-{
- GtkWidgetClass parent_class;
-
- void (*set_scroll_adjustments)(BytesView *, GtkAdjustment *, GtkAdjustment *);
-
-} BytesViewClass;
-
-static void bytes_view_set_scroll_adjustments(BytesView *, GtkAdjustment *, GtkAdjustment *);
-static void bytes_view_adjustment_set(BytesView *);
-
-static void
-bytes_view_init(BytesView *bv)
-{
- bv->context = NULL;
-
- bv->encoding = PACKET_CHAR_ENC_CHAR_ASCII;
- bv->format = BYTES_HEX;
-
- bv->per_line = 16;
- bv->use_digits = 4;
-
- bv->max_width = 0;
-}
-
-static void
-bytes_view_destroy(BytesView *bv)
-{
- if (bv->pd) {
- g_free(bv->pd);
- bv->pd = NULL;
- }
- if (bv->adj_tag) {
- g_source_remove(bv->adj_tag);
- bv->adj_tag = 0;
- }
- if (bv->vadj) {
- g_object_unref(G_OBJECT(bv->vadj));
- bv->vadj = NULL;
- }
- if (bv->hadj) {
- g_object_unref(G_OBJECT(bv->hadj));
- bv->hadj = NULL;
- }
- if (bv->font) {
- pango_font_description_free(bv->font);
- bv->font = NULL;
- }
- if (bv->context) {
- g_object_unref(bv->context);
- bv->context = NULL;
- }
-}
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-static void
-bytes_view_destroy_widget(GtkWidget *widget)
-{
- bytes_view_destroy(BYTES_VIEW(widget));
-
- GTK_WIDGET_CLASS(parent_class)->destroy(widget);
-}
-
-#else
-
-static void
-bytes_view_destroy_object(GtkObject *object)
-{
- bytes_view_destroy(BYTES_VIEW(object));
-
- if (GTK_OBJECT_CLASS(parent_class)->destroy)
- (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
-}
-
-#endif
-
-static void
-bytes_view_ensure_layout(BytesView *bv)
-{
- if (bv->context == NULL) {
- bv->context = gtk_widget_get_pango_context(GTK_WIDGET(bv));
- g_object_ref(bv->context);
-
- {
- PangoLanguage *lang;
- PangoFontMetrics *metrics;
-
- /* vte and xchat does it this way */
- lang = pango_context_get_language(bv->context);
- metrics = pango_context_get_metrics(bv->context, bv->font, lang);
- bv->font_ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
- bv->font_descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
- pango_font_metrics_unref(metrics);
-
- bv->fontsize = bv->font_ascent + bv->font_descent;
- }
- g_assert(bv->context);
- bytes_view_adjustment_set(bv);
- }
-}
-
-static void
-bytes_view_realize(GtkWidget *widget)
-{
- BytesView *bv;
- GdkWindowAttr attributes;
- GtkAllocation allocation;
- GdkWindow *win;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- GtkStyleContext *context;
-#endif
-
- _gtk_widget_set_realized_true(widget);
- bv = BYTES_VIEW(widget);
-
- gtk_widget_get_allocation(widget, &allocation);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual(widget);
- attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;
-
-#if !GTK_CHECK_VERSION(3, 0, 0)
- attributes.colormap = gtk_widget_get_colormap(widget);
-
- win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP);
-#else
- win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL);
-#endif
-
- gtk_widget_set_window(widget, win);
-
-#if GTK_CHECK_VERSION(3, 8, 0)
- gtk_widget_register_window(widget, win);
-#else
- gdk_window_set_user_data(win, widget);
-#endif
-
-#if !GTK_CHECK_VERSION(3, 0, 0) /* XXX, check */
- gdk_window_set_back_pixmap(win, NULL, FALSE);
-#endif
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- context = gtk_widget_get_style_context(widget);
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
- /* gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY); */
-
-#elif GTK_CHECK_VERSION(2, 20, 0)
- gtk_widget_style_attach(widget);
-#else
- widget->style = gtk_style_attach(widget->style, win);
-#endif
- bytes_view_ensure_layout(bv);
-}
-
-static void
-bytes_view_unrealize(GtkWidget *widget)
-{
- BytesView *bv = BYTES_VIEW(widget);
-
- if (bv->context) {
- g_object_unref(bv->context);
- bv->context = NULL;
- }
- /* if there are still events in the queue, this'll avoid segfault */
-#if !GTK_CHECK_VERSION(3, 8, 0)
- gdk_window_set_user_data(gtk_widget_get_window(widget), NULL);
-#endif
-
- if (parent_class->unrealize)
- (*GTK_WIDGET_CLASS(parent_class)->unrealize)(widget);
-}
-
-static GtkAdjustment *
-bytes_view_ensure_vadj(BytesView *bv)
-{
- if (bv->vadj == NULL) {
- bytes_view_set_scroll_adjustments(bv, bv->hadj, bv->vadj);
- g_assert(bv->vadj != NULL);
- }
- return bv->vadj;
-}
-
-static GtkAdjustment *
-bytes_view_ensure_hadj(BytesView *bv)
-{
- if (bv->hadj == NULL) {
- bytes_view_set_scroll_adjustments(bv, bv->hadj, bv->vadj);
- g_assert(bv->hadj != NULL);
- }
- return bv->hadj;
-}
-
-static gboolean
-bytes_view_scroll(GtkWidget *widget, GdkEventScroll *event)
-{
- BytesView *bv = BYTES_VIEW(widget);
-
- gdouble new_value;
-
- if (event->direction == GDK_SCROLL_UP) { /* mouse wheel pageUp */
- bytes_view_ensure_vadj(bv);
-
- new_value = gtk_adjustment_get_value(bv->vadj) - (gtk_adjustment_get_page_increment(bv->vadj) / 10);
- if (new_value < gtk_adjustment_get_lower(bv->vadj))
- new_value = gtk_adjustment_get_lower(bv->vadj);
- gtk_adjustment_set_value(bv->vadj, new_value);
-
- } else if (event->direction == GDK_SCROLL_DOWN) { /* mouse wheel pageDn */
- bytes_view_ensure_vadj(bv);
-
- new_value = gtk_adjustment_get_value(bv->vadj) + (gtk_adjustment_get_page_increment(bv->vadj) / 10);
- if (new_value > (gtk_adjustment_get_upper(bv->vadj) - gtk_adjustment_get_page_size(bv->vadj)))
- new_value = gtk_adjustment_get_upper(bv->vadj) - gtk_adjustment_get_page_size(bv->vadj);
- gtk_adjustment_set_value(bv->vadj, new_value);
- }
- return FALSE;
-}
-
-static void
-bytes_view_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- gtk_widget_set_allocation(widget, allocation);
-
- if (gtk_widget_get_realized(widget)) {
- BytesView *bv = BYTES_VIEW(widget);
-
- gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height);
- bytes_view_adjustment_set(bv);
- }
-}
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-static void
-bytes_view_get_preferred_width(GtkWidget *widget _U_, gint *minimum, gint *natural)
-{
- *minimum = *natural = 200;
-}
-
-static void
-bytes_view_get_preferred_height(GtkWidget *widget _U_, gint *minimum, gint *natural)
-{
- *minimum = *natural = 90;
-}
-
-#else
-
-static void
-bytes_view_size_request(GtkWidget *widget _U_, GtkRequisition *requisition)
-{
- requisition->width = 200;
- requisition->height = 90;
-}
-#endif
-
-static GSList *
-_pango_runs_build(BytesView *bv, const char *str, int len)
-{
- GSList *runs = NULL;
-
- PangoAttrList *attrs;
- PangoAttrIterator *iter;
-
- GList *run_list;
- GList *tmp_list;
-
- attrs = pango_attr_list_new();
- pango_attr_list_insert_before(attrs, pango_attr_font_desc_new(bv->font));
-
- iter = pango_attr_list_get_iterator(attrs);
-
- run_list = pango_itemize(bv->context, str, 0, len, attrs, iter);
-
- for (tmp_list = run_list; tmp_list; tmp_list = tmp_list->next) {
- PangoLayoutRun *run = g_slice_new(PangoLayoutRun);
- PangoItem *run_item = (PangoItem *)tmp_list->data;
-
- run->item = run_item;
-
- /* XXX pango_layout_get_item_properties(run_item, &state->properties); */
-
- run->glyphs = pango_glyph_string_new();
- pango_shape(str + run_item->offset, run_item->length, &run_item->analysis, run->glyphs);
-
- runs = g_slist_prepend(runs, run);
- }
-
- g_list_free(run_list);
-
- pango_attr_iterator_destroy(iter);
- pango_attr_list_unref(attrs);
-
- return g_slist_reverse(runs);
-}
-
-static int
-_pango_glyph_string_to_pixels(PangoGlyphString *glyphs, PangoFont *font _U_)
-{
-#if PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR >= 14
- return pango_glyph_string_get_width(glyphs) / PANGO_SCALE;
-#else
- PangoRectangle logical_rect;
-
- pango_glyph_string_extents(glyphs, font, NULL, &logical_rect);
- /* pango_extents_to_pixels(&logical_rect, NULL); */
-
- return (logical_rect.width / PANGO_SCALE);
-#endif
-}
-
-static int
-xtext_draw_layout_line(cairo_t *cr, gint x, gint y, GSList *runs)
-{
- while (runs) {
- PangoLayoutRun *run = (PangoLayoutRun *)runs->data;
-
- cairo_move_to(cr, x, y);
- pango_cairo_show_glyph_string(cr, run->item->analysis.font, run->glyphs);
-
- x += _pango_glyph_string_to_pixels(run->glyphs, run->item->analysis.font);
- runs = runs->next;
- }
- return x;
-}
-
-static int
-_pango_runs_width(GSList *runs)
-{
- int width = 0;
-
- while (runs) {
- PangoLayoutRun *run = (PangoLayoutRun *)runs->data;
-
- width += _pango_glyph_string_to_pixels(run->glyphs, run->item->analysis.font);
- runs = runs->next;
- }
- return width;
-}
-
-static void
-_pango_runs_free(GSList *runs)
-{
- GSList *list = runs;
-
- while (list) {
- PangoLayoutRun *run = (PangoLayoutRun *)list->data;
-
- pango_item_free(run->item);
- pango_glyph_string_free(run->glyphs);
- g_slice_free(PangoLayoutRun, run);
-
- list = list->next;
- }
- g_slist_free(runs);
-}
-
-typedef int bytes_view_line_cb(BytesView *, void *data, int x, int arg1, const char *str, int len);
-
-static int
-bytes_view_flush_render(BytesView *bv, void *data, int x, int y, const char *str, int len)
-{
- cairo_t *cr = (cairo_t *)data;
- GSList *line_runs;
- int str_width;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- GtkStyleContext *context;
- GdkRGBA bg_color, fg_color;
-#endif
-
- if (len < 1)
- return 0;
-
- line_runs = _pango_runs_build(bv, str, len);
-
- /* XXX, cliping */
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- context = gtk_widget_get_style_context(GTK_WIDGET(bv));
-#endif
-
- if (bv->state == GTK_STATE_SELECTED || bv->state == GTK_STATE_INSENSITIVE) {
- str_width = _pango_runs_width(line_runs);
-
- /* background */
-#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_style_context_get_background_color(context, (GtkStateFlags)( (bv->state == GTK_STATE_SELECTED ? GTK_STATE_FLAG_FOCUSED : 0) | GTK_STATE_FLAG_SELECTED), &bg_color);
- gdk_cairo_set_source_rgba(cr, &bg_color);
-#else
- gdk_cairo_set_source_color(cr, &gtk_widget_get_style(GTK_WIDGET(bv))->base[bv->state]);
-#endif
- cairo_rectangle(cr, x, y - bv->font_ascent, str_width, bv->fontsize);
- cairo_fill(cr);
- }
-
- /* text */
-#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_style_context_get_color(context, (GtkStateFlags)(GTK_STATE_FLAG_FOCUSED | (bv->state == GTK_STATE_SELECTED ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_NORMAL)), &fg_color);
- gdk_cairo_set_source_rgba(cr, &fg_color);
-#else
- gdk_cairo_set_source_color(cr, &gtk_widget_get_style(GTK_WIDGET(bv))->text[bv->state]);
-#endif
- str_width = xtext_draw_layout_line(cr, x, y, line_runs)-x;
-
- _pango_runs_free(line_runs);
-
- return str_width;
-}
-
-static int
-_pango_runs_find_index(GSList *runs, int x_pos, const char *str)
-{
- int start_pos = 0;
-
- while (runs) {
- PangoLayoutRun *run = (PangoLayoutRun *)runs->data;
- int width;
-
- width = _pango_glyph_string_to_pixels(run->glyphs, run->item->analysis.font);
-
- if (x_pos >= start_pos && x_pos < start_pos + width) {
- gboolean char_trailing;
- int pos;
-
- pango_glyph_string_x_to_index(run->glyphs,
- (char *) str + run->item->offset, run->item->length,
- &run->item->analysis,
- (x_pos - start_pos) * PANGO_SCALE,
- &pos, &char_trailing);
-
- return run->item->offset + pos;
- }
-
- start_pos += width;
- runs = runs->next;
- }
- return -1;
-}
-
-static int
-bytes_view_flush_pos(BytesView *bv, void *data, int x, int search_x, const char *str, int len)
-{
- int *pos_x = (int *)data;
- GSList *line_runs;
- int line_width;
-
- if (len < 1)
- return 0;
-
- line_runs = _pango_runs_build(bv, str, len);
-
- line_width = _pango_runs_width(line_runs);
-
- if (x <= search_x && x + line_width > search_x) {
- int off_x = search_x - x;
- int pos_run;
-
- if ((pos_run = _pango_runs_find_index(line_runs, off_x, str)) != -1)
- *pos_x = (-*pos_x) + pos_run;
-
- return -1; /* terminate */
- } else
- *pos_x -= len;
-
- _pango_runs_free(line_runs);
-
- return line_width;
-}
-
-static void
-bytes_view_render_state(BytesView *bv, int state)
-{
- g_assert(state == GTK_STATE_NORMAL || state == GTK_STATE_SELECTED || state == GTK_STATE_INSENSITIVE);
-
- if (bv->bold_highlight) {
- pango_font_description_set_weight(bv->font,
- (state == GTK_STATE_SELECTED) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
- bv->state = GTK_STATE_NORMAL;
- } else
- bv->state = state;
-}
-
-#define BYTE_VIEW_SEP 8 /* insert a space every BYTE_VIEW_SEP bytes */
-
-static void
-_bytes_view_line_common(BytesView *bv, void *data, const int org_off, int xx, int arg1, bytes_view_line_cb flush)
-{
- static const guchar hexchars[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
-
- const guint8 *pd = bv->pd;
- const int len = bv->len;
-
- int state;
-
- char str[128];
- int cur = 0;
-
- int off;
- guchar c;
- int byten;
- int j;
-
- int scroll_x;
- int dx;
-
- g_assert(org_off >= 0);
-
- scroll_x = (int) gtk_adjustment_get_value(bytes_view_ensure_hadj(bv));
-
- state = GTK_STATE_NORMAL;
- bytes_view_render_state(bv, GTK_STATE_NORMAL);
-
- /* Print the line number */
- j = bv->use_digits;
- do {
- j--;
- c = (org_off >> (j*4)) & 0xF;
- str[cur++] = hexchars[c];
- } while (j != 0);
- str[cur++] = ' ';
- str[cur++] = ' ';
-
- /* Print the hex bit */
- for (byten = 0, off = org_off; byten < bv->per_line; byten++) {
- gboolean byte_highlighted =
- (off >= bv->start[0] && off < bv->end[0]) ||
- (off >= bv->start[1] && off < bv->end[1]);
- gboolean proto_byte_highlighted =
- (off >= bv->start[2] && off < bv->end[2]);
-
- int state_cur = (off < len && byte_highlighted) ?
- GTK_STATE_SELECTED :
- (off < len && proto_byte_highlighted) ?
- GTK_STATE_INSENSITIVE :
- GTK_STATE_NORMAL;
-
- if (state_cur != state) {
- /* ok, we want to put space, we prefer to put it in STATE_NORMAL or STATE_INSENSITIVE */
- int space_now = (state_cur != GTK_STATE_NORMAL && state_cur != GTK_STATE_INSENSITIVE)
- || state == GTK_STATE_NORMAL;
-
- if (space_now && byten) {
- str[cur++] = ' ';
- /* insert a space every BYTE_VIEW_SEP bytes */
- if ((off % BYTE_VIEW_SEP) == 0)
- str[cur++] = ' ';
- }
-
- if ((dx = flush(bv, data, xx - scroll_x, arg1, str, cur)) < 0)
- return;
- xx += dx;
- cur = 0;
- bytes_view_render_state(bv, state_cur);
- state = state_cur;
-
- if (!space_now && byten) {
- str[cur++] = ' ';
- /* insert a space every BYTE_VIEW_SEP bytes */
- if ((off % BYTE_VIEW_SEP) == 0)
- str[cur++] = ' ';
- }
-
- } else if (byten) {
- str[cur++] = ' ';
- /* insert a space every BYTE_VIEW_SEP bytes */
- if ((off % BYTE_VIEW_SEP) == 0)
- str[cur++] = ' ';
- }
-
- if (off < len) {
- switch (bv->format) {
- case BYTES_HEX:
- str[cur++] = hexchars[(pd[off] & 0xf0) >> 4];
- str[cur++] = hexchars[pd[off] & 0x0f];
- break;
- case BYTES_BITS:
- /* XXX, bitmask */
- for (j = 7; j >= 0; j--)
- str[cur++] = (pd[off] & (1 << j)) ? '1' : '0';
- break;
- }
- } else {
- switch (bv->format) {
- case BYTES_HEX:
- str[cur++] = ' ';
- str[cur++] = ' ';
- break;
- case BYTES_BITS:
- for (j = 7; j >= 0; j--)
- str[cur++] = ' ';
- break;
- }
- }
- off++;
- }
-
- if (state != GTK_STATE_NORMAL) {
- if ((dx = flush(bv, data, xx - scroll_x, arg1, str, cur)) < 0)
- return;
- xx += dx;
- cur = 0;
- bytes_view_render_state(bv, GTK_STATE_NORMAL);
- state = GTK_STATE_NORMAL;
- }
-
- /* Print some space at the end of the line */
- str[cur++] = ' '; str[cur++] = ' '; str[cur++] = ' ';
-
- /* Print the ASCII bit */
- for (byten = 0, off = org_off; byten < bv->per_line; byten++) {
- gboolean byte_highlighted =
- (off >= bv->start[0] && off < bv->end[0]) ||
- (off >= bv->start[1] && off < bv->end[1]);
- gboolean proto_byte_highlighted =
- (off >= bv->start[2] && off < bv->end[2]);
-
- int state_cur = (off < len && byte_highlighted) ?
- GTK_STATE_SELECTED :
- (off < len && proto_byte_highlighted) ?
- GTK_STATE_INSENSITIVE :
- GTK_STATE_NORMAL;
-
- if (state_cur != state) {
- int space_now = (state_cur != GTK_STATE_NORMAL && state_cur != GTK_STATE_INSENSITIVE)
- || state == GTK_STATE_NORMAL;
-
- if (space_now && byten) {
- /* insert a space every BYTE_VIEW_SEP bytes */
- if ((off % BYTE_VIEW_SEP) == 0)
- str[cur++] = ' ';
- }
-
- if ((dx = flush(bv, data, xx - scroll_x, arg1, str, cur)) < 0)
- return;
- xx += dx;
- cur = 0;
- bytes_view_render_state(bv, state_cur);
- state = state_cur;
-
- if (!space_now && byten) {
- /* insert a space every BYTE_VIEW_SEP bytes */
- if ((off % BYTE_VIEW_SEP) == 0)
- str[cur++] = ' ';
- }
-
- } else if (byten) {
- /* insert a space every BYTE_VIEW_SEP bytes */
- if ((off % BYTE_VIEW_SEP) == 0)
- str[cur++] = ' ';
- }
-
- if (off < len) {
- c = (bv->encoding == PACKET_CHAR_ENC_CHAR_EBCDIC) ?
- EBCDIC_to_ASCII1(pd[off]) :
- pd[off];
-
- str[cur++] = g_ascii_isprint(c) ? c : '.';
- } else
- str[cur++] = ' ';
-
- off++;
- }
-
- if (cur) {
- if ((dx = flush(bv, data, xx - scroll_x, arg1, str, cur)) < 0)
- return;
- xx += dx;
- /* cur = 0; */
- }
-
- if (state != GTK_STATE_NORMAL) {
- bytes_view_render_state(bv, GTK_STATE_NORMAL);
- /* state = GTK_STATE_NORMAL; */
- }
-
- if (bv->max_width < xx)
- bv->max_width = xx;
-}
-
-static void
-_bytes_view_render_line(BytesView *bv, cairo_t *cr, const int org_off, int yy)
-{
- _bytes_view_line_common(bv, cr, org_off, MARGIN, yy, bytes_view_flush_render);
-}
-
-static int
-_bytes_view_find_pos(BytesView *bv, const int org_off, int search_x)
-{
- int pos_x = 0;
-
- _bytes_view_line_common(bv, &pos_x, org_off, MARGIN, search_x, bytes_view_flush_pos);
-
- return pos_x;
-}
-
-static void
-bytes_view_render(BytesView *bv, cairo_t *cr, GdkRectangle *area)
-{
- const int old_max_width = bv->max_width;
-
- int width, height;
- int y;
- int off;
-
- guint line, lines_max;
- guint lines_max_full;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- GtkStyleContext *context;
- GdkRGBA bg_color;
-#endif
-
- if (!gtk_widget_get_realized(GTK_WIDGET(bv)))
- return;
-
- bytes_view_ensure_layout(bv);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- width = gtk_widget_get_allocated_width(GTK_WIDGET(bv));
- height = gtk_widget_get_allocated_height(GTK_WIDGET(bv));
-#elif GTK_CHECK_VERSION(2,24,0)
- width = gdk_window_get_width(gtk_widget_get_window(GTK_WIDGET(bv)));
- height = gdk_window_get_height(gtk_widget_get_window(GTK_WIDGET(bv)));
-#else
- ws_gdk_drawable_get_size(gtk_widget_get_window(GTK_WIDGET(bv)), &width, &height);
-#endif
-
- if (width < 32 + MARGIN || height < bv->fontsize)
- return;
-
- if (area) {
- line = area->y / bv->fontsize;
- lines_max = 1 + (area->y + area->height) / bv->fontsize;
- } else {
- line = 0;
- lines_max = (guint) -1;
- }
- /* g_print("from %d to %d\n", line, lines_max); */
-
- y = (bv->fontsize * line);
-
- /* clear */
-#if GTK_CHECK_VERSION(3, 0, 0)
- context = gtk_widget_get_style_context(GTK_WIDGET(bv));
- gtk_style_context_get_background_color(context, (GtkStateFlags)(GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_NORMAL), &bg_color);
- gdk_cairo_set_source_rgba(cr, &bg_color);
-#else
- gdk_cairo_set_source_color(cr, &gtk_widget_get_style(GTK_WIDGET(bv))->base[GTK_STATE_NORMAL]);
-#endif
- if (area)
- cairo_rectangle(cr, area->x, area->y, area->x + area->width, area->y + area->height);
- else
- cairo_rectangle(cr, 0, 0, width, height);
- cairo_fill(cr);
-
- if (bv->pd) {
- guint real_line = line + (guint) gtk_adjustment_get_value(bytes_view_ensure_vadj(bv));
-
- lines_max_full = (height / bv->fontsize) + 1;
- if (lines_max_full < lines_max)
- lines_max = lines_max_full;
-
- off = real_line * bv->per_line;
-
- while (off < bv->len) {
- _bytes_view_render_line(bv, cr, off, y + bv->font_ascent);
- line++;
- if (line >= lines_max)
- break;
-
- off += bv->per_line;
- y += bv->fontsize;
- }
- }
-
- if (old_max_width != bv->max_width)
- bytes_view_adjustment_set(bv);
-}
-
-static void
-bytes_view_render_full(BytesView *bv)
-{
- cairo_t *cr;
-
- if (bv->adj_tag) {
- g_source_remove(bv->adj_tag);
- bv->adj_tag = 0;
- }
-
- cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(bv)));
- bytes_view_render(bv, cr, NULL);
- cairo_destroy(cr);
-}
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-static gboolean
-bytes_view_draw(GtkWidget *widget, cairo_t *cr)
-{
- GdkRectangle area;
-
- gdk_cairo_get_clip_rectangle(cr, &area);
-
- bytes_view_render(BYTES_VIEW(widget), cr, &area);
- return FALSE;
-}
-
-#else
-
-static gboolean
-bytes_view_expose(GtkWidget *widget, GdkEventExpose *event)
-{
- BytesView *bv = BYTES_VIEW(widget);
- cairo_t *cr;
-
- cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(bv)));
-
- gdk_cairo_region(cr, event->region);
- cairo_clip(cr);
-
- bytes_view_render(bv, cr, &event->area);
-
- cairo_destroy(cr);
- return FALSE;
-}
-
-#endif
-
-#if !GTK_CHECK_VERSION(2, 14, 0)
-static void
-_gtk_adjustment_configure(GtkAdjustment *adj,
- gdouble value,
- gdouble lower,
- gdouble upper,
- gdouble step_increment,
- gdouble page_increment,
- gdouble page_size)
-{
- adj->value = value;
- adj->lower = lower;
- adj->upper = upper;
- adj->step_increment = step_increment;
- adj->page_increment = page_increment;
- adj->page_size = page_size;
-
- gtk_adjustment_changed(adj);
-}
-
-#elif GTK_CHECK_VERSION(3, 0, 0)
-
-#define _gtk_adjustment_configure(adj, val, low, up, step, page, size) \
- gtk_adjustment_configure(adj, val, low, MAX((up), (size)), step, page, size)
-
-#else
-
-#define _gtk_adjustment_configure(adj, val, low, up, step, page, size) \
- gtk_adjustment_configure(adj, val, low, up, step, page, size)
-
-#endif
-
-
-static void
-bytes_view_adjustment_set(BytesView *bv)
-{
- GtkAllocation allocation;
- double lower, upper, page_size, step_increment, page_increment, value;
-
- if (bv->vadj == NULL || bv->hadj == NULL)
- return;
-
- if (bv->context == NULL) {
- bytes_view_ensure_layout(bv);
- /* bytes_view_ensure_layout will call bytes_view_adjustment_set() again */
- return;
- }
-
- gtk_widget_get_allocation(GTK_WIDGET(bv), &allocation);
-
- if (bv->vadj) {
- lower = 0;
- upper = (int) (bv->len / bv->per_line);
- if ((bv->len % bv->per_line))
- upper++;
-
- page_size = (allocation.height - bv->font_descent) / bv->fontsize;
- page_increment = page_size;
- step_increment = 1;
-
- value = gtk_adjustment_get_value(bv->vadj);
-
- if (value > upper - page_size)
- value = upper - page_size;
-
- if (value < 0)
- value = 0;
-
- _gtk_adjustment_configure(bv->vadj, value, lower, upper, step_increment, page_increment, page_size);
- }
-
- if (bv->hadj) {
- lower = 0;
- upper = bv->max_width;
-
- page_size = allocation.width;
- page_increment = page_size;
- step_increment = page_size / 10.0;
-
- value = gtk_adjustment_get_value(bv->hadj);
-
- if (value > upper - page_size)
- value = upper - page_size;
-
- if (value < 0)
- value = 0;
-
- _gtk_adjustment_configure(bv->hadj, value, lower, upper, step_increment, page_increment, page_size);
- }
-}
-
-static gint
-bytes_view_adjustment_timeout(BytesView *bv)
-{
- bv->adj_tag = 0;
- bytes_view_render_full(bv);
- return 0;
-}
-
-static void
-bytes_view_adjustment_changed(GtkAdjustment *adj, BytesView *bv)
-{
- /* delay rendering when scrolling (10ms) */
- if (adj && ((adj == bv->vadj) || (adj == bv->hadj))) {
- if (!bv->adj_tag)
- bv->adj_tag = g_timeout_add(REFRESH_TIMEOUT, (GSourceFunc) bytes_view_adjustment_timeout, bv);
- }
-}
-
-static void
-bytes_view_set_scroll_adjustments(BytesView *bv, GtkAdjustment *hadj, GtkAdjustment *vadj)
-{
- gboolean need_adjust = FALSE;
-
- g_return_if_fail(!hadj || GTK_IS_ADJUSTMENT(hadj));
- g_return_if_fail(!vadj || GTK_IS_ADJUSTMENT(vadj));
-
- if (!vadj)
- vadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
-
- if (!hadj)
- hadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
-
- if (bv->vadj && (bv->vadj != vadj)) {
- g_signal_handlers_disconnect_by_func(bv->vadj, bytes_view_adjustment_changed, bv);
- g_object_unref(bv->vadj);
- }
- if (bv->vadj != vadj) {
- bv->vadj = vadj;
- g_object_ref_sink(bv->vadj);
-
- g_signal_connect(bv->vadj, "value-changed", G_CALLBACK(bytes_view_adjustment_changed), bv);
- need_adjust = TRUE;
-#if GTK_CHECK_VERSION(3, 0, 0)
- g_object_notify(G_OBJECT(bv), "vadjustment");
-#endif
- }
-
- if (bv->hadj && (bv->hadj != hadj)) {
- g_signal_handlers_disconnect_by_func(bv->hadj, bytes_view_adjustment_changed, bv);
- g_object_unref(bv->hadj);
- }
- if (bv->hadj != hadj) {
- bv->hadj = hadj;
- g_object_ref_sink(bv->hadj);
-
- g_signal_connect(bv->hadj, "value-changed", G_CALLBACK(bytes_view_adjustment_changed), bv);
- need_adjust = TRUE;
-#if GTK_CHECK_VERSION(3, 0, 0)
- g_object_notify(G_OBJECT(bv), "hadjustment");
-#endif
- }
-
- if (need_adjust)
- bytes_view_adjustment_set(bv);
-}
-
-#if GTK_CHECK_VERSION(3, 0, 0)
-enum {
- PROP_0,
- PROP_HADJUSTMENT,
- PROP_VADJUSTMENT,
- PROP_HSCROLL_POLICY,
- PROP_VSCROLL_POLICY
-};
-
-static void
-bytes_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- BytesView *bv = BYTES_VIEW(object);
-
- switch (prop_id) {
- case PROP_HADJUSTMENT:
- bytes_view_set_scroll_adjustments(bv, (GtkAdjustment *)g_value_get_object(value), bv->vadj);
- break;
-
- case PROP_VADJUSTMENT:
- bytes_view_set_scroll_adjustments(bv, bv->hadj, (GtkAdjustment *)g_value_get_object(value));
- break;
-
- case PROP_HSCROLL_POLICY:
- bv->hscroll_policy = g_value_get_enum(value);
- gtk_widget_queue_resize(GTK_WIDGET(bv));
- break;
-
- case PROP_VSCROLL_POLICY:
- bv->vscroll_policy = g_value_get_enum(value);
- gtk_widget_queue_resize(GTK_WIDGET(bv));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-bytes_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- BytesView *bv = BYTES_VIEW(object);
-
- switch (prop_id) {
- case PROP_HADJUSTMENT:
- g_value_set_object(value, bv->hadj);
- break;
-
- case PROP_VADJUSTMENT:
- g_value_set_object(value, bv->vadj);
- break;
-
- case PROP_HSCROLL_POLICY:
- g_value_set_enum(value, bv->hscroll_policy);
- break;
-
- case PROP_VSCROLL_POLICY:
- g_value_set_enum(value, bv->vscroll_policy);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-#else
-
-/* bv_VOID__OBJECT_OBJECT() generated by:
- * $ echo 'VOID:OBJECT,OBJECT' | glib-genmarshal --prefix=bv --body
- * (glib-genmarshal version 2.32.4)
- * I *really hope* it's portable over platforms and can be put generated.
- */
-
-static void
-bv_VOID__OBJECT_OBJECT(GClosure *closure, GValue *return_value _U_, guint n_params, const GValue *param_values, gpointer hint _U_, gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT)(gpointer, gpointer, gpointer, gpointer);
-
- register GMarshalFunc_VOID__OBJECT_OBJECT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail(n_params == 3);
-
- if (G_CCLOSURE_SWAP_DATA(closure)) {
- data1 = closure->data;
- data2 = g_value_peek_pointer(param_values + 0);
- } else {
- data1 = g_value_peek_pointer(param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
-
- callback(data1, g_value_get_object(param_values + 1), g_value_get_object(param_values + 2), data2);
-}
-
-#endif
-
-static void
-bytes_view_class_init(BytesViewClass *klass)
-{
-#if !GTK_CHECK_VERSION(3, 0, 0)
- GtkObjectClass *object_class;
-#endif
- GtkWidgetClass *widget_class;
-
- parent_class = (GtkWidgetClass *) g_type_class_peek_parent(klass);
-
-#if !GTK_CHECK_VERSION(3, 0, 0)
- object_class = (GtkObjectClass *) klass;
-#endif
- widget_class = (GtkWidgetClass *) klass;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- widget_class->destroy = bytes_view_destroy_widget;
-#else
- object_class->destroy = bytes_view_destroy_object;
-#endif
- widget_class->realize = bytes_view_realize;
- widget_class->unrealize = bytes_view_unrealize;
-#if GTK_CHECK_VERSION(3, 0, 0)
- widget_class->get_preferred_width = bytes_view_get_preferred_width;
- widget_class->get_preferred_height = bytes_view_get_preferred_height;
-#else
- widget_class->size_request = bytes_view_size_request;
-#endif
- widget_class->size_allocate = bytes_view_allocate;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- widget_class->draw = bytes_view_draw;
-#else
- widget_class->expose_event = bytes_view_expose;
-#endif
-
- widget_class->scroll_event = bytes_view_scroll;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- {
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->set_property = bytes_view_set_property;
- gobject_class->get_property = bytes_view_get_property;
-
- /* XXX, move some code from widget->destroy to gobject->finalize? */
- /* gobject_class->finalize = bytes_view_finalize; */
-
- g_object_class_override_property(gobject_class, PROP_HADJUSTMENT, "hadjustment");
- g_object_class_override_property(gobject_class, PROP_VADJUSTMENT, "vadjustment");
- g_object_class_override_property(gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
- g_object_class_override_property(gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy");
- }
-#else
- klass->set_scroll_adjustments = bytes_view_set_scroll_adjustments;
-
- widget_class->set_scroll_adjustments_signal =
- g_signal_new(g_intern_static_string("set-scroll-adjustments"),
- G_OBJECT_CLASS_TYPE(object_class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- offsetof(BytesViewClass, set_scroll_adjustments),
- NULL, NULL,
- bv_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ADJUSTMENT,
- GTK_TYPE_ADJUSTMENT);
-#endif
-}
-
-GType
-bytes_view_get_type(void)
-{
- static GType bytes_view_gtype = 0;
-
- if (!bytes_view_gtype) {
- static const GTypeInfo bytes_view_info = {
- sizeof (BytesViewClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) bytes_view_class_init,
- NULL, /* class finalize */
- NULL, /* class_data */
- sizeof(BytesView),
- 0, /* n_preallocs */
- (GInstanceInitFunc) bytes_view_init,
- NULL /* value_table */
- };
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- static const GInterfaceInfo scrollable_info = {
- NULL,
- NULL,
- NULL
- };
-#endif
-
- bytes_view_gtype = g_type_register_static(GTK_TYPE_WIDGET,
- "BytesView",
- &bytes_view_info,
- (GTypeFlags)0);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- g_type_add_interface_static(bytes_view_gtype,
- GTK_TYPE_SCROLLABLE,
- &scrollable_info);
-#endif
- }
- return bytes_view_gtype;
-}
-
-int
-bytes_view_byte_from_xy(BytesView *bv, int x, int y)
-{
- /* hex_pos_byte array generated with hex_view_get_byte(0, 0, 0...70) */
- static const int hex_pos_byte[70] = {
- -1, -1,
- 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3,
- 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7,
- -1,
- 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11,
- 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15,
- -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7,
- -1,
- 8, 9, 10, 11, 12, 13, 14, 15
- };
-
- /* bits_pos_byte array generated with bit_view_get_byte(0, 0, 0...84) */
- static const int bits_pos_byte[84] = {
- -1, -1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7
- };
-
- int char_x, off_x = 1;
- int char_y, off_y;
-
- if (x < MARGIN)
- return -1;
-
- bytes_view_ensure_layout(bv);
-
- char_y = (int) gtk_adjustment_get_value(bytes_view_ensure_vadj(bv)) + (y / bv->fontsize);
- off_y = char_y * bv->per_line;
-
- char_x = _bytes_view_find_pos(bv, off_y, x);
- if (/* char_x < 0 || */ char_x < bv->use_digits)
- return -1;
- char_x -= bv->use_digits;
-
- switch (bv->format) {
- case BYTES_BITS:
- g_return_val_if_fail(char_x >= 0 && char_x < (int) G_N_ELEMENTS(bits_pos_byte), -1);
- off_x = bits_pos_byte[char_x];
- break;
-
- case BYTES_HEX:
- g_return_val_if_fail(char_x >= 0 && char_x < (int) G_N_ELEMENTS(hex_pos_byte), -1);
- off_x = hex_pos_byte[char_x];
- break;
- }
-
- if (off_x == -1)
- return -1;
-
- return off_y + off_x;
-}
-
-void
-bytes_view_scroll_to_byte(BytesView *bv, int byte)
-{
- int line;
-
- g_return_if_fail(byte >= 0 && byte < bv->len);
-
- line = byte / bv->per_line;
-
- bytes_view_ensure_vadj(bv);
-
- if (line > gtk_adjustment_get_upper(bv->vadj) - gtk_adjustment_get_page_size(bv->vadj)) {
- line = (int)(gtk_adjustment_get_upper(bv->vadj) - gtk_adjustment_get_page_size(bv->vadj));
-
- if (line < 0)
- line = 0;
- }
-
- /* after bytes_view_scroll_to_byte() we always do bytes_view_refresh() so we can block it */
- g_signal_handlers_block_by_func(bv->vadj, bytes_view_adjustment_changed, bv);
- gtk_adjustment_set_value(bv->vadj, line);
- g_signal_handlers_unblock_by_func(bv->vadj, bytes_view_adjustment_changed, bv);
-
- /* XXX, scroll hadj? */
-}
-
-void
-bytes_view_set_font(BytesView *bv, PangoFontDescription *font)
-{
- if (bv->font)
- pango_font_description_free(bv->font);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_override_font(GTK_WIDGET(bv), font);
-#else
- gtk_widget_modify_font(GTK_WIDGET(bv), font);
-#endif
- bv->font = pango_font_description_copy(font);
- bv->max_width = 0;
-
- if (bv->context) {
- g_object_unref(bv->context);
- bv->context = NULL;
- bytes_view_ensure_layout(bv);
- }
-}
-
-void
-bytes_view_set_data(BytesView *bv, const guint8 *data, int len)
-{
- g_free(bv->pd);
- bv->pd = (guint8 *)g_memdup(data, len);
- bv->len = len;
-
- /*
- * How many of the leading digits of the offset will we supply?
- * We always supply at least 4 digits, but if the maximum offset
- * won't fit in 4 digits, we use as many digits as will be needed.
- */
- if (((len - 1) & 0xF0000000) != 0)
- bv->use_digits = 8; /* need all 8 digits */
- else if (((len - 1) & 0x0F000000) != 0)
- bv->use_digits = 7; /* need 7 digits */
- else if (((len - 1) & 0x00F00000) != 0)
- bv->use_digits = 6; /* need 6 digits */
- else if (((len - 1) & 0x000F0000) != 0)
- bv->use_digits = 5; /* need 5 digits */
- else
- bv->use_digits = 4; /* we'll supply 4 digits */
-
- bytes_view_ensure_vadj(bv);
-
- bytes_view_adjustment_set(bv);
-}
-
-void
-bytes_view_set_encoding(BytesView *bv, packet_char_enc enc)
-{
- bv->encoding = enc;
-}
-
-void
-bytes_view_set_format(BytesView *bv, int format)
-{
- g_assert(format == BYTES_HEX || format == BYTES_BITS);
-
- bv->format = (bytes_view_type)format;
-
- switch (format) {
- case BYTES_BITS:
- bv->per_line = 8;
- break;
-
- case BYTES_HEX:
- bv->per_line = 16;
- break;
- }
-}
-
-void
-bytes_view_set_highlight_style(BytesView *bv, gboolean inverse)
-{
- bv->bold_highlight = !inverse;
-}
-
-void
-bytes_view_set_highlight(BytesView *bv, int start, int end, guint64 mask _U_, int maskle _U_)
-{
- bv->start[0] = start;
- bv->end[0] = end;
-}
-
-void
-bytes_view_set_highlight_extra(BytesView *bv, int id, int start, int end)
-{
- bv->start[id] = start;
- bv->end[id] = end;
-}
-
-void
-bytes_view_refresh(BytesView *bv)
-{
- /* bytes_view_render_full(bv); */
- gtk_widget_queue_draw(GTK_WIDGET(bv));
-}
-
-GtkWidget *
-bytes_view_new(void)
-{
- GtkWidget *widget;
-
- widget = (GtkWidget *) g_object_new(BYTES_VIEW_TYPE, NULL);
-
- g_assert(widget != NULL);
-
- return widget;
-}
-
-/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
- *
- * Local variables:
- * c-basic-offset: 8
- * tab-width: 8
- * indent-tabs-mode: t
- * End:
- *
- * vi: set shiftwidth=8 tabstop=8 noexpandtab:
- * :indentSize=8:tabSize=8:noTabs=false:
- */
diff --git a/ui/gtk/bytes_view.h b/ui/gtk/bytes_view.h
deleted file mode 100644
index bce61096bd..0000000000
--- a/ui/gtk/bytes_view.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* bytes_view.h
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- */
-
-#ifndef __BYTES_VIEW_H__
-#define __BYTES_VIEW_H__
-
-#define BYTES_VIEW_TYPE (bytes_view_get_type())
-#define BYTES_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST((object), BYTES_VIEW_TYPE, BytesView))
-
-#define BYTE_VIEW_HIGHLIGHT_APPENDIX 1
-#define BYTE_VIEW_HIGHLIGHT_PROTOCOL 2
-
-typedef struct _BytesView BytesView;
-
-GType bytes_view_get_type(void);
-
-GtkWidget *bytes_view_new(void);
-void bytes_view_set_font(BytesView *bv, PangoFontDescription *font);
-
-void bytes_view_set_data(BytesView *bv, const guint8 *data, int len);
-void bytes_view_set_encoding(BytesView *bv, packet_char_enc enc);
-void bytes_view_set_format(BytesView *bv, int format);
-void bytes_view_set_highlight_style(BytesView *bv, gboolean bold);
-
-void bytes_view_set_highlight(BytesView *bv, int start, int end, guint64 mask, int maskle);
-void bytes_view_set_highlight_extra(BytesView *bv, int id, int start, int end);
-
-void bytes_view_refresh(BytesView *bv);
-int bytes_view_byte_from_xy(BytesView *bv, int x, int y);
-void bytes_view_scroll_to_byte(BytesView *bv, int byte);
-
-#endif /* __BYTES_VIEW_H__ */
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
deleted file mode 100644
index bb68bbf918..0000000000
--- a/ui/gtk/capture_dlg.c
+++ /dev/null
@@ -1,6243 +0,0 @@
-/* capture_dlg.c
- * Routines for the "Capture Options" dialog and dialog windows popped
- * up from it
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#ifdef HAVE_LIBPCAP
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include <epan/packet.h>
-#include <epan/addr_resolv.h>
-#include <epan/prefs.h>
-#include <wsutil/filesystem.h>
-#include <wsutil/strtoi.h>
-
-#include <wiretap/wtap.h>
-
-#include "ui/capture.h"
-#include "caputils/capture_ifinfo.h"
-#include "caputils/capture-pcap-util.h"
-#include "../../ringbuffer.h"
-
-#include "ui/capture_ui_utils.h"
-#include "ui/capture_globals.h"
-#include "ui/iface_lists.h"
-#include "ui/preference_utils.h"
-#include "ui/recent.h"
-#include "ui/recent_utils.h"
-#include "ui/util.h"
-
-#include "ui/gtk/main.h"
-#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/capture_dlg.h"
-#include "ui/gtk/filter_dlg.h"
-#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/file_dlg.h"
-#include "ui/gtk/capture_file_dlg.h"
-#include "ui/gtk/help_dlg.h"
-#include "ui/gtk/gtkglobals.h"
-#include "ui/gtk/cfilter_combo_utils.h"
-#include "ui/gtk/capture_if_dlg.h"
-#include "ui/gtk/main_welcome.h"
-#include "ui/gtk/menus.h"
-#include "ui/gtk/prefs_dlg.h"
-#include "ui/gtk/main_80211_toolbar.h"
-#include "ui/gtk/stock_icons.h"
-#ifndef HAVE_GDK_GRESOURCE
-#include "ui/gtk/pixbuf-csource.h"
-#endif
-#include "simple_dialog.h"
-
-#include "ui/gtk/keys.h"
-
-#include "ui/gtk/old-gtk-compat.h"
-
-#ifdef HAVE_AIRPCAP
-#include <caputils/airpcap.h>
-#include <caputils/airpcap_loader.h>
-#include "airpcap_gui_utils.h"
-#include "airpcap_dlg.h"
-#endif
-
-#include "extcap.h"
-#include "ui/gtk/extcap_gtk.h"
-
-#include "globals.h"
-
-/*
- * Symbolic names for column indices.
- */
-enum
-{
- CAPTURE = 0,
- IFACE_HIDDEN_NAME,
- INTERFACE,
- LINK,
- PMODE,
- SNAPLEN,
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- BUFFER,
-#endif
-#ifdef HAVE_PCAP_CREATE
- MONITOR,
-#endif
- FILTER,
- NUM_COLUMNS
-};
-
-enum
-{
- COMPILE_ERROR = 0,
- SIGN,
- INAME
-};
-
-#ifdef _WIN32
- #define LOCAL_OFFSET 1
-#else
- #define LOCAL_OFFSET 0
-#endif
-
-/* Capture callback data keys */
-#define E_CAP_IFACE_KEY "cap_iface"
-#define E_CAP_IFACE_IP_KEY "cap_iface_ip"
-#define E_CAP_SNAP_CB_KEY "cap_snap_cb"
-#define E_CAP_LT_CBX_KEY "cap_lt_cbx"
-#define E_CAP_LT_CBX_LABEL_KEY "cap_lt_cbx_label"
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
-#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
-#endif
-#define E_CAP_SNAP_SB_KEY "cap_snap_sb"
-#define E_CAP_PROMISC_KEY "cap_promisc"
-#define E_CAP_PROMISC_KEY_ALL "cap_promisc_all"
-#define E_CAP_KEY_ALL "cap_all"
-#ifdef HAVE_PCAP_CREATE
-#define E_CAP_MONITOR_KEY "cap_monitor"
-#endif
-#define E_CAP_PCAP_NG_KEY "cap_pcap_ng"
-#define E_CAP_FILT_KEY "cap_filter_te"
-#define E_OPT_EDIT_DIALOG_PTR_KEY "cap_edit_opt_dialog"
-#define E_OPT_EDIT_CALLER_PTR_KEY "cap_edit_opt_caller"
-#define E_CAP_FILE_TE_KEY "cap_file_te"
-#define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
-#define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
-#define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
-#define E_CAP_RING_FILESIZE_CBX_KEY "cap_ring_filesize_cbx"
-#define E_CAP_FILE_INTERVAL_CB_KEY "cap_file_interval_cb"
-#define E_CAP_FILE_INTERVAL_SB_KEY "cap_file_interval_sb"
-#define E_CAP_FILE_INTERVAL_CBX_KEY "cap_file_interval_cbx"
-#define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
-#define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
-#define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
-#define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
-#define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
-#define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
-#define E_CAP_SYNC_KEY "cap_sync"
-#define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
-#define E_CAP_HIDE_INFO_KEY "cap_hide_info"
-#define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
-#define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
-#define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
-#define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
-#define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
-#define E_CAP_STOP_FILESIZE_CBX_KEY "cap_stop_filesize_cbx"
-#define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
-#define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
-#define E_CAP_STOP_DURATION_CBX_KEY "cap_stop_duration_cbx"
-#define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
-#define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
-#define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
-#define E_CAP_E_RESOLVE_KEY "cap_e_resolve"
-#define E_CAP_EXTCAP_KEY "cap_extcap_vbox"
-
-#define E_CAP_IFTYPE_CBX_KEY "cap_iftype_cbx"
-#ifdef HAVE_PCAP_REMOTE
-#define E_CAP_IF_LIST_KEY "cap_if_list"
-#define E_CAP_DATATX_UDP_CB_KEY "cap_datatx_udp_cb"
-#define E_CAP_NOCAP_RPCAP_CB_KEY "cap_nocap_rpcap_cb"
-#define E_CAP_REMOTE_DIALOG_PTR_KEY "cap_remote_dialog"
-#define E_CAP_REMOTE_CALLER_PTR_KEY "cap_remote_caller"
-#define E_REMOTE_HOST_TE_KEY "cap_remote_host"
-#define E_REMOTE_PORT_TE_KEY "cap_remote_port"
-#define E_REMOTE_AUTH_NULL_KEY "cap_remote_auth_null"
-#define E_REMOTE_AUTH_PASSWD_KEY "cap_remote_auth_passwd"
-#define E_REMOTE_USERNAME_LB_KEY "cap_remote_username_lb"
-#define E_REMOTE_USERNAME_TE_KEY "cap_remote_username_te"
-#define E_REMOTE_PASSWD_LB_KEY "cap_remote_passwd_lb"
-#define E_REMOTE_PASSWD_TE_KEY "cap_remote_passwd_te"
-#define E_REMOTE_OK_BT_KEY "cap_remote_ok_bt"
-#define E_REMOTE_DEL_BT_KEY "cap_remote_delete_bt"
-#define E_CAP_CBX_IFTYPE_NOUPDATE_KEY "cap_cbx_iftype_noupdate"
-#define E_OPT_REMOTE_DIALOG_PTR_KEY "cap_remote_opt_dialog"
-#define E_OPT_REMOTE_CALLER_PTR_KEY "cap_remote_opt_caller"
-#endif
-#ifdef HAVE_PCAP_SETSAMPLING
-#define E_CAP_SAMP_NONE_RB_KEY "cap_samp_none_rb"
-#define E_CAP_SAMP_COUNT_RB_KEY "cap_samp_count_rb"
-#define E_CAP_SAMP_COUNT_SB_KEY "cap_samp_count_sb"
-#define E_CAP_SAMP_TIMER_RB_KEY "cap_samp_timer_rb"
-#define E_CAP_SAMP_TIMER_SB_KEY "cap_samp_timer_sb"
-#endif
-#define E_CAP_PIPE_TE_KEY "cap_pipe_te"
-#define E_CAP_PIPE_L_KEY "cap_pipe_list"
-#define E_CAP_PIPE_DEL_KEY "cap_pipe_delete_key"
-#define E_CAP_LOCAL_L_KEY "cap_local_list"
-#define E_CAP_REMOTE_L_KEY "cap_remote_list"
-
-#define E_COMPILE_SW_SCROLLW_KEY "compileScrolledWindowInterfaces"
-#define E_COMPILE_TREE_VIEW_INTERFACES "compileTreeViewInterfaces"
-
-#define DUMMY_SNAPLENGTH 65535
-#define DUMMY_NETMASK 0xFF000000
-
-enum
-{
- COL_NAME = 0,
- COL_ADDRESS,
- COL_LINK
-} ;
-
-/*
- * Keep a static pointer to the current "Capture Options" window, if
- * any, so that if somebody tries to do "Capture:Options" while there's
- * already a "Capture Options" window up, we just pop up the existing
- * one, rather than creating a new one.
- * Also: Capture:Start obtains info from the "Capture Options" window
- * if it exists and if its creation is complete.
- */
-static GtkWidget *cap_open_w = NULL, *opt_edit_w = NULL, *ok_bt, *interface_management_w = NULL;
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
-static GtkWidget *compile_bpf_w = NULL;
-#endif
-static gboolean cap_open_complete; /* valid only if cap_open_w != NULL */
-static const gchar *pipe_name = NULL;
-static const gchar *selected_name;
-static GtkWidget *columns_menu_object;
-static GtkUIManager *ui_manager_columns = NULL;
-static GSList *popup_menu_list = NULL;
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
-static GHashTable *compile_results = NULL;
-static GtkWidget *all_compile_bt;
-#endif
-
-static gint marked_interface;
-static gint marked_row;
-
-#ifdef HAVE_PCAP_REMOTE
-static remote_options global_remote_opts;
-static guint num_selected = 0;
-#endif
-
-static gulong capture_all_handler_id;
-static gulong promisc_all_handler_id;
-
-static void
-capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
-
-static void
-capture_prep_pipe_cb(GtkWidget *pipe_bt, GtkWidget *pipe_te);
-
-static void
-select_link_type_cb(GtkWidget *w, gpointer data);
-
-#ifdef HAVE_PCAP_REMOTE
-static void
-populate_existing_remotes(gpointer key, gpointer value, gpointer user_data);
-
-static void
-capture_remote_cb(GtkWidget *w, gboolean focus_username);
-
-static void
-select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data);
-
-static void
-fill_remote_list(void);
-#endif
-
-static void
-capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
-
-static void
-capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
-
-#ifdef HAVE_PCAP_CREATE
-static void
-capture_prep_monitor_changed_cb(GtkWidget *monitor, gpointer argp);
-#endif
-
-static gboolean
-capture_dlg_prep(gpointer parent_w);
-
-static GtkTreeModel*
-create_and_fill_model(GtkTreeView *view);
-
-static void
-update_options_table(gint indx);
-
-static void
-update_properties_all(void);
-
-static gboolean
-query_tooltip_tree_view_cb (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_tip,
- GtkTooltip *tooltip,
- gpointer data);
-
-static
-gchar *col_index_to_name(gint indx)
-{
- gchar *col_name;
-
- switch (indx)
- {
- case INTERFACE: col_name = g_strdup("INTERFACE");
- break;
- case LINK: col_name = g_strdup("LINK");
- break;
- case PMODE: col_name = g_strdup("PMODE");
- break;
- case SNAPLEN: col_name = g_strdup("SNAPLEN");
- break;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- case BUFFER: col_name = g_strdup("BUFFER");
- break;
-#endif
-#ifdef HAVE_PCAP_CREATE
- case MONITOR: col_name = g_strdup("MONITOR");
- break;
-#endif
- case FILTER: col_name = g_strdup("FILTER");
- break;
- default: return NULL;
- }
- return col_name;
-}
-
-static
-gint col_title_to_index(const gchar *name)
-{
- if (strcmp(name, "Capture") == 0) return CAPTURE;
- if (strcmp(name, "Interface") == 0) return INTERFACE;
- if (strcmp(name, "Link-layer header") == 0) return LINK;
- if (strcmp(name, "Prom. Mode") == 0) return PMODE;
- if (strcmp(name, "Snaplen [B]") == 0) return SNAPLEN;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- if (strcmp(name, "Buffer [MiB]") == 0) return BUFFER;
-#endif
-#ifdef HAVE_PCAP_CREATE
- if (strcmp(name, "Mon. Mode") == 0) return MONITOR;
-#endif
- if (strcmp(name, "Capture Filter") == 0) return FILTER;
- return -1;
-}
-
-static void
-set_capture_column_visible(gchar *col, gboolean visible _U_)
-{
- GList *curr;
- gchar *col_name;
-
- if (visible && !prefs_capture_options_dialog_column_is_visible(col)) {
- prefs.capture_columns = g_list_append(prefs.capture_columns, col);
- } else if (!visible && prefs_capture_options_dialog_column_is_visible(col)) {
- for (curr = g_list_first(prefs.capture_columns); curr; curr = g_list_next(curr)) {
- col_name = (gchar *)curr->data;
- if (col_name && (g_ascii_strcasecmp(col_name, col) == 0)) {
- prefs.capture_columns = g_list_remove(prefs.capture_columns, curr->data);
- break;
- }
- }
- }
-}
-
-static void
-toggle_visible_column_cb (GtkWidget *w _U_, gpointer data)
-{
- GtkTreeView *view;
- GtkTreeViewColumn *col;
- gchar *col_name;
- gint col_id;
-
- col_id = GPOINTER_TO_INT(data);
- view = (GtkTreeView *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_id);
- col_name = col_index_to_name(col_id);
- gtk_tree_view_column_set_visible(col, prefs_capture_options_dialog_column_is_visible(col_name)?FALSE:TRUE);
- set_capture_column_visible(col_name, prefs_capture_options_dialog_column_is_visible(col_name)?FALSE:TRUE);
-}
-
-
-static void
-set_all_columns_visible (void)
-{
- GtkTreeViewColumn *col;
- int col_id;
- GtkTreeView *view;
- gchar *name;
-
- view = (GtkTreeView *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- for (col_id = 2; col_id < NUM_COLUMNS; col_id++) {
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_id);
- gtk_tree_view_column_set_visible(col, TRUE);
- if ((name = col_index_to_name(col_id)) != NULL) {
- set_capture_column_visible(name, TRUE);
- }
- }
-
- if (!prefs.gui_use_pref_save) {
- prefs_main_write();
- }
-
- update_visible_columns_menu ();
-}
-
-static void
-columns_activate_all_columns_cb(GtkAction *action _U_, gpointer user_data _U_)
-{
- set_all_columns_visible ();
-}
-
-void
-update_visible_tree_view_columns(void)
-{
- GtkTreeView *view;
- gint col_id;
- GtkTreeViewColumn *col;
-
- view = (GtkTreeView *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(view), INTERFACE), TRUE);
- for (col_id = 3; col_id < NUM_COLUMNS; col_id++) {
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_id);
- gtk_tree_view_column_set_visible(col, prefs_capture_options_dialog_column_is_visible(col_index_to_name(col_id))?TRUE:FALSE);
- }
-}
-
-
-void
-update_visible_columns_menu (void)
-{
- GtkWidget *menu_columns, *menu_item;
- GtkWidget *sub_menu;
- gchar *title;
- gint col_id;
-
- menu_columns = gtk_ui_manager_get_widget(ui_manager_columns, "/ColumnsPopup/DisplayedColumns");
- /* Debug */
- if (! menu_columns){
- fprintf (stderr, "Warning: couldn't find menu_columns path=/ColumnsPopup/DisplayedColumns");
- }
-
- sub_menu = gtk_menu_new();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_columns), sub_menu);
-
- for (col_id = 3; col_id < NUM_COLUMNS; col_id++) {
- title = col_index_to_name(col_id);
- menu_item = gtk_check_menu_item_new_with_label(title);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), prefs_capture_options_dialog_column_is_visible(title));
- g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(toggle_visible_column_cb), GINT_TO_POINTER(col_id));
- gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
- gtk_widget_show (menu_item);
- }
- menu_item = gtk_menu_item_new();
- gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
- gtk_widget_show (menu_item);
-
- menu_item = gtk_menu_item_new_with_label ("Display All");
- gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
- g_signal_connect(menu_item, "activate", G_CALLBACK(columns_activate_all_columns_cb), NULL);
- gtk_widget_show (menu_item);
-}
-
-static void
-columns_pref_cb(GtkAction *action _U_, gpointer user_data)
-{
- GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_columns, "/ColumnsPopup/ColumnPreferences");
- prefs_page_cb( widget , user_data, PREFS_PAGE_CAPTURE);
-}
-
-static void
-columns_hide_col_cb(GtkAction *action _U_, gpointer user_data _U_)
-{
- GtkTreeView *view;
- GtkTreeViewColumn *col;
- gint num;
- gchar *name;
-
- view = (GtkTreeView *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- col = (GtkTreeViewColumn *)g_object_get_data(G_OBJECT(view), E_MCAPTURE_COLUMNS_COLUMN_KEY);
- gtk_tree_view_column_set_visible(col, FALSE);
- num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(col), E_MCAPTURE_COLUMNS_COL_KEY));
- if ((name = col_index_to_name(num)) != NULL) {
- set_capture_column_visible(name, FALSE);
- if (!prefs.gui_use_pref_save) {
- prefs_main_write();
- }
- update_visible_columns_menu ();
- }
-}
-
-static const char *ui_desc_columns_menu_popup =
-"<ui>\n"
-" <popup name='ColumnsPopup' action='PopupAction'>\n"
-" <menuitem name='ColumnPreferences' action='/Column Preferences'/>\n"
-" <menu name='DisplayedColumns' action='/Displayed Columns'>\n"
-" <menuitem name='Display All' action='/Displayed Columns/Display All'/>\n"
-" </menu>\n"
-" <menuitem name='HideColumn' action='/Hide Column'/>\n"
-" </popup>\n"
-"</ui>\n";
-
-static const GtkActionEntry columns_menu_popup_action_entries[] = {
- { "/Column Preferences", GTK_STOCK_PREFERENCES, "Column Preferences...", NULL, NULL, G_CALLBACK(columns_pref_cb) },
- { "/Displayed Columns", NULL, "Displayed Columns", NULL, NULL, NULL },
- { "/Displayed Columns/Display All", NULL, "Display All", NULL, NULL, G_CALLBACK(columns_activate_all_columns_cb) },
- { "/Hide Column", NULL, "Hide Column", NULL, NULL, G_CALLBACK(columns_hide_col_cb) },
-};
-
-#ifdef HAVE_PCAP_CREATE
-static void
-activate_monitor(GtkTreeViewColumn *tree_column, GtkCellRenderer *renderer,
- GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
-#endif
-
-static void
-init_columns_menu(void)
-{
- GtkActionGroup *columns_action_group;
- GError *error = NULL;
-
- columns_menu_object = gtk_menu_new();
- /* columns pop-up menu */
- columns_action_group = gtk_action_group_new ("ColumnsPopUpMenuActionGroup");
-
- gtk_action_group_add_actions (columns_action_group, /* the action group */
- (const GtkActionEntry *)columns_menu_popup_action_entries, /* an array of action descriptions */
- G_N_ELEMENTS(columns_menu_popup_action_entries), /* the number of entries */
- columns_menu_object); /* data to pass to the action callbacks */
-
- ui_manager_columns = gtk_ui_manager_new ();
- gtk_ui_manager_insert_action_group (ui_manager_columns,
- columns_action_group,
- 0); /* the position at which the group will be inserted. */
-
- gtk_ui_manager_add_ui_from_string (ui_manager_columns, ui_desc_columns_menu_popup, -1, &error);
- if (error != NULL)
- {
- fprintf (stderr, "Warning: building Packet List Heading Pop-Up failed: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- g_object_set_data(G_OBJECT(columns_menu_object), PM_COLUMNS_KEY,
- gtk_ui_manager_get_widget(ui_manager_columns, "/ColumnsPopup"));
-
- popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_columns);
-}
-
-/* stop the currently running capture */
-void
-capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-#ifdef HAVE_AIRPCAP
- if (airpcap_if_active)
- airpcap_set_toolbar_stop_capture(airpcap_if_active);
-#endif
-
- capture_stop(&global_capture_session);
-}
-
-/* restart (stop - delete old file - start) running capture */
-void
-capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-#ifdef HAVE_AIRPCAP
- if (airpcap_if_active)
- airpcap_set_toolbar_start_capture(airpcap_if_active);
-#endif
-
- capture_restart(&global_capture_session);
-}
-
-enum cfc_state_t {
- CFC_PENDING,
- CFC_UNKNOWN,
- CFC_VALID,
- CFC_INVALID
-};
-
-typedef struct capture_filter_check {
- enum cfc_state_t state;
- gchar *filter_text;
- GtkWidget *filter_te;
- int dlt;
-} capture_filter_check_t;
-
-/* Valid states:
- *
- * Idle: filter_text = NULL, state = ?
- * Pending: filter_text != NULL, state = CFC_PENDING
- * Unknown: filter_text != NULL, state = CFC_UNKNOWN
- * Known: filter_text != NULL, state = CFC_VALID || CFC_INVALID
- *
- * We assume that only one text entry is active at a time.
- */
-
-/* We could make this smarter by caching results */
-static capture_filter_check_t cfc_data;
-
-static GMutex *pcap_compile_mtx;
-static GCond *cfc_data_cond;
-static GMutex *cfc_data_mtx;
-
-#if 0
-#define DEBUG_SYNTAX_CHECK(state1, state2) g_warning("CF state %s -> %s : %s", state1, state2, cfc_data.filter_text)
-#else
-#define DEBUG_SYNTAX_CHECK(state1, state2)
-#endif
-
-static void *
-check_capture_filter_syntax(void *data _U_) {
- struct bpf_program fcode;
- int pc_err;
-
- while (1) {
- g_mutex_lock(cfc_data_mtx);
- while (!cfc_data.filter_text || cfc_data.state != CFC_PENDING) {
- /* Do we really need to use a mutex here? We only have one thread... */
- g_cond_wait(cfc_data_cond, cfc_data_mtx);
- }
- cfc_data.state = CFC_UNKNOWN;
- DEBUG_SYNTAX_CHECK("pending", "unknown");
-
- g_mutex_unlock(cfc_data_mtx);
- g_mutex_lock(pcap_compile_mtx);
-
- /* pcap_compile_nopcap will not alter the filter string, so the (char *) cast is "safe" */
- pc_err = pcap_compile_nopcap(DUMMY_SNAPLENGTH /* use a dummy snaplength for syntax-checking */,
- cfc_data.dlt, &fcode, cfc_data.filter_text, 1 /* Do optimize */,
- DUMMY_NETMASK /* use a dummy netmask for syntax-checking */);
-
- g_mutex_unlock(pcap_compile_mtx);
- g_mutex_lock(cfc_data_mtx);
-
- if (cfc_data.state == CFC_UNKNOWN) { /* No more input came in */
- if (pc_err) {
- DEBUG_SYNTAX_CHECK("unknown", "known bad");
- cfc_data.state = CFC_INVALID;
- } else {
- DEBUG_SYNTAX_CHECK("unknown", "known good");
- cfc_data.state = CFC_VALID;
- }
- }
- g_mutex_unlock(cfc_data_mtx);
- }
- return NULL;
-}
-
-static gboolean
-update_capture_filter_te(gpointer data _U_) {
-
- g_mutex_lock(cfc_data_mtx);
-
- if (cfc_data.filter_text && cfc_data.filter_te) {
- if (cfc_data.state == CFC_VALID) {
- colorize_filter_te_as_valid(cfc_data.filter_te);
- } else if (cfc_data.state == CFC_INVALID) {
- colorize_filter_te_as_invalid(cfc_data.filter_te);
- } else {
- colorize_filter_te_as_empty(cfc_data.filter_te);
- }
-
- if (cfc_data.state == CFC_VALID || cfc_data.state == CFC_INVALID) {
- DEBUG_SYNTAX_CHECK("known", "idle");
- /* Reset the current state to idle. */
- if (cfc_data.filter_text != NULL) {
- g_free(cfc_data.filter_text);
- }
- cfc_data.filter_text = NULL;
- cfc_data.state = CFC_PENDING;
- }
- }
- g_mutex_unlock(cfc_data_mtx);
- return TRUE;
-}
-
-/** Initialize background capture filter syntax checking
- */
-void capture_filter_init(void) {
- cfc_data.filter_text = NULL;
- cfc_data.filter_te = NULL;
- cfc_data.state = CFC_PENDING;
-
-#if GLIB_CHECK_VERSION(2,31,0)
- pcap_compile_mtx = g_new(GMutex,1);
- g_mutex_init(pcap_compile_mtx);
- cfc_data_cond = g_new(GCond,1);
- g_cond_init(cfc_data_cond);
- cfc_data_mtx = g_new(GMutex,1);
- g_mutex_init(cfc_data_mtx);
- g_thread_new("Capture filter syntax", check_capture_filter_syntax, NULL);
-#else
- pcap_compile_mtx = g_mutex_new();
- cfc_data_cond = g_cond_new();
- cfc_data_mtx = g_mutex_new();
- g_thread_create(check_capture_filter_syntax, NULL, FALSE, NULL);
-#endif
-
- g_timeout_add(200, update_capture_filter_te, NULL);
-}
-
-static void
-update_filter_string(gchar *name, gchar *text)
-{
- GtkTreeIter iter;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- gchar *name_str;
-
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- gtk_tree_model_get_iter_first(model, &iter);
- do {
- gtk_tree_model_get(model, &iter, IFACE_HIDDEN_NAME, &name_str, -1);
- if (strcmp(name, name_str) == 0) {
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, FILTER, g_strdup(text), -1);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
-}
-
-static void
-capture_all_filter_check_syntax_cb(GtkWidget *w _U_, gpointer user_data _U_)
-{
- GtkWidget *filter_cm, *filter_te;
- gchar *filter_text = NULL;
- guint i;
-
- filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_ALL_CFILTER_CM_KEY);
-
- if (!filter_cm)
- return;
-
- filter_te = gtk_bin_get_child(GTK_BIN(filter_cm));
-
- if (!filter_te)
- return;
-
- if (global_capture_opts.num_selected > 0) {
- interface_t device;
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (!device.selected) {
- continue;
- }
- if (device.active_dlt == -1) {
- colorize_filter_te_as_empty(filter_te);
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device.name);
- continue; /* Programming error: somehow managed to select an "unsupported" entry */
- }
- /* Can't verify extcap capture filters */
- if (device.if_info.extcap != NULL && strlen(device.if_info.extcap) > 0)
- continue;
- filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
- if (strlen(filter_text) == 0) {
- colorize_filter_te_as_empty(filter_te);
- if (strlen(device.cfilter) > 0) {
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_free(device.cfilter);
- device.cfilter = g_strdup(filter_text);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- update_filter_string(device.name, filter_text);
- }
- g_free(filter_text);
- continue;
- }
- g_assert(filter_text != NULL);
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_free(device.cfilter);
- device.cfilter = g_strdup(filter_text);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- g_mutex_lock(cfc_data_mtx);
- /* Ruthlessly clobber the current state. */
- g_free(cfc_data.filter_text);
- cfc_data.dlt = device.active_dlt;
- cfc_data.filter_text = filter_text;
- cfc_data.filter_te = filter_te;
- cfc_data.state = CFC_PENDING;
- DEBUG_SYNTAX_CHECK("?", "pending");
- g_cond_signal(cfc_data_cond);
- g_mutex_unlock(cfc_data_mtx);
- update_filter_string(device.name, filter_text);
- }
- }
-}
-
-static void
-capture_filter_check_syntax_cb(GtkWidget *w _U_, gpointer user_data _U_)
-{
- GtkWidget *filter_cm, *filter_te, *linktype_combo_box;
- gchar *filter_text;
- gpointer dlt_ptr;
-
- filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(opt_edit_w), E_CFILTER_CM_KEY);
- if (!filter_cm)
- return;
- filter_te = gtk_bin_get_child(GTK_BIN(filter_cm));
- if (!filter_te)
- return;
-
- linktype_combo_box = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY);
-
- if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(linktype_combo_box), &dlt_ptr)) {
- /*
- * There is no guarantee that we will even know the list of link-layer
- * header types; we will not have it if, for example, we have a named
- * pipe rather than an interface, as a named pipe doesn't *have* a
- * link-layer header type until the capture is started and the
- * pcap file header or pcapng interface description block is
- * written, and we can't wait for that. We won't have it if we can't
- * open the interface, either.
- *
- * We also won't have an active pointer, even if we have the list of
- * link-layer header types, if none of the types are supported.
- *
- * Just mark it as empty, as a way of saying "damned if I know whether
- * this filter is valid".
- */
- colorize_filter_te_as_empty(filter_te);
- return;
- }
- if ((cfc_data.dlt = GPOINTER_TO_INT(dlt_ptr)) == -1) {
- g_assert_not_reached(); /* Programming error: somehow managed to select an "unsupported" entry */
- }
-
- filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
-
- if (strlen(filter_text) == 0) {
- colorize_filter_te_as_empty(filter_te);
- g_free(filter_text);
- return;
- }
-
- g_mutex_lock(cfc_data_mtx);
- /* Ruthlessly clobber the current state. */
- if (cfc_data.filter_text != NULL) {
- g_free(cfc_data.filter_text);
- }
- cfc_data.filter_text = filter_text;
- cfc_data.filter_te = filter_te;
- cfc_data.state = CFC_PENDING;
- DEBUG_SYNTAX_CHECK("?", "pending");
- g_cond_signal(cfc_data_cond);
- g_mutex_unlock(cfc_data_mtx);
-}
-
-static void
-capture_filter_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
-{
- g_mutex_lock(cfc_data_mtx);
- /* Reset the current state to idle. */
- if (cfc_data.filter_text != NULL) {
- g_free(cfc_data.filter_text);
- }
- cfc_data.filter_text = NULL;
- cfc_data.filter_te = NULL;
- cfc_data.state = CFC_PENDING;
- g_mutex_unlock(cfc_data_mtx);
-}
-
-#define TIME_UNIT_SECOND 0
-#define TIME_UNIT_MINUTE 1
-#define TIME_UNIT_HOUR 2
-#define TIME_UNIT_DAY 3
-#define MAX_TIME_UNITS 4
-static const char *time_unit_name[MAX_TIME_UNITS] = {
- "second(s)",
- "minute(s)",
- "hour(s)",
- "day(s)",
-};
-
-/* create one of the duration options */
-/* (and select the matching unit depending on the given value) */
-static GtkWidget *time_unit_combo_box_new(guint32 value) {
- GtkWidget *unit_combo_box;
- int i;
-
- unit_combo_box = gtk_combo_box_text_new ();
- for (i = 0; i < MAX_TIME_UNITS; i++) {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (unit_combo_box), time_unit_name[i]);
- }
- /* the selected combo_box item can't be changed, once the combo_box
- is created, so set the matching combo_box item now */
- /* days */
- if (value >= 60 * 60 * 24) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), TIME_UNIT_DAY);
- } else {
- /* hours */
- if (value >= 60 * 60) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), TIME_UNIT_HOUR);
- } else {
- /* minutes */
- if (value >= 60) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), TIME_UNIT_MINUTE);
- } else {
- /* seconds */
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), TIME_UNIT_SECOND);
- }
- }
- }
- return unit_combo_box;
-}
-
-/* convert time value from raw to displayed (e.g. 60s -> 1min) */
-static guint32 time_unit_combo_box_convert_value(
-guint32 value)
-{
- /* days */
- if (value >= 60 * 60 * 24) {
- return value / (60 * 60 * 24);
- }
-
- /* hours */
- if (value >= 60 * 60) {
- return value / (60 * 60);
- }
-
- /* minutes */
- if (value >= 60) {
- return value / 60;
- }
-
- /* seconds */
- return value;
-}
-
-/* get raw value from unit and value fields */
-static guint32 time_unit_combo_box_get_value(
-GtkWidget *unit_combo_box,
-guint32 value)
-{
- int unit;
-
- unit = gtk_combo_box_get_active (GTK_COMBO_BOX(unit_combo_box));
-
- switch(unit) {
- case(TIME_UNIT_SECOND):
- return value;
- case(TIME_UNIT_MINUTE):
- return value * 60;
- case(TIME_UNIT_HOUR):
- return value * 60 * 60;
- case(TIME_UNIT_DAY):
- return value * 60 * 60 * 24;
- default:
- g_assert_not_reached();
- return 0;
- }
-}
-
-
-#define SIZE_UNIT_KILOBYTES 0
-#define SIZE_UNIT_MEGABYTES 1
-#define SIZE_UNIT_GIGABYTES 2
-#define MAX_SIZE_UNITS 3
-static const char *size_unit_name[MAX_SIZE_UNITS] = {
- "kilobyte(s)",
- "megabyte(s)",
- "gigabyte(s)"
-};
-
-/* create one of the size options */
-/* (and select the matching unit depending on the given value) */
-static GtkWidget *size_unit_combo_box_new(guint32 value) {
- GtkWidget *unit_combo_box;
- int i;
-
- unit_combo_box=gtk_combo_box_text_new();
- for (i=0; i<MAX_SIZE_UNITS; i++){
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (unit_combo_box), size_unit_name[i]);
- }
- /* the selected combo_box item can't be changed, once the combo_box
- is created, so set the matching combo_box item now */
- /* gigabytes */
- if (value >= 1000 * 1000) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), SIZE_UNIT_GIGABYTES);
- } else {
- /* megabytes */
- if (value >= 1000) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), SIZE_UNIT_MEGABYTES);
- } else {
- /* kilobytes */
- gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), SIZE_UNIT_KILOBYTES);
- }
- }
- return unit_combo_box;
-}
-
-/* convert size value from raw to displayed (e.g. 1000 Bytes -> 1 kB) */
-static guint32 size_unit_combo_box_set_value(
-guint32 value)
-{
- /* gigabytes */
- if (value >= 1000 * 1000) {
- return value / (1000 * 1000);
- }
-
- /* megabytes */
- if (value >= 1000) {
- return value / (1000);
- }
-
- /* kilobytes */
- return value;
-}
-
-/* get raw value from unit and value fields */
-static guint32 size_unit_combo_box_convert_value(
- GtkWidget *unit_combo_box,
-guint32 value)
-{
- int unit;
-
- unit = gtk_combo_box_get_active (GTK_COMBO_BOX(unit_combo_box));
-
- switch(unit) {
- case(SIZE_UNIT_KILOBYTES):
- if (value > (((guint32)G_MAXINT + 1) / 1000)) {
- return 0;
- } else {
- return value;
- }
- case(SIZE_UNIT_MEGABYTES):
- if (value > (((guint32)G_MAXINT + 1) / (1000 * 1000))) {
- return 0;
- } else {
- return value * 1000;
- }
- case(SIZE_UNIT_GIGABYTES):
- if (value > (((guint32)G_MAXINT + 1) / (1000 * 1000 * 1000))) {
- return 0;
- } else {
- return value * 1000 * 1000;
- }
- default:
- g_assert_not_reached();
- return 0;
- }
-}
-
-#ifdef HAVE_AIRPCAP
-/*
- * Sets the toolbar before calling the advanced dialog with for the right interface
- */
-static void
-options_airpcap_advanced_cb(GtkWidget *w, gpointer d)
-{
- int *from_widget;
-
- from_widget = (gint*)g_malloc(sizeof(gint));
- *from_widget = AIRPCAP_ADVANCED_FROM_OPTIONS;
- g_object_set_data(G_OBJECT(wireless_tb),AIRPCAP_ADVANCED_FROM_KEY,from_widget);
-
- airpcap_if_active = airpcap_if_selected;
- airpcap_enable_toolbar_widgets(wireless_tb,FALSE);
- display_airpcap_advanced_cb(w,d);
-}
-#endif
-
-#ifdef HAVE_PCAP_REMOTE
-#if 0
-/* PCAP interface type menu item */
-struct iftype_info {
- capture_source id;
- const char *name;
-};
-
-/* List of available types of PCAP interface */
-static struct iftype_info iftype[] = {
- { CAPTURE_IFLOCAL, "Local" },
- { CAPTURE_IFREMOTE, "Remote..." }
-};
-
-#define REMOTE_HOST_START ((sizeof(iftype) / sizeof(iftype[0])) + 1)
-#else
-#define REMOTE_HOST_START 3
-#endif
-#define REMOTE_HOST_SEPARATOR "---"
-
-static void
-iftype_combo_box_add_remote_separators (GtkWidget *iftype_cbx)
-{
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(iftype_cbx), REMOTE_HOST_SEPARATOR);
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(iftype_cbx), "Clear list");
-}
-
-#if 0
-static void
-iftype_combo_box_add (GtkWidget *iftype_cbx, interface_t *device)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean create_new = FALSE;
- gchar *string;
- guint pos = REMOTE_HOST_START;
- struct remote_host *rh;
-
- rh = recent_get_remote_host(device->remote_opts.remote_host_opts.remote_host);
- if (!rh) {
- rh = (struct remote_host *)g_malloc0 (sizeof (*rh));
- if (recent_get_remote_host_list_size() == 0) {
- iftype_combo_box_add_remote_separators (iftype_cbx);
- }
- gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(iftype_cbx), pos, device->remote_opts.remote_host_opts.remote_host);
- rh->r_host = g_strdup (device->remote_opts.remote_host_opts.remote_host);
- create_new = TRUE;
- } else {
- model = (GtkTreeModel *)gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cbx));
- if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) {
- while (gtk_tree_model_iter_next(model, &iter)) {
- gtk_tree_model_get(model, &iter, 0, &string, -1);
- if (string) {
- if (strcmp (device->remote_opts.remote_host_opts.remote_host, string) == 0) {
- /* Found match, show this position in combo box */
- g_free (string);
- break;
- }
- g_free (string);
- }
- pos++;
- }
- }
-
- g_free (rh->remote_port);
- g_free (rh->auth_username);
- g_free (rh->auth_password);
- }
-
- rh->remote_port = g_strdup (device->remote_opts.remote_host_opts.remote_port);
- rh->auth_type = device->remote_opts.remote_host_opts.auth_type;
- rh->auth_username = g_strdup (device->remote_opts.remote_host_opts.auth_username);
- rh->auth_password = g_strdup (device->remote_opts.remote_host_opts.auth_password);
-
- if (create_new) {
- recent_add_remote_host(g_strdup (device->remote_opts.remote_host_opts.remote_host), rh);
- }
-
- g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(1));
- gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cbx), pos);
- g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(0));
-}
-#endif
-
-static void
-iftype_combo_box_add_remote_host (gpointer key, gpointer value _U_, gpointer user_data)
-{
- gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(user_data), REMOTE_HOST_START, (const char *)key);
-}
-
-/* Fill the menu of available types of interfaces */
-static GtkWidget *
-iftype_combo_box_new(void)
-{
- GtkWidget *iftype_cbx;
-
- iftype_cbx = gtk_combo_box_text_new_with_entry();
-
- if (recent_get_remote_host_list_size() > 0) {
- /* Add remote hosts */
- recent_remote_host_list_foreach (iftype_combo_box_add_remote_host, iftype_cbx);
- iftype_combo_box_add_remote_separators (iftype_cbx);
- }
-
- g_signal_connect(iftype_cbx, "changed", G_CALLBACK(select_if_type_cb), NULL);
-
- return iftype_cbx;
-}
-
-#if 0
-static gboolean
-iftype_combo_is_separator (GtkTreeModel *model, GtkTreeIter *iter, gpointer data _U_)
-{
- gboolean result = FALSE;
- gchar *string;
-
- gtk_tree_model_get(model, iter, 0, &string, -1);
- if (string) {
- result = !strcmp (string, REMOTE_HOST_SEPARATOR);
- g_free (string);
- }
-
- return result;
-
-}
-#endif
-#endif
-
-#ifdef HAVE_PCAP_REMOTE
-static void
-error_list_remote_interface_cb (gpointer dialog _U_, gint btn _U_, gpointer data)
-{
- capture_remote_cb(GTK_WIDGET(data), FALSE);
-}
-
-static void
-insert_new_rows(GList *rlist)
-{
- GtkTreeIter iter;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- char *snaplen_string;
- gchar *link_type_name = NULL;
- char *temp = NULL;
-
- GList *if_entry, *lt_entry;
- if_info_t *if_info;
- char *if_string = NULL;
- gchar *descr, *auth_str;
- if_capabilities_t *caps;
- gint linktype_count;
- gboolean monitor_mode, found = FALSE;
- GSList *curr_addr;
- int ips = 0;
- guint i;
- if_addr_t *addr;
- data_link_info_t *data_link_info;
- GString *ip_str;
- link_row *linkr = NULL;
- interface_t device;
- guint num_interfaces;
- remote_options *roptions;
-
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
-
- roptions = &global_remote_opts;
- /* Scan through the list and build a list of strings to display. */
- num_interfaces = global_capture_opts.all_ifaces->len;
- for (if_entry = g_list_first(rlist); if_entry != NULL; if_entry = g_list_next(if_entry)) {
- auth_str = NULL;
- if_info = (if_info_t *)if_entry->data;
- add_interface_to_remote_list(if_info);
- for (i = 0; i < num_interfaces; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(device.name, if_info->name) == 0) {
- found = TRUE;
- break;
- }
- }
- if (found) {
- found = FALSE;
- continue;
- }
- ip_str = g_string_new("");
- ips = 0;
- memset(&device, 0, sizeof(device));
- device.name = g_strdup(if_info->name);
- device.if_info.name = g_strdup("Don't crash on bug 13448");
- /* Is this interface hidden and, if so, should we include it
- anyway? */
- descr = capture_dev_user_descr_find(if_info->name);
- if (descr != NULL) {
- /* Yes, we have a user-supplied description; use it. */
- if_string = g_strdup_printf("%s: %s", descr, if_info->name);
- g_free(descr);
- } else {
- /* No, we don't have a user-supplied description; did we get
- one from the OS or libpcap? */
- if (if_info->vendor_description != NULL) {
- /* Yes - use it. */
- if_string = g_strdup_printf("%s: %s", if_info->vendor_description, if_info->name);
- } else {
- /* No. */
- if_string = g_strdup(if_info->name);
- }
- } /* else descr != NULL */
- if (if_info->loopback) {
- device.display_name = g_strdup_printf("%s (loopback)", if_string);
- } else {
- device.display_name = g_strdup(if_string);
- }
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- if ((device.buffer = capture_dev_user_buffersize_find(if_string)) == -1) {
- device.buffer = global_capture_opts.default_options.buffer_size;
- }
-#endif
- if (!capture_dev_user_pmode_find(if_string, &device.pmode)) {
- device.pmode = global_capture_opts.default_options.promisc_mode;
- }
- if (!capture_dev_user_snaplen_find(if_string, &device.has_snaplen,
- &device.snaplen)) {
- device.has_snaplen = global_capture_opts.default_options.has_snaplen;
- device.snaplen = global_capture_opts.default_options.snaplen;
- }
- device.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
- device.timestamp_type = g_strdup(global_capture_opts.default_options.timestamp_type);
- monitor_mode = prefs_capture_device_monitor_mode(if_string);
- if (roptions->remote_host_opts.auth_type == CAPTURE_AUTH_PWD) {
- auth_str = g_strdup_printf("%s:%s", roptions->remote_host_opts.auth_username,
- roptions->remote_host_opts.auth_password);
- }
- caps = capture_get_if_capabilities(if_string, monitor_mode, auth_str, NULL, main_window_update);
- g_free(auth_str);
- for (; (curr_addr = g_slist_nth(if_info->addrs, ips)) != NULL; ips++) {
- address addr_str;
- char* temp_addr_str = NULL;
- if (ips != 0) {
- g_string_append(ip_str, "\n");
- }
- addr = (if_addr_t *)curr_addr->data;
- switch (addr->ifat_type) {
- case IF_AT_IPv4:
- set_address(&addr_str, AT_IPv4, 4, &addr->addr.ip4_addr);
- temp_addr_str = (char*)address_to_str(NULL, &addr_str);
- g_string_append(ip_str, temp_addr_str);
- break;
- case IF_AT_IPv6:
- set_address(&addr_str, AT_IPv6, 16, addr->addr.ip6_addr);
- temp_addr_str = (char*)address_to_str(NULL, &addr_str);
- g_string_append(ip_str, temp_addr_str);
- break;
- default:
- /* In case we add non-IP addresses */
- break;
- }
-
- wmem_free(NULL, temp_addr_str);
- } /* for curr_addr */
- linktype_count = 0;
- device.links = NULL;
- if (caps != NULL) {
-#ifdef HAVE_PCAP_CREATE
- device.monitor_mode_enabled = monitor_mode;
- device.monitor_mode_supported = caps->can_set_rfmon;
-#endif
- for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
- data_link_info = (data_link_info_t *)lt_entry->data;
- linkr = (link_row *)g_malloc(sizeof(link_row));
- /*
- * For link-layer types libpcap/WinPcap doesn't know about, the
- * name will be "DLT n", and the description will be null.
- * We mark those as unsupported, and don't allow them to be
- * used.
- */
- if (data_link_info->description != NULL) {
- linkr->name = g_strdup(data_link_info->description);
- linkr->dlt = data_link_info->dlt;
- } else {
- linkr->name = g_strdup_printf("%s (not supported)", data_link_info->name);
- linkr->dlt = -1;
- }
- if (linktype_count == 0) {
- device.active_dlt = data_link_info->dlt;
- }
- device.links = g_list_append(device.links, linkr);
- linktype_count++;
- } /* for link_types */
- } else {
-#if defined(HAVE_PCAP_CREATE)
- device.monitor_mode_enabled = FALSE;
- device.monitor_mode_supported = FALSE;
-#endif
- device.active_dlt = -1;
- }
- device.addresses = g_strdup(ip_str->str);
- device.no_addresses = ips;
- device.remote_opts.src_type = roptions->src_type;
- if (device.remote_opts.src_type == CAPTURE_IFREMOTE) {
- device.local = FALSE;
- }
- device.remote_opts.remote_host_opts.remote_host = g_strdup(roptions->remote_host_opts.remote_host);
- device.remote_opts.remote_host_opts.remote_port = g_strdup(roptions->remote_host_opts.remote_port);
- device.remote_opts.remote_host_opts.auth_type = roptions->remote_host_opts.auth_type;
- device.remote_opts.remote_host_opts.auth_username = g_strdup(roptions->remote_host_opts.auth_username);
- device.remote_opts.remote_host_opts.auth_password = g_strdup(roptions->remote_host_opts.auth_password);
- device.remote_opts.remote_host_opts.datatx_udp = roptions->remote_host_opts.datatx_udp;
- device.remote_opts.remote_host_opts.nocap_rpcap = roptions->remote_host_opts.nocap_rpcap;
- device.remote_opts.remote_host_opts.nocap_local = roptions->remote_host_opts.nocap_local;
-#ifdef HAVE_PCAP_SETSAMPLING
- device.remote_opts.sampling_method = roptions->sampling_method;
- device.remote_opts.sampling_param = roptions->sampling_param;
-#endif
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- g_array_append_val(global_capture_opts.all_ifaces, device);
- g_string_free(ip_str, TRUE);
-
- if (caps == NULL) {
- link_type_name = g_strdup("default");
- } else {
- data_link_info = (data_link_info_t *)caps->data_link_types->data;
- if (data_link_info->description != NULL) {
- link_type_name = g_strdup(data_link_info->description);
- } else {
- link_type_name = g_strdup_printf("%s (not supported)", data_link_info->name);
- }
- }
- if (ips == 0) {
- temp = g_strdup_printf("<b>%s</b>", device.display_name);
- } else {
- temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
- }
- snaplen_string = g_strdup_printf("%d", device.snaplen);
-
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
-#if defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, BUFFER, device.buffer, MONITOR, "no",FILTER, "",-1);
-#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, BUFFER, device.buffer, FILTER, "",-1);
- #else
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, -1);
-#endif
- add_interface_to_list(global_capture_opts.all_ifaces->len-1);
- } /*for*/
- gtk_tree_view_set_model(GTK_TREE_VIEW(if_cb), model);
-}
-#endif
-
-#ifdef HAVE_PCAP_REMOTE
-static void
-populate_existing_remotes(gpointer key, gpointer value, gpointer user_data _U_)
-{
- const gchar *host = (const gchar *)key;
- struct remote_host *remote_host = (struct remote_host *)value;
- GList *if_list;
- int err;
- gchar *err_str;
-
- g_free(global_remote_opts.remote_host_opts.remote_host);
- g_free(global_remote_opts.remote_host_opts.remote_port);
- g_free(global_remote_opts.remote_host_opts.auth_username);
- g_free(global_remote_opts.remote_host_opts.auth_password);
- global_remote_opts.src_type = CAPTURE_IFREMOTE;
- global_remote_opts.remote_host_opts.remote_host = g_strdup(host);
- global_remote_opts.remote_host_opts.remote_port = g_strdup(remote_host->remote_port);
- global_remote_opts.remote_host_opts.auth_type = remote_host->auth_type;
- global_remote_opts.remote_host_opts.auth_username = g_strdup(remote_host->auth_username);
- global_remote_opts.remote_host_opts.auth_password = g_strdup(remote_host->auth_password);
- global_remote_opts.remote_host_opts.datatx_udp = FALSE;
- global_remote_opts.remote_host_opts.nocap_rpcap = TRUE;
- global_remote_opts.remote_host_opts.nocap_local = FALSE;
-#ifdef HAVE_PCAP_SETSAMPLING
- global_remote_opts.sampling_method = CAPTURE_SAMP_NONE;
- global_remote_opts.sampling_param = 0;
-#endif
-
- if_list = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
- global_remote_opts.remote_host_opts.remote_port,
- global_remote_opts.remote_host_opts.auth_type,
- global_remote_opts.remote_host_opts.auth_username,
- global_remote_opts.remote_host_opts.auth_password,
- &err, &err_str);
- if (if_list != NULL) {
- /* New remote interface */
- insert_new_rows(if_list);
- refresh_non_local_interface_lists();
- }
-}
-
-
-/* Retrieve the list of remote interfaces according to selected
- * options and re-fill interface name combobox */
-static void
-update_remote_interface_list(void)
-{
- GtkWidget *iftype_cbx;
- GList *if_list;
- int err;
- gchar *err_str;
-
- if (cap_open_w == NULL)
- return;
- iftype_cbx = (GtkWidget *)g_object_get_data(G_OBJECT(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY)), E_REMOTE_HOST_TE_KEY);
- if_list = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
- global_remote_opts.remote_host_opts.remote_port,
- global_remote_opts.remote_host_opts.auth_type,
- global_remote_opts.remote_host_opts.auth_username,
- global_remote_opts.remote_host_opts.auth_password,
- &err, &err_str);
- if (if_list == NULL &&
- (err == CANT_GET_INTERFACE_LIST || err == DONT_HAVE_PCAP)) {
- gpointer dialog = simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
- g_free(err_str);
-
- /* Fall back to previous interface list */
- simple_dialog_set_cb(dialog, error_list_remote_interface_cb, iftype_cbx);
- return;
- } else {
- /* New remote interface */
- insert_new_rows(if_list);
- refresh_non_local_interface_lists();
- }
-}
-
-/* User changed an interface entry of "Remote interface" dialog */
-static void
-capture_remote_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
-{
- GtkWidget *auth_passwd_rb,
- *username_lb, *username_te,
- *passwd_lb, *passwd_te;
- gboolean state;
-
- auth_passwd_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
- E_REMOTE_AUTH_PASSWD_KEY);
- username_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
- E_REMOTE_USERNAME_LB_KEY);
- username_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
- E_REMOTE_USERNAME_TE_KEY);
- passwd_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_REMOTE_PASSWD_LB_KEY);
- passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_REMOTE_PASSWD_TE_KEY);
-
- state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_passwd_rb));
- gtk_widget_set_sensitive(GTK_WIDGET(username_lb), state);
- gtk_widget_set_sensitive(GTK_WIDGET(username_te), state);
- gtk_widget_set_sensitive(GTK_WIDGET(passwd_lb), state);
- gtk_widget_set_sensitive(GTK_WIDGET(passwd_te), state);
-}
-
-
-/* user requested to accept remote interface options */
-static void
-capture_remote_ok_cb(GtkWidget *win _U_, GtkWidget *remote_w)
-{
- GtkWidget *host_te, *port_te, *username_te, *passwd_te, *auth_passwd_rb;
- gchar *hostname;
- struct remote_host *rh;
-
- if (remote_w == NULL) {
- return;
- }
-
- host_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY);
- hostname = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(host_te));
- port_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY);
- username_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w),
- E_REMOTE_USERNAME_TE_KEY);
- passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY);
- auth_passwd_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY);
- g_free(global_remote_opts.remote_host_opts.remote_host);
- global_remote_opts.remote_host_opts.remote_host = hostname;
- g_free(global_remote_opts.remote_host_opts.remote_port);
- global_remote_opts.remote_host_opts.remote_port = g_strdup(gtk_entry_get_text(GTK_ENTRY(port_te)));
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_passwd_rb)))
- global_remote_opts.remote_host_opts.auth_type = CAPTURE_AUTH_PWD;
- else
- global_remote_opts.remote_host_opts.auth_type = CAPTURE_AUTH_NULL;
- g_free(global_remote_opts.remote_host_opts.auth_username);
- global_remote_opts.remote_host_opts.auth_username =
- g_strdup(gtk_entry_get_text(GTK_ENTRY(username_te)));
-
- g_free(global_remote_opts.remote_host_opts.auth_password);
- global_remote_opts.remote_host_opts.auth_password =
- g_strdup(gtk_entry_get_text(GTK_ENTRY(passwd_te)));
-
- rh = (struct remote_host *)g_malloc (sizeof (*rh));
- rh->r_host = g_strdup(global_remote_opts.remote_host_opts.remote_host);
- rh->remote_port = g_strdup(global_remote_opts.remote_host_opts.remote_port);
- rh->auth_type = global_remote_opts.remote_host_opts.auth_type;
- rh->auth_password = g_strdup("");
- rh->auth_username = g_strdup("");
-
- recent_add_remote_host(hostname, rh);
-
- update_remote_interface_list();
- fill_remote_list();
- window_destroy(GTK_WIDGET(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY)));
-}
-
-static void
-capture_remote_cancel_cb(GtkWidget *win, gpointer data)
-{
- window_cancel_button_cb (win, data);
-}
-
-static void
-select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data _U_)
-{
- gchar *string;
- GtkWidget *port_te, *auth_rb, *user_te, *pass_te;
- GtkWidget *remote_w;
- struct remote_host *rh;
-
- int new_iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cbx));
- gint num_remote = recent_get_remote_host_list_size();
-
- if (new_iftype != -1 && new_iftype == num_remote+1) {
- recent_free_remote_host_list();
- num_remote += 2;
- while (num_remote--) { /* Remove separator lines and "Clear" item */
- gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT(iftype_cbx), num_remote);
- }
- remote_w = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
- window_destroy(GTK_WIDGET(remote_w));
- capture_remote_cb(GTK_WIDGET(iftype_cbx), FALSE);
- } else {
- string = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(iftype_cbx));
- rh = recent_get_remote_host(string);
- g_free (string);
- if (rh) {
- remote_w = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
- port_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY);
- gtk_entry_set_text(GTK_ENTRY(port_te), rh->remote_port);
- auth_rb = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY);
- if (rh->auth_type == CAPTURE_AUTH_PWD) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_rb), TRUE);
- } else {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_rb), FALSE);
- }
- user_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_TE_KEY);
- gtk_entry_set_text(GTK_ENTRY(user_te), rh->auth_username);
- pass_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY);
- gtk_entry_set_text(GTK_ENTRY(pass_te), rh->auth_password);
- }
- }
-}
-
-/* Show remote capture interface parameters dialog */
-static void
-capture_remote_cb(GtkWidget *w _U_, gboolean focus_username)
-{
- GtkWidget *remote_w,
- *main_vb, *host_grid,
- *host_lb, *host_te, *port_lb, *port_te,
- *auth_fr, *auth_vb,
- *auth_null_rb, *auth_passwd_rb, *auth_passwd_grid,
- *user_lb, *user_te, *passwd_lb, *passwd_te,
- *bbox, *ok_but, *cancel_bt;
- gchar *title;
- GSList *auth_group;
-
- title = create_user_window_title("Wireshark: Remote Interface");
- remote_w = dlg_window_new(title);
- gtk_window_set_transient_for(GTK_WINDOW(remote_w), GTK_WINDOW(interface_management_w));
- g_object_set_data(G_OBJECT(remote_w), E_CAP_REMOTE_CALLER_PTR_KEY, interface_management_w);
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY, remote_w);
- g_free(title);
-
- main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
- gtk_container_add(GTK_CONTAINER(remote_w), main_vb);
-
- /* Host/port table */
- host_grid = ws_gtk_grid_new();
- ws_gtk_grid_set_row_spacing(GTK_GRID(host_grid), DLG_LABEL_SPACING);
- ws_gtk_grid_set_column_spacing(GTK_GRID(host_grid), DLG_UNRELATED_SPACING);
- gtk_box_pack_start(GTK_BOX(main_vb), host_grid, FALSE, FALSE, 0);
-
- /* Host row */
- host_lb = gtk_label_new("Host:");
- ws_gtk_grid_attach_defaults(GTK_GRID (host_grid), host_lb, 0, 0, 1, 1);
-
- host_te = iftype_combo_box_new();
- ws_gtk_grid_attach_defaults(GTK_GRID (host_grid), host_te, 1, 0, 1, 1);
-
- /* Port row */
- port_lb = gtk_label_new("Port:");
- ws_gtk_grid_attach_defaults(GTK_GRID (host_grid), port_lb, 0, 1, 1, 1);
-
- port_te = gtk_entry_new();
- gtk_widget_set_tooltip_text(port_te, "Enter the TCP port number used by RPCAP server at remote host "
- "(leave it empty for default port number).");
- ws_gtk_grid_attach_defaults(GTK_GRID (host_grid), port_te, 1, 1, 1, 1);
-
- /* Authentication options frame */
- auth_fr = gtk_frame_new("Authentication");
- gtk_box_pack_start(GTK_BOX (main_vb), auth_fr, TRUE, TRUE, 0);
-
- auth_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(auth_vb), 5);
- gtk_container_add(GTK_CONTAINER(auth_fr), auth_vb);
-
- auth_null_rb = gtk_radio_button_new_with_label(NULL,
- "Null authentication");
- gtk_box_pack_start(GTK_BOX(auth_vb), auth_null_rb, TRUE, TRUE, 0);
-
- auth_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(auth_null_rb));
- auth_passwd_rb = gtk_radio_button_new_with_label(auth_group,
- "Password authentication");
- gtk_box_pack_start(GTK_BOX(auth_vb), auth_passwd_rb, TRUE, TRUE, 0);
- g_signal_connect(auth_passwd_rb, "toggled",
- G_CALLBACK(capture_remote_adjust_sensitivity), remote_w);
-
- auth_passwd_grid = ws_gtk_grid_new();
- ws_gtk_grid_set_row_spacing(GTK_GRID(auth_passwd_grid), DLG_LABEL_SPACING);
- ws_gtk_grid_set_column_spacing(GTK_GRID(auth_passwd_grid), DLG_UNRELATED_SPACING);
-
- gtk_box_pack_start(GTK_BOX(auth_vb), auth_passwd_grid, FALSE, FALSE, 0);
-
- user_lb = gtk_label_new("Username:");
- ws_gtk_grid_attach_defaults(GTK_GRID (auth_passwd_grid), user_lb, 0, 0, 1, 1);
-
- user_te = gtk_entry_new();
- ws_gtk_grid_attach_defaults(GTK_GRID (auth_passwd_grid), user_te, 1, 0, 1, 1);
-
- passwd_lb = gtk_label_new("Password:");
- ws_gtk_grid_attach_defaults(GTK_GRID (auth_passwd_grid), passwd_lb, 0, 1, 1, 1);
-
- passwd_te = gtk_entry_new();
- gtk_entry_set_visibility(GTK_ENTRY(passwd_te), FALSE);
- ws_gtk_grid_attach_defaults(GTK_GRID (auth_passwd_grid), passwd_te, 1, 1, 1, 1);
-
- /* Button row: "OK" and "Cancel" buttons */
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
- gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
-
- ok_but = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- gtk_widget_set_can_default(ok_but, TRUE);
- g_signal_connect(ok_but, "clicked", G_CALLBACK(capture_remote_ok_cb), remote_w);
- gtk_widget_set_tooltip_text(ok_but,
- "Accept remote host parameters and lookup "
- "remote interfaces.");
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_OK_BT_KEY, ok_but);
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
- gtk_widget_set_tooltip_text(cancel_bt, "Cancel and exit dialog.");
- window_set_cancel_button(remote_w, cancel_bt, capture_remote_cancel_cb);
-
- if (focus_username) {
- /* Give the initial focus to the "Username" entry box. */
- gtk_widget_grab_focus(user_te);
- }
-
- gtk_widget_grab_default(ok_but);
-
- /* Catch the "activate" signal on the text
- entries, so that if the user types Return there, we act as if the
- "OK" button had been selected, as happens if Return is typed if some
- widget that *doesn't* handle the Return key has the input focus. */
- dlg_set_activate(port_te, ok_but);
- dlg_set_activate(user_te, ok_but);
- dlg_set_activate(passwd_te, ok_but);
-
- g_signal_connect(remote_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
-
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY, host_te);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY, port_te);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_AUTH_NULL_KEY, auth_null_rb);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY, auth_passwd_rb);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_LB_KEY, user_lb);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_TE_KEY, user_te);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_LB_KEY, passwd_lb);
- g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY, passwd_te);
-
- if (global_remote_opts.remote_host_opts.auth_type == CAPTURE_AUTH_PWD)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_passwd_rb), TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_null_rb), TRUE);
- capture_remote_adjust_sensitivity(NULL, remote_w);
-
- gtk_widget_show_all(remote_w);
- window_present(remote_w);
-}
-
-/* user requested to destroy the dialog */
-static void
-options_remote_destroy_cb(GtkWidget *win, gpointer user_data _U_)
-{
- GtkWidget *caller;
-
- caller = (GtkWidget *)g_object_get_data(G_OBJECT(win), E_OPT_REMOTE_CALLER_PTR_KEY);
- g_object_set_data(G_OBJECT(caller), E_OPT_REMOTE_DIALOG_PTR_KEY, NULL);
-}
-
-/* user requested to accept remote interface options */
-static void
-options_remote_ok_cb(GtkWidget *win _U_, GtkWidget *parent_w)
-{
- GtkWidget *datatx_udp_cb, *nocap_rpcap_cb;
-#ifdef HAVE_PCAP_SETSAMPLING
- GtkWidget *samp_none_rb, *samp_count_rb, *samp_timer_rb,
- *samp_count_sb, *samp_timer_sb;
-#endif
- interface_t device;
-
- if (parent_w == NULL)
- return;
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
- g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
- datatx_udp_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_DATATX_UDP_CB_KEY);
- nocap_rpcap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_NOCAP_RPCAP_CB_KEY);
-
- device.remote_opts.remote_host_opts.datatx_udp =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(datatx_udp_cb));
- device.remote_opts.remote_host_opts.nocap_rpcap =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb));
-
-#ifdef HAVE_PCAP_SETSAMPLING
- samp_none_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_NONE_RB_KEY);
- samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
- samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
- samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
- samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_none_rb)))
- device.remote_opts.sampling_method = CAPTURE_SAMP_NONE;
- else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb))) {
- device.remote_opts.sampling_method = CAPTURE_SAMP_BY_COUNT;
- device.remote_opts.sampling_param = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(samp_count_sb));
- } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb))) {
- device.remote_opts.sampling_method = CAPTURE_SAMP_BY_TIMER;
- device.remote_opts.sampling_param = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(samp_timer_sb));
- }
-#endif /* HAVE_PCAP_SETSAMPLING*/
- g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
- window_destroy(GTK_WIDGET(parent_w));
-}
-#endif /*HAVE_PCAP_REMOTE*/
-
-#ifdef HAVE_PCAP_SETSAMPLING
-static void
-options_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
-{
- GtkWidget *samp_count_rb, *samp_timer_rb,
- *samp_count_sb, *samp_timer_sb;
-
- samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
- samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
- samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
- samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
-
- if (samp_count_sb && samp_count_rb)
- gtk_widget_set_sensitive(GTK_WIDGET(samp_count_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)));
-
- if (samp_timer_sb && samp_timer_rb)
- gtk_widget_set_sensitive(GTK_WIDGET(samp_timer_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)));
-}
-
-#endif /*HAVE_PCAP_SETSAMPLING*/
-#ifdef HAVE_PCAP_REMOTE
-static void
-options_remote_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- GtkWidget *opt_remote_w, *main_vb;
- GtkWidget *caller, *bbox, *ok_but, *cancel_bt;
- GtkWidget *capture_fr, *capture_vb;
- GtkWidget *nocap_rpcap_cb, *datatx_udp_cb;
-#ifdef HAVE_PCAP_SETSAMPLING
- GtkWidget *sampling_fr, *sampling_vb, *sampling_grid, *sampling_lb,
- *samp_none_rb, *samp_count_rb, *samp_timer_rb,
- *samp_count_sb, *samp_timer_sb;
- GtkAdjustment *samp_count_adj, *samp_timer_adj;
- GSList *samp_group;
-#endif
- interface_t device;
-
- caller = gtk_widget_get_toplevel(w);
- opt_remote_w = (GtkWidget *)g_object_get_data(G_OBJECT(caller), E_OPT_REMOTE_DIALOG_PTR_KEY);
- if (opt_remote_w != NULL) {
- reactivate_window(opt_remote_w);
- return;
- }
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
- opt_remote_w = dlg_window_new("Remote Capture Settings");
- gtk_window_set_modal(GTK_WINDOW(opt_remote_w), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(opt_remote_w), GTK_WINDOW(caller));
- gtk_window_set_type_hint(GTK_WINDOW(opt_remote_w), GDK_WINDOW_TYPE_HINT_DIALOG);
-
- g_object_set_data(G_OBJECT(opt_remote_w), E_OPT_REMOTE_CALLER_PTR_KEY, caller);
- g_object_set_data(G_OBJECT(caller), E_OPT_REMOTE_DIALOG_PTR_KEY, opt_remote_w);
-
- main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
- gtk_container_add(GTK_CONTAINER(opt_remote_w), main_vb);
-
- /* Remote capture options */
- capture_fr = gtk_frame_new("Capture Options");
- gtk_box_pack_start(GTK_BOX (main_vb), capture_fr, TRUE, TRUE, 0);
-
- capture_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(capture_vb), 5);
- gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
-
- nocap_rpcap_cb = gtk_check_button_new_with_mnemonic("Do not capture own RPCAP traffic");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb),
- device.remote_opts.remote_host_opts.nocap_rpcap);
- gtk_box_pack_start(GTK_BOX (capture_vb), nocap_rpcap_cb, TRUE, TRUE, 0);
-
- datatx_udp_cb = gtk_check_button_new_with_mnemonic("Use UDP for data transfer");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(datatx_udp_cb),
- device.remote_opts.remote_host_opts.datatx_udp);
- gtk_box_pack_start(GTK_BOX (capture_vb), datatx_udp_cb, TRUE, TRUE, 0);
-
-
-#ifdef HAVE_PCAP_SETSAMPLING
- /* Sampling options */
- sampling_fr = gtk_frame_new("Sampling Options");
- gtk_box_pack_start(GTK_BOX (main_vb), sampling_fr, TRUE, TRUE, 0);
-
- sampling_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(sampling_vb), 5);
- gtk_container_add(GTK_CONTAINER(sampling_fr), sampling_vb);
-
- sampling_grid = ws_gtk_grid_new();
- ws_gtk_grid_set_row_spacing(GTK_GRID(sampling_grid), DLG_LABEL_SPACING);
- ws_gtk_grid_set_column_spacing(GTK_GRID(sampling_grid), DLG_UNRELATED_SPACING);
- gtk_box_pack_start(GTK_BOX(sampling_vb), sampling_grid, FALSE, FALSE, 0);
-
- /* "No sampling" row */
- samp_none_rb = gtk_radio_button_new_with_label(NULL, "None");
- if (device.remote_opts.sampling_method == CAPTURE_SAMP_NONE)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb), TRUE);
- g_signal_connect(samp_none_rb, "toggled",
- G_CALLBACK(options_prep_adjust_sensitivity), opt_remote_w);
- ws_gtk_grid_attach_defaults(GTK_GRID (sampling_grid), samp_none_rb, 0, 0, 1, 1);
-
- /* "Sampling by counter" row */
- samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_none_rb));
- samp_count_rb = gtk_radio_button_new_with_label(samp_group, "1 of");
- if (device.remote_opts.sampling_method == CAPTURE_SAMP_BY_COUNT)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_count_rb), TRUE);
- g_signal_connect(samp_count_rb, "toggled",
- G_CALLBACK(options_prep_adjust_sensitivity), opt_remote_w);
- ws_gtk_grid_attach_defaults(GTK_GRID (sampling_grid), samp_count_rb, 0, 1, 1, 1);
-
- samp_count_adj = (GtkAdjustment *) gtk_adjustment_new(
- (gfloat)device.remote_opts.sampling_param,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- samp_count_sb = gtk_spin_button_new(samp_count_adj, 0, 0);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_count_sb), TRUE);
- ws_gtk_grid_attach_defaults(GTK_GRID (sampling_grid), samp_count_sb, 1, 1, 1, 1);
-
- sampling_lb = gtk_label_new("packets");
- gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5f);
- ws_gtk_grid_attach_defaults(GTK_GRID (sampling_grid), sampling_lb, 2, 1, 1, 1);
-
- /* "Sampling by timer" row */
- samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_count_rb));
- samp_timer_rb = gtk_radio_button_new_with_label(samp_group, "1 every");
- if (device.remote_opts.sampling_method == CAPTURE_SAMP_BY_TIMER)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_timer_rb), TRUE);
- g_signal_connect(samp_timer_rb, "toggled",
- G_CALLBACK(options_prep_adjust_sensitivity), opt_remote_w);
- ws_gtk_grid_attach_defaults(GTK_GRID (sampling_grid), samp_timer_rb, 0, 2, 1, 1);
-
- samp_timer_adj = (GtkAdjustment *) gtk_adjustment_new(
- (gfloat)device.remote_opts.sampling_param,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- samp_timer_sb = gtk_spin_button_new(samp_timer_adj, 0, 0);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_timer_sb), TRUE);
- ws_gtk_grid_attach_defaults(GTK_GRID(sampling_grid), samp_timer_sb, 1, 2, 1, 1);
-
- sampling_lb = gtk_label_new("milliseconds");
- gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5f);
- ws_gtk_grid_attach_defaults(GTK_GRID (sampling_grid), sampling_lb, 2, 2, 1, 1);
-#endif
-
- /* Button row: "Start" and "Cancel" buttons */
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
- gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
-
- ok_but = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- g_signal_connect(ok_but, "clicked", G_CALLBACK(options_remote_ok_cb), opt_remote_w);
- gtk_widget_set_tooltip_text(ok_but, "Accept parameters and close dialog");
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
- gtk_widget_set_tooltip_text(cancel_bt, "Cancel and exit dialog.");
- window_set_cancel_button(opt_remote_w, cancel_bt, window_cancel_button_cb);
-
- gtk_widget_grab_default(ok_but);
-
- g_signal_connect(opt_remote_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(opt_remote_w, "destroy", G_CALLBACK(options_remote_destroy_cb), NULL);
-
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_NOCAP_RPCAP_CB_KEY, nocap_rpcap_cb);
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_DATATX_UDP_CB_KEY, datatx_udp_cb);
-
-#ifdef HAVE_PCAP_SETSAMPLING
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_NONE_RB_KEY, samp_none_rb);
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_COUNT_RB_KEY, samp_count_rb);
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_COUNT_SB_KEY, samp_count_sb);
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_TIMER_RB_KEY, samp_timer_rb);
- g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_TIMER_SB_KEY, samp_timer_sb);
-#endif
-
-#ifdef HAVE_PCAP_SETSAMPLING
- /* Set the sensitivity of various widgets as per the settings of other
- widgets. */
- options_prep_adjust_sensitivity(NULL, opt_remote_w);
-#endif
-
- gtk_widget_show_all(opt_remote_w);
- window_present(opt_remote_w);
-}
-
-#endif /* HAVE_PCAP_REMOTE */
-
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
-
-static void
-compile_bpf_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
-{
- /* Note that we no longer have an "About Wireshark" dialog box. */
- compile_bpf_w = NULL;
-}
-
-static void
-select_first_entry(void)
-{
- GtkWidget *view;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
-
- view = (GtkWidget *)g_object_get_data(G_OBJECT(compile_bpf_w), E_COMPILE_TREE_VIEW_INTERFACES);
- model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
- gtk_tree_model_get_iter_first(model, &iter);
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_select_iter(selection, &iter);
-}
-
-static void
-add_page(gchar *name, gchar *text, gboolean error)
-{
- GtkWidget *view, *icon;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- view = (GtkWidget *)g_object_get_data(G_OBJECT(compile_bpf_w), E_COMPILE_TREE_VIEW_INTERFACES);
- model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
- if (error) {
-#ifdef HAVE_GDK_GRESOURCE
- icon = pixbuf_to_widget("/org/wireshark/image/stock_icons/14x14/x-expert-error.png");
-#else
- icon = pixbuf_to_widget(expert_error_pb_data);
-#endif
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, COMPILE_ERROR, 1, SIGN, gtk_image_get_pixbuf(GTK_IMAGE(icon)), INAME, name, -1);
- } else {
-#ifdef HAVE_GDK_GRESOURCE
- icon = pixbuf_to_widget("/org/wireshark/image/expert_ok.png");
-#else
- icon = pixbuf_to_widget(expert_ok_pb_data);
-#endif
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, COMPILE_ERROR, 0, SIGN, gtk_image_get_pixbuf(GTK_IMAGE(icon)), INAME, name, -1);
- }
- g_hash_table_insert(compile_results, name, text);
-}
-
-static void
-compile_tree_select_cb(GtkTreeSelection *sel, gpointer dummy _U_)
-{
- gchar *name, *text;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *textview;
- GtkTextBuffer *buffer;
- guint error;
-
- if (gtk_tree_selection_get_selected(sel, &model, &iter))
- {
- gtk_tree_model_get(model, &iter, COMPILE_ERROR, &error, INAME, &name, -1);
- text = (gchar *)g_hash_table_lookup(compile_results, name);
- textview = (GtkWidget *)g_object_get_data(G_OBJECT(compile_bpf_w), CR_MAIN_NB);
- if (error == 1) {
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_CHAR);
- } else {
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_NONE);
- }
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_set_text(buffer, text, -1);
- gtk_widget_show_all(compile_bpf_w);
- }
-}
-
-static void
-compile_results_prep(GtkWidget *w _U_, gpointer data _U_)
-{
- GtkWidget *main_box, *main_vb, *bbox, *ok_btn, *top_hb, *ct_sb;
- GtkListStore *store;
- GtkWidget *view, *scrolled_win, *textview;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- PangoFontDescription *font;
-
- if (compile_bpf_w != NULL) {
- /* There's already an "About Wireshark" dialog box; reactivate it. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The requested dialog is already open. Please close it first.");
- return;
- }
-
- compile_bpf_w = dlg_window_new("Compile selected BPFs");
- /* set the initial position (must be done, before show is called!) */
- /* default position is not appropriate for the about dialog */
- gtk_window_set_position(GTK_WINDOW(compile_bpf_w), GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_window_set_default_size(GTK_WINDOW(compile_bpf_w), 600, 400);
- gtk_window_set_modal(GTK_WINDOW(compile_bpf_w), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(compile_bpf_w), GTK_WINDOW(cap_open_w));
- gtk_container_set_border_width(GTK_CONTAINER(compile_bpf_w), 6);
-
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_box), 6);
- gtk_container_add(GTK_CONTAINER(compile_bpf_w), main_box);
- gtk_widget_show(main_box);
-
- /* Top row: Interfaces tree and notebook */
- top_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
- gtk_box_pack_start(GTK_BOX(main_box), top_hb, TRUE, TRUE, 0);
- gtk_widget_show(top_hb);
-
- /* scrolled window on the left for the categories tree */
- ct_sb = scrolled_window_new(NULL, NULL);
- gtk_widget_set_size_request(GTK_WIDGET(ct_sb), 50, -1);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct_sb),
- GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct_sb),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(top_hb), ct_sb, TRUE, TRUE, 0);
- gtk_widget_show(ct_sb);
- g_object_set_data(G_OBJECT(compile_bpf_w), E_COMPILE_SW_SCROLLW_KEY, ct_sb);
-
- store = gtk_list_store_new(3, G_TYPE_UINT, GDK_TYPE_PIXBUF, G_TYPE_STRING);
- view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
- gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL (store));
- g_object_set(G_OBJECT(view), "headers-visible", FALSE, NULL);
- g_object_set_data(G_OBJECT(compile_bpf_w), E_COMPILE_TREE_VIEW_INTERFACES, view);
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
- column = gtk_tree_view_column_new();
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_attributes(column, renderer, "text", COMPILE_ERROR, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_visible(column, FALSE);
- column = gtk_tree_view_column_new();
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer, "pixbuf", SIGN, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_attributes(column, renderer, "text", INAME, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0), TRUE);
-
- g_signal_connect(selection, "changed", G_CALLBACK(compile_tree_select_cb), NULL);
- gtk_container_add(GTK_CONTAINER(ct_sb), view);
- gtk_widget_show(view);
-
- main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 10, FALSE);
- gtk_box_pack_start(GTK_BOX(top_hb), main_vb, TRUE, TRUE, 0);
- gtk_widget_show(main_vb);
- g_object_set_data(G_OBJECT(compile_bpf_w), CR_MAIN_NB, main_vb);
-
- font = pango_font_description_from_string("Monospace");
- textview = gtk_text_view_new();
-#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_override_font(textview, font);
-#else
- gtk_widget_modify_font(textview, font);
-#endif
- scrolled_win = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_set_size_request(GTK_WIDGET(scrolled_win), 350, -1);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_win),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_win),
- GTK_SHADOW_IN);
- gtk_container_add(GTK_CONTAINER(scrolled_win), textview);
- gtk_box_pack_start(GTK_BOX(main_vb), scrolled_win, TRUE, TRUE, 0);
- g_object_set_data(G_OBJECT(compile_bpf_w), CR_MAIN_NB, textview);
-
- /* Button row */
- bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
- gtk_box_pack_start(GTK_BOX(main_box), bbox, FALSE, FALSE, 0);
-
- ok_btn = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- gtk_widget_grab_focus(ok_btn);
- gtk_widget_grab_default(ok_btn);
- window_set_cancel_button(compile_bpf_w, ok_btn, window_cancel_button_cb);
-
- g_signal_connect(compile_bpf_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(compile_bpf_w, "destroy", G_CALLBACK(compile_bpf_destroy_cb), NULL);
-
- gtk_widget_show_all(compile_bpf_w);
- window_present(compile_bpf_w);
-
- compile_results = g_hash_table_new(g_str_hash, g_str_equal);
-}
-
-static void
-capture_all_filter_compile_cb(GtkWidget *w _U_, gpointer user_data _U_)
-{
- pcap_t *pd;
- struct bpf_program fcode;
-
- GtkWidget *filter_cm;
- gchar *filter_text;
- guint i;
- gboolean set = FALSE;
-
- filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_ALL_CFILTER_CM_KEY);
-
- if (!filter_cm)
- return;
-
- if (global_capture_opts.all_ifaces->len > 0) {
- interface_t device;
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (!device.selected || device.hidden) {
- continue;
- }
- if (device.active_dlt == -1) {
- g_assert_not_reached(); /* Programming error: somehow managed to select an "unsupported" entry */
- }
- if (!set) {
- set = TRUE;
- compile_results_prep(NULL, NULL);
- }
- pd = pcap_open_dead(device.active_dlt, DUMMY_SNAPLENGTH);
-
- filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
- g_mutex_lock(pcap_compile_mtx);
-#ifdef PCAP_NETMASK_UNKNOWN
- if (pcap_compile(pd, &fcode, filter_text, 1 /* Do optimize */, PCAP_NETMASK_UNKNOWN) < 0)
-#else
- if (pcap_compile(pd, &fcode, filter_text, 1 /* Do optimize */, 0) < 0)
-#endif
- {
- g_mutex_unlock(pcap_compile_mtx);
- add_page(device.name, g_strdup(pcap_geterr(pd)), TRUE);
- } else {
- GString *bpf_code_dump = g_string_new("");
- struct bpf_insn *insn = fcode.bf_insns;
- int ii, n = fcode.bf_len;
- gchar *bpf_code_str;
-
- for (ii = 0; ii < n; ++insn, ++ii) {
- g_string_append(bpf_code_dump, bpf_image(insn, ii));
- g_string_append(bpf_code_dump, "\n");
- }
- bpf_code_str = g_string_free(bpf_code_dump, FALSE);
- g_mutex_unlock(pcap_compile_mtx);
- add_page(device.name, g_strdup(bpf_code_str), FALSE);
- g_free(bpf_code_str);
- }
- g_free(filter_text);
- pcap_close(pd);
- }
- }
- select_first_entry();
-}
-#endif /* HAVE_PCAP_OPEN_DEAD && HAVE_BPF_IMAGE */
-
-
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
-static void
-compile_results_win(gchar *text, gboolean error)
-{
- GtkWidget *main_box, *bbox, *ok_btn, *results_w;
- GtkWidget *scrolled_win, *textview;
- PangoFontDescription *font;
- GtkTextBuffer *buffer;
-
- results_w = dlg_window_new("Compile results");
- /* set the initial position (must be done, before show is called!) */
- /* default position is not appropriate for the about dialog */
- gtk_window_set_position(GTK_WINDOW(results_w), GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_window_set_default_size(GTK_WINDOW(results_w), 400, 400);
- gtk_window_set_modal(GTK_WINDOW(results_w), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(results_w), GTK_WINDOW(opt_edit_w));
- gtk_container_set_border_width(GTK_CONTAINER(results_w), 6);
- main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_box), 6);
- gtk_container_add(GTK_CONTAINER(results_w), main_box);
- gtk_widget_show(main_box);
- font = pango_font_description_from_string("Monospace");
- textview = gtk_text_view_new();
-#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_override_font(textview, font);
-#else
- gtk_widget_modify_font(textview, font);
-#endif
- scrolled_win = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_set_size_request(GTK_WIDGET(scrolled_win), 350, -1);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_win),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_win),
- GTK_SHADOW_IN);
- gtk_container_add(GTK_CONTAINER(scrolled_win), textview);
- gtk_box_pack_start(GTK_BOX(main_box), scrolled_win, TRUE, TRUE, 0);
- if (error == 1) {
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_CHAR);
- } else {
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_NONE);
- }
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_set_text(buffer, g_strdup(text), -1);
- /* Button row */
- bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
- gtk_box_pack_start(GTK_BOX(main_box), bbox, FALSE, FALSE, 0);
-
- ok_btn = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- gtk_widget_grab_focus(ok_btn);
- gtk_widget_grab_default(ok_btn);
- window_set_cancel_button(results_w, ok_btn, window_cancel_button_cb);
-
- g_signal_connect(results_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(results_w, "destroy", G_CALLBACK(compile_bpf_destroy_cb), NULL);
-
- gtk_widget_show_all(results_w);
- window_present(results_w);
-}
-
-
-static void
-capture_filter_compile_cb(GtkWidget *w _U_, gpointer user_data _U_)
-{
- pcap_t *pd;
- struct bpf_program fcode;
-
- GtkWidget *filter_cm;
- gchar *filter_text;
- gpointer ptr;
- int dlt;
- GtkWidget *linktype_combo_box = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY);
-
- if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(linktype_combo_box), &ptr)) {
- g_assert_not_reached(); /* Programming error: somehow nothing is active */
- }
- if ((dlt = GPOINTER_TO_INT(ptr)) == -1) {
- g_assert_not_reached(); /* Programming error: somehow managed to select an "unsupported" entry */
- }
- pd = pcap_open_dead(dlt, DUMMY_SNAPLENGTH);
- filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(opt_edit_w), E_CFILTER_CM_KEY);
- filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
- g_mutex_lock(pcap_compile_mtx);
-#ifdef PCAP_NETMASK_UNKNOWN
- if (pcap_compile(pd, &fcode, filter_text, 1 /* Do optimize */, PCAP_NETMASK_UNKNOWN) < 0) {
-#else
- if (pcap_compile(pd, &fcode, filter_text, 1 /* Do optimize */, 0) < 0) {
-#endif
- g_mutex_unlock(pcap_compile_mtx);
- compile_results_win(g_strdup(pcap_geterr(pd)), 1);
- } else {
- GString *bpf_code_dump = g_string_new("");
- struct bpf_insn *insn = fcode.bf_insns;
- int i, n = fcode.bf_len;
-
- gchar *bpf_code_str;
-
- g_mutex_unlock(pcap_compile_mtx);
-
- for (i = 0; i < n; ++insn, ++i) {
- g_string_append(bpf_code_dump, bpf_image(insn, i));
- g_string_append(bpf_code_dump, "\n");
- }
-
- bpf_code_str = g_string_free(bpf_code_dump, FALSE);
- compile_results_win(g_strdup(bpf_code_str), 0);
-
- g_free(bpf_code_str);
- }
- g_free(filter_text);
-
- pcap_close(pd);
-}
-#endif /* HAVE_PCAP_OPEN_DEAD && HAVE_BPF_IMAGE */
-
-static void
-options_edit_destroy_cb(GtkWidget *win, gpointer user_data _U_)
-{
- GtkWidget *caller;
-
- caller = (GtkWidget *)g_object_get_data(G_OBJECT(win), E_OPT_EDIT_CALLER_PTR_KEY);
- g_object_set_data(G_OBJECT(caller), E_OPT_EDIT_DIALOG_PTR_KEY, NULL);
-}
-
-static void
-update_options_table(gint indx)
-{
- interface_t device;
- GtkTreePath *path;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *temp, *path_str, *snaplen_string, *linkname;
- GList *list;
- link_row *linkr = NULL;
- gboolean enabled;
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
-
- if (!device.hidden) {
- if (device.no_addresses == 0) {
- temp = g_strdup_printf("<b>%s</b>", device.display_name);
- } else {
- temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
- }
- linkname = NULL;
- for (list=device.links; list!=NULL; list=g_list_next(list))
- {
- linkr = (link_row*)(list->data);
- if (linkr->dlt == device.active_dlt) {
- linkname = g_strdup(linkr->name);
- break;
- }
- }
- if (!linkname)
- linkname = g_strdup("unknown");
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- if (cap_open_w) {
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- path_str = g_strdup_printf("%d", indx);
- path = gtk_tree_path_new_from_string(path_str);
- model = gtk_tree_view_get_model(if_cb);
- gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_model_get(model, &iter, CAPTURE, &enabled, -1);
- if (enabled == FALSE) {
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
- g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
- }
- #if defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
- #elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
- #else
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
- #endif
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
-#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
-#endif
- }
- gtk_tree_path_free (path);
- g_free(path_str);
- }
- if (interfaces_dialog_window_present()) {
- update_selected_interface(g_strdup(device.name));
- }
- if (get_welcome_window() != NULL) {
- change_interface_selection(g_strdup(device.name), device.selected);
- }
- g_free(linkname);
- }
- set_sensitivity_for_start_icon();
-}
-
-
-static void
-save_options_cb(GtkWidget *win _U_, gpointer user_data _U_)
-{
- GtkWidget *snap_cb, *snap_sb, *promisc_cb,
-#ifdef HAVE_PCAP_CREATE
- *monitor_cb,
-#endif
- *filter_cm, *linktype_combo_box;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- GtkWidget *buffer_size_sb;
-#endif
- GtkWidget *extcap_vbox = NULL;
-
- interface_t device;
- gpointer ptr = NULL;
- int dlt = -1;
- gchar *filter_text;
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
- snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_CB_KEY);
- snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_SB_KEY);
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_BUFFER_SIZE_SB_KEY);
-#endif
- promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_PROMISC_KEY);
-#ifdef HAVE_PCAP_CREATE
- monitor_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_MONITOR_KEY);
-#endif
- filter_cm = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CFILTER_CM_KEY);
-
- linktype_combo_box = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY);
-
- extcap_vbox = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_EXTCAP_KEY);
-
- if (device.links != NULL) {
- if (ws_combo_box_get_active_pointer(GTK_COMBO_BOX(linktype_combo_box), &ptr)) {
- /* Even though device.links != NULL, we might not have an active pointer
- * if all of the available links are unsupported, so the failure of
- * ws_combo_box_get_active_pointer() is not cause for
- * g_assert_not_reached().
- */
- if (ptr != NULL && (dlt = GPOINTER_TO_INT(ptr)) == -1)
- g_assert_not_reached(); /* Programming error: somehow managed to select an "unsupported" entry */
- }
- }
- device.active_dlt = dlt;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- device.buffer = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
-#endif
- device.pmode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
- device.has_snaplen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
- if (device.has_snaplen) {
- device.snaplen = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
- if (device.snaplen < MIN_PACKET_SIZE)
- device.snaplen = MIN_PACKET_SIZE;
- } else {
- device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
- }
- filter_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(filter_cm));
- g_free(device.cfilter);
- g_assert(filter_text != NULL);
- device.cfilter = filter_text;
-
- if (device.external_cap_args_settings != NULL)
- g_hash_table_unref(device.external_cap_args_settings);
-
- if (extcap_vbox != NULL)
- device.external_cap_args_settings = extcap_gtk_get_state(extcap_vbox);
-
- /* Destroy the args data linked in the gtk widget */
-#if 0
- extcap_gtk_free_args(extcap_vbox);
-#endif
-
-#ifdef HAVE_PCAP_CREATE
- /* if dumpcap reported that the interface does not support monitor
- mode, we disable monitor mode even if the user explicitly selected it */
- device.monitor_mode_enabled = device.monitor_mode_supported ?
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor_cb)) : FALSE;
-#endif
- g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
- window_destroy(opt_edit_w);
- update_options_table(marked_row);
- update_properties_all();
-}
-
-static void
-adjust_snap_sensitivity(GtkWidget *tb _U_, gpointer parent_w _U_)
-{
- GtkWidget *snap_cb, *snap_sb;
- interface_t device;
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
-
- snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_CB_KEY);
- snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_SB_KEY);
-
- /* The snapshot length spinbox is sensitive if the "Limit each packet
- to" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
- device.has_snaplen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
- if (!device.has_snaplen) {
- gtk_spin_button_set_value(GTK_SPIN_BUTTON (snap_sb), WTAP_MAX_PACKET_SIZE_STANDARD);
- device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
- }
- g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
-}
-
-static GtkWidget *build_extcap_options(const gchar *name, GHashTable *hash) {
- GtkWidget *ret_box = NULL;
- GList *arglist = NULL;
- GList *elem = NULL;
-
- arglist = extcap_get_if_configuration( name );
- for ( elem = g_list_first(arglist); elem; elem = elem->next )
- {
- GSList *widget_list;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- ret_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
-#else
- ret_box = ws_gtk_vbox_new(FALSE, 3);
-#endif
- widget_list = extcap_populate_gtk_vbox((GList *) elem->data, ret_box, hash);
- g_object_set_data(G_OBJECT(ret_box), EXTCAP_GTK_DATA_KEY_WIDGETLIST, widget_list);
- }
-
- return ret_box;
-}
-
-/*
- * If we have an AirPcap "Wireless Settings" checkbox, have two columns
- * (vboxes) of settings, and put the buffer size in the right column.
- *
- * If we have remote capture support, and if this is a remote interface,
- * have two columns of settings, have a "Remote Sttings" button, and
- * put it in the right column.
- *
- * If we can set the buffer size, then have two columns of settings
- * and, if we don't have a "Remote Settings" button, put it in the
- * right column.
- *
- * We avoid having the right column if we don't need it, because it
- * steals 3 pixels.
- */
-#if defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(CAN_SET_CAPTURE_BUFFER_SIZE)
-#define HAVE_TWO_SETTING_COLUMNS
-# if !defined(HAVE_PCAP_REMOTE)
-# define BUFFER_SIZE_IN_RIGHT_COLUMN
-# endif /* !defined(HAVE_PCAP_REMOTE) */
-#endif /* defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(CAN_SET_CAPTURE_BUFFER_SIZE) */
-
-void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata)
-{
- GtkWidget *caller, *window, *swindow = NULL, *if_view,
- *main_vb, *if_hb, *if_lb, *if_lb_name,
- *main_hb, *left_vb,
-#ifdef HAVE_TWO_SETTING_COLUMNS
- *right_vb,
-#endif
- *capture_fr, *capture_vb,
- *if_ip_hb, *if_ip_lb = NULL, *if_ip_name,
- *if_vb_left, *if_vb_right,
- *linktype_hb, *linktype_lb, *linktype_combo_box,
- *snap_hb, *snap_cb, *snap_sb, *snap_lb,
- *promisc_cb,
-#ifdef HAVE_PCAP_CREATE
- *monitor_cb,
-#endif
- *filter_hb, *filter_bt, *filter_te, *filter_cm,
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- *compile_bt,
-#endif
- *bbox, *ok_but, *cancel_bt,
- *extcap_vbox,
- *help_bt;
-
- GList *cf_entry, *list, *cfilter_list;
- GtkAdjustment *snap_adj;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- GtkAdjustment *buffer_size_adj;
- GtkWidget *buffer_size_lb, *buffer_size_sb, *buffer_size_hb;
-#endif
-#ifdef HAVE_PCAP_REMOTE
- GtkWidget *remote_bt;
-#endif
-#ifdef HAVE_AIRPCAP
- GtkWidget *advanced_bt;
-#endif
- interface_t device;
- GtkTreeModel *model;
- GtkTreeIter iter;
- link_row *temp;
- gboolean found = FALSE;
- gint num_link_types, num_supported_link_types, first_supported_index;
- guint i;
- gchar *tok, *name;
- GtkCellRenderer *renderer;
- GtkListStore *store;
- const gchar *new_cfilter;
- GHashTable *extcap_hash;
-
- window = (GtkWidget *)userdata;
- caller = gtk_widget_get_toplevel(GTK_WIDGET(window));
- opt_edit_w = (GtkWidget *)g_object_get_data(G_OBJECT(caller), E_OPT_EDIT_DIALOG_PTR_KEY);
- if (opt_edit_w != NULL) {
- reactivate_window(opt_edit_w);
- return;
- }
-
- device.name = NULL;
- device.display_name = NULL;
- device.no_addresses = 0;
- device.addresses = NULL;
- device.links = NULL;
- device.active_dlt = -1;
- device.pmode = FALSE;
-#ifdef HAVE_PCAP_CREATE
- device.monitor_mode_enabled = FALSE;
- device.monitor_mode_supported = FALSE;
-#endif
- device.has_snaplen = FALSE;
- device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
- device.cfilter = NULL;
- device.timestamp_type = NULL;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
-#endif
- device.external_cap_args_settings = NULL;
-
- model = gtk_tree_view_get_model(view);
- gtk_tree_model_get_iter (model, &iter, path);
-
- if (window == get_welcome_window()) {
- gtk_tree_model_get(model, &iter, IFACE_NAME, &name, -1);
- } else if (window == cap_open_w) {
- gtk_tree_model_get(model, &iter, IFACE_HIDDEN_NAME, &name, -1);
- } else {
- return;
- }
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(device.name, name) == 0) {
- marked_interface = i;
- break;
- }
- }
- // not sure if this can happen, just to be sure...
- if (gtk_tree_path_get_depth(path) == 0) {
- marked_row = 0;
- } else {
- marked_row = gtk_tree_path_get_indices(path)[0];
- }
- opt_edit_w = dlg_window_new("Edit Interface Settings");
- gtk_window_set_modal(GTK_WINDOW(opt_edit_w), TRUE);
- gtk_window_set_type_hint (GTK_WINDOW (opt_edit_w), GDK_WINDOW_TYPE_HINT_DIALOG);
- g_object_set_data(G_OBJECT(opt_edit_w), E_OPT_EDIT_CALLER_PTR_KEY, caller);
- g_object_set_data(G_OBJECT(caller), E_OPT_EDIT_DIALOG_PTR_KEY, opt_edit_w);
-
- main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
- gtk_container_add(GTK_CONTAINER(opt_edit_w), main_vb);
-
- /* Capture-related options frame */
- capture_fr = gtk_frame_new("Capture");
- gtk_box_pack_start(GTK_BOX (main_vb), capture_fr, TRUE, TRUE, 0);
-
- capture_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(capture_vb), 5);
- gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
-
- /* Interface row */
- if_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(capture_vb), if_hb, FALSE, FALSE, 3);
-
- if_lb = gtk_label_new("Interface: ");
- gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 3);
-
- if_lb_name = gtk_label_new(device.display_name);
- gtk_box_pack_start(GTK_BOX(if_hb), if_lb_name, FALSE, FALSE, 3);
-
- /* IP addresses row */
- if_ip_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
-
- gtk_widget_set_tooltip_text(if_ip_hb, "Lists the IP address(es) "
- "assigned to the selected interface. ");
- if_vb_left = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(if_ip_hb), if_vb_left, FALSE, FALSE, 3);
- if_vb_right = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
-
- if_ip_lb = gtk_label_new("IP address:");
- gtk_misc_set_alignment(GTK_MISC(if_ip_lb), 0, 0); /* Left justified */
- gtk_box_pack_start(GTK_BOX(if_vb_left), if_ip_lb, FALSE, FALSE, 0);
- if (device.no_addresses > 0) {
- gchar *temp_addresses = g_strdup(device.addresses);
- gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(if_ip_hb), if_vb_right, TRUE, TRUE, 3);
- swindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swindow), GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_widget_set_size_request(GTK_WIDGET(swindow),-1, 50);
- if_view = gtk_tree_view_new ();
- g_object_set(G_OBJECT(if_view), "headers-visible", FALSE, NULL);
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ("",
- GTK_CELL_RENDERER(renderer),
- "text", 0,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
- store = gtk_list_store_new(1, G_TYPE_STRING);
- for (tok = strtok (temp_addresses, "\n"); tok; tok = strtok(NULL, "\n")) {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, tok, -1);
- }
- gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
- gtk_container_add (GTK_CONTAINER (swindow), if_view);
- gtk_box_pack_start(GTK_BOX(if_vb_right), swindow, TRUE, TRUE, 0);
- g_free(temp_addresses);
- } else {
- gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(if_ip_hb), if_vb_right, FALSE, FALSE, 3);
- if_ip_name = gtk_label_new("none");
- gtk_misc_set_alignment(GTK_MISC(if_ip_name), 0, 0); /* Left justified */
- gtk_box_pack_start(GTK_BOX(if_vb_right), if_ip_name, FALSE, FALSE, 0);
- }
- main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
- gtk_box_pack_start(GTK_BOX(capture_vb), main_hb, FALSE, FALSE, 3);
-
- left_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
-
-#ifdef HAVE_TWO_SETTING_COLUMNS
- right_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 3);
-#endif
-
- /* Linktype row */
- linktype_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(left_vb), linktype_hb, FALSE, FALSE, 0);
-
- linktype_lb = gtk_label_new("Link-layer header type:");
- gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 3);
-
- linktype_combo_box = ws_combo_box_new_text_and_pointer();
- g_object_set_data(G_OBJECT(linktype_combo_box), E_CAP_LT_CBX_LABEL_KEY, linktype_lb);
- /* Default to "use the default" */
- /* Datalink menu index is not reset; it will be restored with last used value */
-
- g_object_set_data(G_OBJECT(linktype_combo_box), E_CAP_IFACE_IP_KEY, if_ip_lb);
- /*
- * XXX - in some cases, this is "multiple link-layer header types", e.g.
- * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
- * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
- *
- * In other cases, it's "multiple link-layer types", e.g., with recent
- * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
- * request Cisco HDLC or PPP depending on what type of traffic is going
- * over the WAN, or an Ethernet interface, where you can request Ethernet
- * or DOCSIS, the latter being for some Cisco cable modem equipment that
- * can be configured to send raw DOCSIS frames over an Ethernet inside
- * Ethernet low-level framing, for traffic capture purposes.
- *
- * We leave it as "multiple link-layer types" for now.
- */
- gtk_widget_set_tooltip_text(linktype_combo_box, "The selected interface supports multiple link-layer types; select the desired one.");
- gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_combo_box, FALSE, FALSE, 0);
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY, linktype_combo_box);
- num_link_types = 0;
- num_supported_link_types = 0;
- first_supported_index = -1;
- for (list=device.links; list!=NULL; list=g_list_next(list))
- {
- temp = (link_row*)(list->data);
- if (temp->dlt == -1)
- {
- ws_combo_box_append_text_and_pointer_full(GTK_COMBO_BOX(linktype_combo_box),
- NULL,
- temp->name,
- GINT_TO_POINTER(-1), /* Flag as "not supported" */
- FALSE);
- }
- else
- {
- ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(linktype_combo_box),
- temp->name,
- GINT_TO_POINTER(temp->dlt));
- /* Record the index of the first supported link type (and thus the first
- * one in the list to be active) for use determining the default selected
- * element. */
- if (first_supported_index == -1)
- {
- first_supported_index = num_link_types;
- }
- if (temp->dlt == device.active_dlt)
- {
- ws_combo_box_set_active(GTK_COMBO_BOX(linktype_combo_box), num_link_types);
- found = TRUE;
- }
- num_supported_link_types++;
- }
- num_link_types++;
- }
- gtk_widget_set_sensitive(linktype_lb, num_link_types >= 2);
- gtk_widget_set_sensitive(linktype_combo_box, num_link_types >= 2);
- if (!found && first_supported_index >= 0)
- {
- ws_combo_box_set_active(GTK_COMBO_BOX(linktype_combo_box),first_supported_index);
- }
- g_signal_connect(linktype_combo_box, "changed", G_CALLBACK(select_link_type_cb), NULL);
-
- /* Promiscuous mode row */
- promisc_cb = gtk_check_button_new_with_mnemonic(
- "Capture packets in _promiscuous mode");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb),
- device.pmode);
- gtk_widget_set_tooltip_text(promisc_cb,
- "Usually a network adapter will only capture the traffic sent to its own network address. "
- "If you want to capture all traffic that the network adapter can \"see\", mark this option. "
- "See the FAQ for some more details of capturing packets from a switched network.");
- gtk_box_pack_start (GTK_BOX(left_vb), promisc_cb, FALSE, FALSE, 0);
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_PROMISC_KEY, promisc_cb);
-
-#ifdef HAVE_PCAP_CREATE
- /* Monitor mode row */
- monitor_cb = gtk_check_button_new_with_mnemonic( "Capture packets in monitor mode");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(monitor_cb), device.monitor_mode_enabled);
- gtk_widget_set_sensitive(monitor_cb, device.monitor_mode_supported);
- g_signal_connect(monitor_cb, "toggled", G_CALLBACK(capture_prep_monitor_changed_cb), NULL);
-
- gtk_widget_set_tooltip_text(monitor_cb,
- "Usually a Wi-Fi adapter will, even in promiscuous mode, only capture the traffic on the BSS to which it's associated. "
- "If you want to capture all traffic that the Wi-Fi adapter can \"receive\", mark this option. "
- "In order to see IEEE 802.11 headers or to see radio information for captured packets, "
- "it might be necessary to turn this option on.\n\n"
- "Note that, in monitor mode, the adapter might disassociate from the network to which it's associated.");
- gtk_box_pack_start (GTK_BOX(left_vb), monitor_cb, FALSE, FALSE, 0);
-
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_MONITOR_KEY, monitor_cb);
-#endif
-
- /*
- * This controls the sensitivity of both the link-type list and, if
- * you have it, the monitor mode checkbox. That's why we do this
- * now.
- */
-
- /* Capture length row */
- snap_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start (GTK_BOX(left_vb), snap_hb, FALSE, FALSE, 0);
-
- snap_cb = gtk_check_button_new_with_mnemonic("_Limit each packet to");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(snap_cb),
- device.has_snaplen);
- g_signal_connect(snap_cb, "toggled", G_CALLBACK(adjust_snap_sensitivity), NULL);
- gtk_widget_set_tooltip_text(snap_cb,
- "Limit the maximum number of bytes to be captured from each packet. This size includes the "
- "link-layer header and all subsequent headers. ");
- gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
-
- snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) device.snaplen,
- MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
- snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
- gtk_widget_set_size_request(snap_sb, 80, -1);
- gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
-
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_CB_KEY, snap_cb);
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_SB_KEY, snap_sb);
- snap_lb = gtk_label_new("bytes");
- gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5f);
- gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
- gtk_widget_set_sensitive(GTK_WIDGET(snap_sb), device.has_snaplen);
-
- /* Filter row */
- filter_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
-
- filter_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
- g_signal_connect(filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
- g_signal_connect(filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
- gtk_widget_set_tooltip_text(filter_bt,
- "Select a capture filter to reduce the amount of packets to be captured. "
- "See \"Capture Filters\" in the online help for further information how to use it."
- );
- gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
-
- /* Create the capture filter combo box*/
- filter_cm = gtk_combo_box_text_new_with_entry();
- g_object_set_data(G_OBJECT(opt_edit_w), E_CFILTER_CM_KEY, filter_cm);
- filter_te = gtk_bin_get_child(GTK_BIN(filter_cm));
- colorize_filter_te_as_empty(filter_te);
- g_signal_connect(filter_te, "changed", G_CALLBACK(capture_filter_check_syntax_cb), NULL);
- g_signal_connect(filter_te, "destroy", G_CALLBACK(capture_filter_destroy_cb), NULL);
-
- cfilter_list = recent_get_cfilter_list(name);
- for (cf_entry = cfilter_list; cf_entry != NULL; cf_entry = g_list_next(cf_entry)) {
- new_cfilter = (const gchar *)cf_entry->data;
- /* If this is the current dfilter or the default cfilter, don't put
- it in the list, as it'll be added later. */
- if ((device.cfilter == NULL || strcmp(device.cfilter, new_cfilter) != 0) &&
- (global_capture_opts.default_options.cfilter == NULL || strcmp(global_capture_opts.default_options.cfilter, new_cfilter) != 0)) {
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(filter_cm), new_cfilter);
- }
- }
- if (global_capture_opts.default_options.cfilter && (strlen(global_capture_opts.default_options.cfilter) > 0)) {
- /* If this is the current dfilter, don't put it in the list, as it'll be
- added later. */
- if (device.cfilter == NULL || strcmp(device.cfilter, global_capture_opts.default_options.cfilter) != 0) {
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(filter_cm), global_capture_opts.default_options.cfilter);
- }
- }
- if (device.cfilter && (strlen(device.cfilter) > 0)) {
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(filter_cm), device.cfilter);
- gtk_combo_box_set_active(GTK_COMBO_BOX(filter_cm), 0);
- }
-
- gtk_widget_set_tooltip_text(filter_cm,
- "Enter a capture filter to reduce the amount of packets to be captured. "
- "See \"Capture Filters\" in the online help for further information how to use it. "
- "Syntax checking can be disabled in Preferences -> Capture -> Syntax check capture filter."
- );
- gtk_box_pack_start(GTK_BOX(filter_hb), filter_cm, TRUE, TRUE, 3);
-
- /* let an eventually capture filters dialog know the text entry to fill in */
- g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te);
-
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- compile_bt = gtk_button_new_with_label("Compile BPF");
- g_signal_connect(compile_bt, "clicked", G_CALLBACK(capture_filter_compile_cb), NULL);
- gtk_widget_set_tooltip_text(compile_bt,
- "Compile the capture filter expression and show the BPF (Berkeley Packet Filter) code.");
- /* We can't compile without any supported link-types, so disable the button in that case */
- gtk_widget_set_sensitive(compile_bt, (num_supported_link_types >= 1));
- gtk_box_pack_start(GTK_BOX(filter_hb), compile_bt, FALSE, FALSE, 3);
-#endif
-
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- buffer_size_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- buffer_size_lb = gtk_label_new("Buffer size:");
- gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 0);
-
- buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) device.buffer,
- 1, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
- buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) device.buffer);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
- gtk_widget_set_size_request(buffer_size_sb, 80, -1);
- gtk_widget_set_tooltip_text(buffer_size_sb,
- "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.");
- gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_sb, FALSE, FALSE, 0);
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
- buffer_size_lb = gtk_label_new("mebibyte(s)");
- gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 3);
- gtk_misc_set_alignment(GTK_MISC(buffer_size_lb), 1, 0);
-#ifdef BUFFER_SIZE_IN_RIGHT_COLUMN
- gtk_box_pack_start (GTK_BOX(right_vb), buffer_size_hb, FALSE, FALSE, 0);
-#else /* BUFFER_SIZE_IN_RIGHT_COLUMN */
- gtk_box_pack_start (GTK_BOX(left_vb), buffer_size_hb, FALSE, FALSE, 0);
-#endif /* BUFFER_SIZE_IN_RIGHT_COLUMN */
-#endif /* CAN_SET_CAPTURE_BUFFER_SIZE */
-
-#ifdef HAVE_PCAP_REMOTE
- /*
- * *IF* this is a remote interface, add the "Remote Settings"
- * button. Do *not* add it for other interfaces, as that could
- * lead users to believe that it could somehow be enabled.
- */
- /* Both the callback and the data are global */
- if (strncmp (device.name, "rpcap://", 8) == 0) {
- remote_bt = gtk_button_new_with_label("Remote Settings");
- gtk_widget_set_tooltip_text(remote_bt, "Various settings for remote capture.");
-
- g_signal_connect(remote_bt, "clicked", G_CALLBACK(options_remote_cb), NULL);
-
- gtk_box_pack_start(GTK_BOX(right_vb), remote_bt, FALSE, FALSE, 0);
- gtk_widget_show(remote_bt);
- }
-#endif
-
-#ifdef HAVE_AIRPCAP
- /*
- * *IF* this is an AirPcap interface, add the "Wireless Settings"
- * button. Do *not* add it for other interfaces, as that can
- * confuse users, so that they ask why this is grayed out on
- * their non-Windows machine and ask how to enable it.
- */
- airpcap_if_selected = get_airpcap_if_from_name(g_airpcap_if_list, device.name);
- if (airpcap_if_selected != NULL) {
- advanced_bt = gtk_button_new_with_label("Wireless Settings");
-
- /* Both the callback and the data are global */
- g_signal_connect(advanced_bt,"clicked", G_CALLBACK(options_airpcap_advanced_cb), wireless_tb);
-
- gtk_box_pack_start(GTK_BOX(right_vb), advanced_bt, FALSE, FALSE, 0);
- gtk_widget_show(advanced_bt);
- }
-#endif
-
- extcap_hash = device.external_cap_args_settings;
- extcap_vbox = build_extcap_options(device.name, extcap_hash);
- if (extcap_vbox != NULL) {
- gtk_box_pack_start(GTK_BOX(capture_vb), extcap_vbox, FALSE, FALSE, 5);
- gtk_widget_show(extcap_vbox);
- }
- g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_EXTCAP_KEY, extcap_vbox);
-
-/* Button row: "Start", "Cancel" and "Help" buttons */
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
- gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
-
- ok_but = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- g_signal_connect(ok_but, "clicked", G_CALLBACK(save_options_cb), NULL);
- gtk_widget_set_tooltip_text(ok_but,
- "Accept interface settings.");
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
- gtk_widget_set_tooltip_text(cancel_bt,
- "Cancel and exit dialog.");
- window_set_cancel_button(opt_edit_w, cancel_bt, window_cancel_button_cb);
- help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
- gtk_widget_set_tooltip_text(help_bt,
- "Show help about capturing.");
- g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_CAPTURE_OPTIONS_DIALOG);
- dlg_set_activate(filter_te, ok_but);
- gtk_widget_grab_focus(filter_te);
- g_signal_connect(opt_edit_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(opt_edit_w, "destroy", G_CALLBACK(options_edit_destroy_cb), NULL);
- gtk_widget_show_all(opt_edit_w);
- window_present(opt_edit_w);
-}
-
-static void toggle_callback(GtkCellRendererToggle *cell _U_,
- gchar *path_str,
- gpointer data _U_)
-{
- /* get the treemodel from somewhere */
- GtkTreeIter iter;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- gboolean enabled;
- GtkWidget *pcap_ng_cb, *filter_cm;
- interface_t device;
- gchar *name;
- gint indx = -1;
- guint i;
-
- /* Initialise device */
- device.cfilter = NULL;
-
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, CAPTURE, &enabled, IFACE_HIDDEN_NAME, &name, -1);
- /* Look for the right interface. The number of interfaces shown might be less
- * than the real number. Therefore the path index does not correspond
- * necessarily to the position in the list */
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(device.name, name) == 0) {
- indx = i;
- break;
- }
- }
- if (enabled == FALSE) {
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- } else {
- device.selected = FALSE;
- global_capture_opts.num_selected--;
- }
- if (indx != -1) {
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, indx);
- g_array_insert_val(global_capture_opts.all_ifaces, indx, device);
- pcap_ng_cb = (GtkWidget *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_PCAP_NG_KEY);
- if (global_capture_opts.num_selected >= 2) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pcap_ng_cb), TRUE);
- gtk_widget_set_sensitive(pcap_ng_cb, FALSE);
- } else {
- gtk_widget_set_sensitive(pcap_ng_cb, TRUE);
- }
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
-#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
-#endif
- }
- /* do something with the new enabled value, and set the new
- enabled value in your treemodel */
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, -1);
- if (interfaces_dialog_window_present()) {
- update_selected_interface(g_strdup(device.name));
- }
- if (get_welcome_window() != NULL) {
- change_interface_selection(g_strdup(device.name), device.selected);
- }
- }
- if (device.cfilter != NULL) {
- g_free(device.cfilter);
- device.cfilter = NULL;
- update_filter_string(device.name, NULL);
- }
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, indx);
- g_array_insert_val(global_capture_opts.all_ifaces, indx, device);
- gtk_tree_path_free (path);
- filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_ALL_CFILTER_CM_KEY);
- if (strcmp(gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm)),"") != 0) {
- capture_all_filter_check_syntax_cb(NULL, NULL);
- }
- update_properties_all();
-}
-
-void enable_selected_interface(gchar *name, gboolean selected)
-{
- GtkTreeIter iter;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- gchar *name_str;
-
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- gtk_tree_model_get_iter_first(model, &iter);
- do {
- gtk_tree_model_get(model, &iter, IFACE_HIDDEN_NAME, &name_str, -1);
- if (strcmp(name, name_str) == 0) {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, CAPTURE, selected, -1);
- break;
- }
- }
- while (gtk_tree_model_iter_next(model, &iter));
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
-#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
-#endif
- }
-}
-
-
-static void capture_all_cb(GtkToggleButton *button, gpointer d _U_)
-{
- GtkTreeIter iter;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- GtkWidget *filter_cm, *pcap_ng_cb;
- gchar *interface = NULL, *filter_text = NULL;
- gboolean enabled = FALSE, capture_set = FALSE, pseudo = FALSE;
- guint16 num_temp, i;
- interface_t device;
-
- if (gtk_toggle_button_get_active(button))
- enabled = TRUE;
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- pcap_ng_cb = (GtkWidget *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_PCAP_NG_KEY);
- num_temp = global_capture_opts.num_selected++;
- filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_ALL_CFILTER_CM_KEY);
- filter_text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(filter_cm));
- if (gtk_tree_model_get_iter_first(model, &iter)) {
- do {
- gtk_tree_model_get (model, &iter, CAPTURE, &capture_set, IFACE_HIDDEN_NAME, &interface, -1);
- if (strcmp(interface, "any") == 0) {
- pseudo = TRUE;
- }
- if (!capture_set && enabled && !pseudo) {
- num_temp++;
- } else if (capture_set && (!enabled || (enabled && pseudo))) {
- num_temp--;
- }
- if (!pseudo) {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, CAPTURE, enabled, -1);
- if (strlen(filter_text) != 0) {
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(device.name, interface) == 0) {
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_free(device.cfilter);
- device.cfilter = g_strdup(filter_text);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- update_filter_string(device.name, filter_text);
- }
- }
- }
- } else {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, -1);
- }
- pseudo = FALSE;
- } while (gtk_tree_model_iter_next(model, &iter));
- }
- if (num_temp >= 2) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pcap_ng_cb), TRUE);
- gtk_widget_set_sensitive(pcap_ng_cb, FALSE);
- } else if (num_temp <= 1) {
- gtk_widget_set_sensitive(pcap_ng_cb, TRUE);
- }
- if (interfaces_dialog_window_present()) {
- select_all_interfaces(enabled);
- }
- if (get_welcome_window() != NULL) {
- change_selection_for_all(enabled);
- }
- if (global_capture_opts.num_selected != num_temp) {
- global_capture_opts.num_selected = num_temp;
- }
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
-#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
-#endif
- }
- set_sensitivity_for_start_icon();
-}
-
-
-static gboolean get_all_prom_mode(void)
-{
- interface_options interface_opts;
- guint i;
-
- for (i = 0; i < global_capture_opts.ifaces->len; i++) {
- interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
- if (!interface_opts.promisc_mode) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-static void promisc_mode_callback(GtkToggleButton *button, gpointer d _U_)
-{
- GtkTreeIter iter;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- gboolean enabled = FALSE;
- interface_t device;
- interface_options interface_opts;
- guint i;
-
- if (gtk_toggle_button_get_active(button))
- enabled = TRUE;
-
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first(model, &iter)) {
- do {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, PMODE, enabled?"enabled":"disabled", -1);
- } while (gtk_tree_model_iter_next(model, &iter));
- }
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- device.pmode = (enabled?TRUE:FALSE);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- }
-
- for (i = 0; i < global_capture_opts.ifaces->len; i++) {
- interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
- global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
- interface_opts.promisc_mode = (enabled?TRUE:FALSE);
- g_array_insert_val(global_capture_opts.ifaces, i, interface_opts);
- }
-}
-
-#if defined (HAVE_PCAP_REMOTE)
-static void
-show_remote_dialog(GtkWidget *w)
-{
-
- g_free(global_remote_opts.remote_host_opts.remote_host);
- g_free(global_remote_opts.remote_host_opts.remote_port);
- g_free(global_remote_opts.remote_host_opts.auth_username);
- g_free(global_remote_opts.remote_host_opts.auth_password);
- global_remote_opts.src_type = CAPTURE_IFREMOTE;
- global_remote_opts.remote_host_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
- global_remote_opts.remote_host_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
- global_remote_opts.remote_host_opts.auth_type = global_capture_opts.default_options.auth_type;
- global_remote_opts.remote_host_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
- global_remote_opts.remote_host_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
- global_remote_opts.remote_host_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
- global_remote_opts.remote_host_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
- global_remote_opts.remote_host_opts.nocap_local = global_capture_opts.default_options.nocap_local;
-#ifdef HAVE_PCAP_SETSAMPLING
- global_remote_opts.sampling_method = global_capture_opts.default_options.sampling_method;
- global_remote_opts.sampling_param = global_capture_opts.default_options.sampling_param;
-#endif
- capture_remote_cb(GTK_WIDGET(w), FALSE);
-}
-#endif
-
-static void change_pipe_name_cb(gpointer dialog _U_, gint btn, gpointer data)
-{
- guint i;
- interface_t device;
- gchar *temp, *optname, *snaplen_string/*, *oldname = ""*/;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *pipe_te;
-
- switch(btn) {
- case(ESD_BTN_OK):
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp((gchar *)data, device.name) == 0) {
- simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
- "%sA pipe with this name already exists.%s",
- simple_dialog_primary_start(), simple_dialog_primary_end());
- if_cb = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
- pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, 0, &optname, -1);
- if (strcmp(optname, (gchar *) data) == 0) {
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, pipe_name, -1);
- gtk_entry_set_text(GTK_ENTRY(pipe_te), pipe_name);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- g_free(optname);
- }
- return;
- }
- }
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(pipe_name, device.name) == 0) {
- g_free(device.name);
- g_free(device.display_name);
- device.name = g_strdup((gchar *)data);
- device.display_name = g_strdup(device.name);
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- temp = g_strdup_printf("<b>%s</b>", device.display_name);
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, IFACE_HIDDEN_NAME, &optname, -1);
- if (strcmp(optname, pipe_name) == 0) {
-#if defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
-#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
-#else
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
-#endif
-#if 0
- oldname = g_strdup(pipe_name);
-#endif
- pipe_name = g_strdup(device.name);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
-
- g_free(optname);
- }
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
-#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
-#endif
- }
- refresh_non_local_interface_lists();
- break;
- }
- }
- break;
- case(ESD_BTN_CANCEL): {
- if_cb = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
- pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- model = gtk_tree_view_get_model(if_cb);
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, 0, &optname, -1);
- if (strcmp(optname, (gchar *) data) == 0) {
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, pipe_name, -1);
- gtk_entry_set_text(GTK_ENTRY(pipe_te), pipe_name);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- g_free(optname);
- }
- break;
- }
- default:
- g_assert_not_reached();
- }
-}
-
-static void
-add_pipe_cb(gpointer w _U_)
-{
- interface_t device;
- gint indx;
- GtkTreeView *if_cb;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *temp, *path_str, *snaplen_string;
- GtkWidget *pipe_te;
- const gchar *g_save_file;
- gchar *name;
- guint i;
- gpointer dialog;
-
- if (!pipe_name)
- return;
-
- pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- g_save_file = gtk_entry_get_text(GTK_ENTRY(pipe_te));
- name = g_strdup(g_save_file);
- if (strcmp(name, "New pipe") == 0 || strcmp(name, "") == 0) {
- g_free(name);
- return;
- }
- if (strcmp(pipe_name, "New pipe") != 0) {
- if (strcmp(pipe_name, name) != 0) {
- dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
- "%sDo you want to change %s to %s?%s",
- simple_dialog_primary_start(), pipe_name, name, simple_dialog_primary_end());
- simple_dialog_set_cb(dialog, change_pipe_name_cb, name);
- }
- } else {
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(name, device.name) == 0) {
- g_free(name);
- return;
- }
- }
- pipe_name = g_strdup(g_save_file);
- memset(&device, 0, sizeof(device));
- device.name = g_strdup(g_save_file);
- device.display_name = g_strdup(device.name);
- device.hidden = FALSE;
- device.selected = TRUE;
- device.type = IF_PIPE;
- device.pmode = global_capture_opts.default_options.promisc_mode;
- device.has_snaplen = global_capture_opts.default_options.has_snaplen;
- device.snaplen = global_capture_opts.default_options.snaplen;
- device.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
- device.timestamp_type = g_strdup(global_capture_opts.default_options.timestamp_type);
- device.addresses = NULL;
- device.no_addresses = 0;
- device.last_packets = 0;
- device.links = NULL;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
-#endif
- device.active_dlt = -1;
- device.if_info.name = g_strdup(g_save_file);
- device.if_info.friendly_name = NULL;
- device.if_info.vendor_description = NULL;
- device.if_info.addrs = NULL;
- device.if_info.loopback = FALSE;
- device.if_info.type = IF_PIPE;
- device.if_info.extcap = NULL;
- device.external_cap_args_settings = NULL;
-#if defined(HAVE_PCAP_CREATE)
- device.monitor_mode_enabled = FALSE;
- device.monitor_mode_supported = FALSE;
-#endif
- global_capture_opts.num_selected++;
-
- indx = global_capture_opts.all_ifaces->len;
- temp = g_strdup_printf("<b>%s</b>", device.display_name);
-
- snaplen_string = g_strdup_printf("%d", device.snaplen);
-
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- path_str = g_strdup_printf("%d", indx);
- model = gtk_tree_view_get_model(if_cb);
- gtk_tree_model_get_iter_from_string(model, &iter, path_str);
- g_array_append_val(global_capture_opts.all_ifaces, device);
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
-#if defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
-#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
-#else
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
-#endif
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
-#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
-#endif
- }
-
- /* Refresh all places that are displaying an interface list
- that includes interfaces other than local interfaces
- (such as pipes). */
- refresh_non_local_interface_lists();
-
- g_free(name);
- }
-}
-
-static void
-pipe_new_bt_clicked_cb(GtkWidget *w _U_, gpointer data _U_)
-{
- GtkWidget *name_te = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- GtkTreeView *pipe_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
- GtkListStore *store;
- GtkTreeIter iter;
-
- /* Add a new entry to the pipe list. */
-
- store = GTK_LIST_STORE(gtk_tree_view_get_model(pipe_l));
- gtk_list_store_append(store, &iter);
-
- gtk_list_store_set(store, &iter, 0, "New pipe", -1);
- pipe_name = "New pipe";
-
- /* Select the item. */
- gtk_tree_selection_select_iter(gtk_tree_view_get_selection(pipe_l), &iter);
-
- gtk_editable_select_region(GTK_EDITABLE(name_te), 0, -1);
-
- gtk_widget_grab_focus(name_te);
-}
-
-static void
-pipe_del_bt_clicked_cb(GtkWidget *w _U_, gpointer data _U_)
-{
- GtkWidget *pipe_l = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY);
- GtkWidget *name_te = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- GtkTreeSelection *sel;
- GtkTreeModel *model, *optmodel;
- GtkTreeIter iter, optiter;
- GtkTreeView *if_cb;
- GtkTreePath *path;
- gchar *name, *optname = NULL;
- guint i;
- gint32 num;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(pipe_l));
- /* If something was selected */
-
- if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
- gtk_tree_model_get(model, &iter, 0, &name, -1);
- path = gtk_tree_model_get_path(model, &iter);
- if (gtk_tree_path_get_depth(path) == 0) {
- num = 0;
- } else {
- num = gtk_tree_path_get_indices(path)[0];
- }
- if (name != NULL && num < (gint)global_capture_opts.all_ifaces->len) {
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- if (strcmp(g_array_index(global_capture_opts.all_ifaces, interface_t, i).name, name) == 0) {
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- break;
- }
- }
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- gtk_entry_set_text(GTK_ENTRY(name_te), "");
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- optmodel = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first (optmodel, &optiter)) {
- do {
- gtk_tree_model_get(optmodel, &optiter, IFACE_HIDDEN_NAME, &optname, -1);
- if (optname != NULL && strcmp(optname, name) == 0) {
- gtk_list_store_remove(GTK_LIST_STORE(gtk_tree_view_get_model(if_cb)), &optiter);
- break;
- }
- } while (gtk_tree_model_iter_next(optmodel, &optiter));
- g_free(optname);
- }
- }
- g_free(name);
- }
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- gtk_tree_selection_select_iter(sel, &iter);
- } else {
- gtk_widget_set_sensitive(name_te, FALSE);
- }
-
- /* Refresh all places that are displaying an interface list
- that includes interfaces other than local interfaces
- (such as pipes). */
- refresh_non_local_interface_lists();
-}
-
-static void
-pipe_name_te_changed_cb(GtkWidget *w _U_, gpointer data _U_)
-{
- GtkWidget *name_te = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- GtkWidget *pipe_l = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY);
- const gchar *name;
- GtkTreeSelection *sel;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(pipe_l));
- name = gtk_entry_get_text(GTK_ENTRY(name_te));
-
- /* if something was selected */
- if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, name, -1);
- }
-}
-
-static void
-fill_pipe_list(void)
-{
- guint i;
- interface_t device;
- GtkTreeIter iter;
- GtkTreeView *pipe_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
- GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(pipe_l));
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (device.type == IF_PIPE) {
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, 0, device.name, -1);
- } else {
- continue;
- }
- }
-}
-
-static void
-pipe_sel_list_cb(GtkTreeSelection *sel, gpointer data _U_)
-{
- /* GtkWidget *pipe_l = GTK_WIDGET(gtk_tree_selection_get_tree_view(sel));*/
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *name_te = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- GtkWidget *del_bt = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_DEL_KEY);
- gchar *name = NULL;
-
- if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
- gtk_tree_model_get(model, &iter, 0, &name, -1);
- if (name) {
- if (name_te != NULL) {
- gtk_entry_set_text(GTK_ENTRY(name_te), name ? name : "");
- gtk_widget_set_sensitive(name_te, TRUE);
- selected_name = gtk_entry_get_text(GTK_ENTRY(name_te));
- pipe_name = g_strdup(selected_name);
- }
- if (del_bt != NULL) {
- gtk_widget_set_sensitive(del_bt, TRUE);
- }
- g_free(name);
- }
- }
-}
-
-static void
-cancel_pipe_cb (gpointer w _U_)
-{
-#ifdef HAVE_PCAP_REMOTE
- if (interface_management_w && G_IS_OBJECT(interface_management_w)) {
- GtkWidget *remote_w;
- remote_w = (GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
- if (remote_w != NULL && G_IS_OBJECT(remote_w))
- window_destroy(remote_w);
- }
-#endif
- window_destroy(GTK_WIDGET(interface_management_w));
- pipe_name = NULL;
-}
-
-static void
-fill_local_list(void)
-{
- guint i;
- interface_t device;
- GtkTreeIter iter;
- GtkListStore *store;
- GtkTreeView *local_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_LOCAL_L_KEY));
-
-#ifdef _WIN32
- store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
-#else
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
-#endif
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (device.local && device.type != IF_PIPE && device.type != IF_STDIN) {
- gtk_list_store_append(store, &iter);
-
-#ifdef _WIN32
- gtk_list_store_set(store, &iter, 0, device.friendly_name, 1, device.name, 2, device.hidden, -1);
-#else
- gtk_list_store_set(store, &iter, 0, device.name, 1, device.hidden, -1);
-#endif
- } else {
- continue;
- }
- }
- gtk_tree_view_set_model(GTK_TREE_VIEW(local_l), GTK_TREE_MODEL(store));
-}
-
-static void local_hide_cb(GtkCellRendererToggle *cell _U_,
- gchar *path_str,
- gpointer data _U_)
-{
- gboolean hide, hide_enabled = TRUE;
- gchar *name;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeView *local_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_LOCAL_L_KEY));
-
- model = gtk_tree_view_get_model(local_l);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, 0+LOCAL_OFFSET, &name, 1+LOCAL_OFFSET, &hide, -1);
-
- /* See if this is the currently selected capturing device */
- if ((prefs.capture_device != NULL) && (*prefs.capture_device != '\0')) {
- guint i;
- interface_t device;
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if ((strcmp(device.display_name, prefs.capture_device) == 0) &&
- (strcmp(device.name, name) == 0)) {
- /* Don't allow current interface to be hidden */
- hide_enabled = FALSE;
- break;
- }
- }
- }
-
- if (hide_enabled) {
- if (hide) {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1+LOCAL_OFFSET, FALSE, -1);
- } else {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1+LOCAL_OFFSET, TRUE, -1);
- }
- } else {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Default interface cannot be hidden");
- }
-}
-
-static void
-apply_local_cb(GtkWidget *win _U_, gpointer *data _U_)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- gchar *name, *new_hide;
- gboolean hide;
- gint first_if = TRUE;
- GtkTreeView *local_l;
-
- if (global_capture_opts.all_ifaces->len > 0) {
- local_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_LOCAL_L_KEY));
- model = gtk_tree_view_get_model(local_l);
-
- new_hide = (gchar*)g_malloc0(MAX_VAL_LEN);
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, 0+LOCAL_OFFSET, &name, 1+LOCAL_OFFSET, &hide, -1);
- if (!hide) {
- continue;
- } else {
- if (first_if != TRUE) {
- g_strlcat (new_hide, ",", MAX_VAL_LEN);
- }
- g_strlcat (new_hide, name, MAX_VAL_LEN);
- first_if = FALSE;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- g_free(name);
- }
- /* write new "hidden" string to preferences */
- g_free(prefs.capture_devices_hide);
- prefs.capture_devices_hide = new_hide;
- hide_interface(g_strdup(new_hide));
-
- /* Refresh all places that are displaying an interface list
- that includes local interfaces, in case we've changed
- a property of the interface list that changes how it's
- displayed. */
- refresh_local_interface_lists();
-
- /* save changes to the preferences file */
- if (!prefs.gui_use_pref_save) {
- prefs_main_write();
- }
- }
-}
-
-void
-capture_dlg_refresh_if (void)
-{
- GtkTreeView *view;
-
- if (interface_management_w)
- fill_local_list();
-
- view = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- create_and_fill_model(GTK_TREE_VIEW(view));
- update_properties_all();
-}
-
-/*
- * We've been asked to rescan the system looking for interfaces.
- */
-static void
-rescan_local_cb(GtkWidget *button _U_, gpointer *data _U_)
-{
- /* Refresh all places that are displaying an interface list
- that includes local interfaces. */
- refresh_local_interface_lists();
-}
-
-#if defined(HAVE_PCAP_REMOTE)
-static void
-fill_remote_list(void)
-{
- guint i;
- interface_t device;
- GtkTreeIter iter, child;
- gchar *host = "";
- GtkTreeView *remote_l;
- GtkTreeStore *store;
-
- num_selected = 0;
- remote_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_L_KEY));
- store = gtk_tree_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (device.local) {
- continue;
- } else {
- /* fill the store */
- if (strcmp(host, device.remote_opts.remote_host_opts.remote_host) != 0) {
- host = g_strdup(device.remote_opts.remote_host_opts.remote_host);
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store, &iter, 0, host, 3, "FALSE", -1);
- gtk_tree_store_append(store, &child, &iter);
- gtk_tree_store_set(store, &child, 1, device.name, 2, device.hidden, 3, "TRUE", -1);
- } else {
- gtk_tree_store_append(store, &child, &iter);
- gtk_tree_store_set(store, &child, 1, device.name, 2, device.hidden, 3, "TRUE", -1);
- }
- }
- }
- gtk_tree_view_set_model(GTK_TREE_VIEW(remote_l), GTK_TREE_MODEL(store));
- gtk_tree_view_expand_all(GTK_TREE_VIEW(remote_l));
-}
-
-static void
-button_hide_cb(GtkTreeViewColumn *column _U_, GtkCellRenderer *renderer,
- GtkTreeModel *model, GtkTreeIter *iter, gpointer data _U_)
-{
- gchar *enabled;
-
- gtk_tree_model_get(model, iter, 3, &enabled, -1);
- if (strcmp(enabled, "TRUE") == 0) {
- g_object_set(G_OBJECT(renderer), "visible", TRUE, NULL);
- } else if (strcmp(enabled, "FALSE") == 0){
- g_object_set(G_OBJECT(renderer), "visible", FALSE, NULL);
- }
-}
-
-static void remote_hide_cb(GtkCellRendererToggle *cell _U_,
- gchar *path_str,
- gpointer data _U_)
-{
- gboolean hide;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeView *remote_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_L_KEY));
-
- model = gtk_tree_view_get_model(remote_l);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, 2, &hide, -1);
-
- if (hide) {
- gtk_tree_store_set(GTK_TREE_STORE(model), &iter, 2, FALSE, -1);
- } else {
- gtk_tree_store_set(GTK_TREE_STORE(model), &iter, 2, TRUE, -1);
- }
-}
-
-static void
-ok_remote_cb(GtkWidget *win _U_, gpointer *data _U_)
-{
- GtkTreeIter iter, child;
- GtkTreeModel *model;
- gchar *name, *new_hide;
- gboolean hide;
- gint first_if = TRUE;
-
- GtkTreeView *remote_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_L_KEY));
- model = gtk_tree_view_get_model(remote_l);
-
- new_hide = (char *)g_malloc0(MAX_VAL_LEN);
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, 1, &name, 2, &hide, -1);
- if (!name && gtk_tree_model_iter_children(model, &child, &iter)) {
- do {
- gtk_tree_model_get(model, &child, 1, &name, 2, &hide, -1);
- if (!hide) {
- continue;
- } else {
- if (first_if != TRUE) {
- g_strlcat (new_hide, ",", MAX_VAL_LEN);
- }
- g_strlcat (new_hide, name, MAX_VAL_LEN);
- first_if = FALSE;
- }
- } while (gtk_tree_model_iter_next(model, &child));
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- g_free(name);
- }
- hide_interface(new_hide);
-
- /* Refresh all places that are displaying an interface list
- that includes interfaces other than local interfaces
- (such as remote interfaces). */
- refresh_non_local_interface_lists();
-}
-
-static gboolean
-select_host_cb(GtkTreeSelection *selection _U_,
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean path_currently_selected _U_,
- gpointer data _U_)
-{
- GtkTreeIter iter;
-
- gtk_tree_model_get_iter (model, &iter, path);
- if (gtk_tree_model_iter_has_child(model, &iter)) {
- num_selected++;
- gtk_widget_set_sensitive((GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_REMOTE_DEL_BT_KEY), TRUE);
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-static void
-remove_remote_host(GtkWidget *w _U_, gpointer data _U_)
-{
- GtkTreeIter iter, child;
- GtkTreeModel *model;
- gchar *host;
- gint num_children, i;
- interface_t device;
- GtkTreeView *remote_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_L_KEY));
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(remote_l));
-
- model = gtk_tree_view_get_model(remote_l);
- if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
- gtk_tree_model_get(model, &iter, 0, &host, -1);
- if ((num_children = gtk_tree_model_iter_n_children(model, &iter)) > 0) {
- for (i = num_children-1; i >= 0; i--) {
- if (gtk_tree_model_iter_nth_child(model, &child, &iter, i)) {
- gtk_tree_store_remove(GTK_TREE_STORE(model), &child);
- }
- }
- }
- gtk_tree_store_remove(GTK_TREE_STORE(model), &iter);
- if (--num_selected == 0) {
- gtk_widget_set_sensitive((GtkWidget *)g_object_get_data(G_OBJECT(interface_management_w), E_REMOTE_DEL_BT_KEY), FALSE);
- }
- for (i = global_capture_opts.all_ifaces->len-1; i >= 0; i--) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (device.local) {
- continue;
- } else {
- if (strcmp(host, device.remote_opts.remote_host_opts.remote_host) == 0) {
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- capture_opts_free_interface_t(&device);
- }
- }
- }
-
- /* Refresh all places that are displaying an interface list
- that includes interfaces other than local interfaces
- (such as remote interfaces). */
- refresh_non_local_interface_lists();
- }
-}
-#endif
-
-static void
-show_add_interfaces_dialog(GtkWidget *bt _U_, GtkWidget *parent_win)
-{
- GtkWidget *vbox, *top_hb;
- GtkWidget *hbox, *bbox, *list_bb, *edit_fr, *pipe_fr, *pipe_sc, *pipe_l, *props_fr, *props_vb;
- GtkWidget *main_nb;
- GtkWidget *temp_page, *tmp;
- GtkWidget *pipe_hb, *pipe_bt, *pipe_lb, *pipe_te, *pipe_vb;
- GtkWidget *add_bt, *cancel_bt, *new_bt, *del_bt, *middle_hb;
- GtkWidget *local_fr, *local_l, *local_sc, *local_vb;
- GtkWidget *apply_bt, *refresh_bt;
- GtkCellRenderer *renderer, *toggle_renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *sel;
- GtkListStore *store;
-#if defined(HAVE_PCAP_REMOTE)
- GtkWidget *remote_fr, *remote_l, *remote_sc, *remote_vb;
- GtkWidget *delete_bt, *add_but, *ok_but;
- GtkWidget *button_hbox, *help_hbox;
- GtkTreeSelection *selection;
-#endif
-
- if (interface_management_w != NULL && G_IS_OBJECT(interface_management_w)) {
- /* There's already a "Manage Interfaces" dialog box; reactivate it. */
- reactivate_window(interface_management_w);
- return;
- }
-
- interface_management_w = window_new(GTK_WINDOW_TOPLEVEL, "Interface Management");
- gtk_window_set_transient_for(GTK_WINDOW(interface_management_w), GTK_WINDOW(parent_win));
- gtk_window_set_destroy_with_parent(GTK_WINDOW(interface_management_w), TRUE);
-
- gtk_window_set_default_size(GTK_WINDOW(interface_management_w), 700, 300);
-
- vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_container_add(GTK_CONTAINER(interface_management_w), vbox);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
-
- main_nb = gtk_notebook_new();
- gtk_box_pack_start(GTK_BOX(vbox), main_nb, TRUE, TRUE, 0);
-
- /* --- Pipes --- */
- temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
- tmp = gtk_label_new("Pipes");
- gtk_widget_show(tmp);
- hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX (hbox), tmp, TRUE, TRUE, 0);
-
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
-
- /* Pipe row */
- pipe_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(pipe_hb), 5);
- gtk_box_pack_start(GTK_BOX(temp_page), pipe_hb, TRUE, TRUE, 0);
-
- /* Container for each row of widgets */
- pipe_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(pipe_vb), 0);
- gtk_box_pack_start(GTK_BOX (pipe_hb), pipe_vb, TRUE, TRUE, 0);
- gtk_widget_show(pipe_vb);
-
- /* Top row: Buttons and pipe list */
- top_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_box_pack_start(GTK_BOX (pipe_vb), top_hb, TRUE, TRUE, 0);
- gtk_widget_show(top_hb);
-
- edit_fr = gtk_frame_new("");
- gtk_box_pack_start(GTK_BOX(top_hb), edit_fr, FALSE, FALSE, 0);
- gtk_widget_show(edit_fr);
-
- list_bb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, TRUE);
- gtk_container_set_border_width(GTK_CONTAINER(list_bb), 5);
- gtk_container_add(GTK_CONTAINER(edit_fr), list_bb);
- gtk_widget_show(list_bb);
-
- new_bt = ws_gtk_button_new_from_stock(GTK_STOCK_NEW);
- g_signal_connect(new_bt, "clicked", G_CALLBACK(pipe_new_bt_clicked_cb), NULL);
- gtk_widget_show(new_bt);
- gtk_box_pack_start (GTK_BOX (list_bb), new_bt, FALSE, FALSE, 0);
- gtk_widget_set_tooltip_text (new_bt, "Add a new pipe (with default properties)");
-
- del_bt = ws_gtk_button_new_from_stock(GTK_STOCK_DELETE);
- g_signal_connect(del_bt, "clicked", G_CALLBACK(pipe_del_bt_clicked_cb), NULL);
- gtk_widget_show(del_bt);
- gtk_widget_set_sensitive(del_bt, FALSE);
- gtk_box_pack_start (GTK_BOX (list_bb), del_bt, FALSE, FALSE, 0);
- gtk_widget_set_tooltip_text (del_bt, "Remove the selected pipe from the list");
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_PIPE_DEL_KEY, del_bt);
-
- pipe_fr = gtk_frame_new("Pipes");
- gtk_box_pack_start(GTK_BOX(top_hb), pipe_fr, TRUE, TRUE, 0);
- gtk_widget_show(pipe_fr);
-
- pipe_sc = scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(pipe_sc),
- GTK_SHADOW_IN);
-
- gtk_container_set_border_width (GTK_CONTAINER (pipe_sc), 5);
- gtk_container_add(GTK_CONTAINER(pipe_fr), pipe_sc);
- gtk_widget_show(pipe_sc);
-
- store = gtk_list_store_new(1, G_TYPE_STRING);
- pipe_l = tree_view_new(GTK_TREE_MODEL(store));
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pipe_l), FALSE);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(pipe_l), column);
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(pipe_l));
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY, pipe_l);
- g_signal_connect(sel, "changed", G_CALLBACK(pipe_sel_list_cb), pipe_vb);
- gtk_container_add(GTK_CONTAINER(pipe_sc), pipe_l);
- gtk_widget_show(pipe_l);
-
- fill_pipe_list();
-
- g_object_unref(G_OBJECT(store));
-
- props_fr = gtk_frame_new("");
- gtk_box_pack_start(GTK_BOX(pipe_vb), props_fr, FALSE, FALSE, 0);
- gtk_widget_show(props_fr);
-
- props_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(props_vb), 5);
- gtk_container_add(GTK_CONTAINER(props_fr), props_vb);
- gtk_widget_show(props_vb);
-
- middle_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX (props_vb), middle_hb, TRUE, TRUE, 0);
- gtk_widget_show(middle_hb);
-
- pipe_lb = gtk_label_new("Pipe:");
- gtk_box_pack_start(GTK_BOX(middle_hb), pipe_lb, FALSE, FALSE, 3);
- pipe_te = gtk_entry_new();
- gtk_widget_set_tooltip_text(GTK_WIDGET(pipe_te),
- "Enter the name of the pipe data should be captured from. "
- );
- gtk_box_pack_start(GTK_BOX(middle_hb), pipe_te, TRUE, TRUE, 3);
- gtk_widget_set_sensitive(pipe_te, FALSE);
- pipe_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
- gtk_widget_set_tooltip_text(GTK_WIDGET(pipe_bt),
- "Select a pipe from which data should be captured, "
- "instead of entering the pipe name directly. "
- );
- gtk_box_pack_start(GTK_BOX(middle_hb), pipe_bt, FALSE, FALSE, 0);
- g_signal_connect(pipe_te, "changed", G_CALLBACK(pipe_name_te_changed_cb), NULL);
- g_signal_connect(pipe_bt, "clicked", G_CALLBACK(capture_prep_pipe_cb), pipe_te);
-
- bbox = dlg_button_row_new(GTK_STOCK_SAVE, GTK_STOCK_CLOSE, NULL);
- gtk_box_pack_start(GTK_BOX(temp_page), bbox, FALSE, FALSE, 5);
-
- add_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
- g_signal_connect(add_bt, "clicked", G_CALLBACK(add_pipe_cb), interface_management_w);
- gtk_widget_set_tooltip_text(GTK_WIDGET(add_bt), "Add pipe to the list of interfaces.");
-
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
- g_signal_connect(GTK_WIDGET(cancel_bt), "clicked", G_CALLBACK(cancel_pipe_cb), interface_management_w);
- gtk_widget_set_tooltip_text(GTK_WIDGET(cancel_bt), "Cancel and exit dialog.");
-
- gtk_widget_show(bbox);
- gtk_widget_show(temp_page);
-
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY, pipe_te);
-
- /* --- Local interfaces --- */
- temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
- tmp = gtk_label_new("Local Interfaces");
- gtk_widget_show(tmp);
- hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(hbox), tmp, TRUE, TRUE, 0);
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
-
- local_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(local_vb), 0);
- gtk_box_pack_start(GTK_BOX(temp_page), local_vb, TRUE, TRUE, 0);
- gtk_widget_show(local_vb);
-
- local_fr = gtk_frame_new("Local Interfaces");
- gtk_box_pack_start(GTK_BOX(local_vb), local_fr, TRUE, TRUE, 0);
- gtk_widget_show(local_fr);
-
- local_sc = scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(local_sc),
- GTK_SHADOW_IN);
-
- gtk_container_set_border_width (GTK_CONTAINER (local_sc), 5);
- gtk_container_add(GTK_CONTAINER(local_fr), local_sc);
- gtk_widget_show(local_sc);
-
- local_l = gtk_tree_view_new();
-
-#ifdef _WIN32
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Friendly Name", renderer, "text", 0, NULL);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(local_l), column);
-#endif
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Interface Name", renderer, "text", 0+LOCAL_OFFSET, NULL);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, 0+LOCAL_OFFSET);
- gtk_tree_view_append_column(GTK_TREE_VIEW(local_l), column);
-
- toggle_renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes("Hide", GTK_CELL_RENDERER(toggle_renderer), "active", 1+LOCAL_OFFSET, NULL);
- g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK (local_hide_cb), NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(local_l), column);
- gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(toggle_renderer), TRUE);
-
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_LOCAL_L_KEY, local_l);
- gtk_container_add(GTK_CONTAINER(local_sc), local_l);
- gtk_widget_show(local_l);
-
- fill_local_list();
-
- bbox = dlg_button_row_new(GTK_STOCK_REFRESH, GTK_STOCK_APPLY, GTK_STOCK_CLOSE, NULL);
-
- gtk_box_pack_start(GTK_BOX(temp_page), bbox, FALSE, FALSE, 5);
- refresh_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_REFRESH);
- g_signal_connect(refresh_bt, "clicked", G_CALLBACK(rescan_local_cb), NULL);
- gtk_widget_set_tooltip_text(GTK_WIDGET(refresh_bt), "Rescan the local interfaces and refresh the list");
-
- cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
- g_signal_connect(GTK_WIDGET(cancel_bt), "clicked", G_CALLBACK(cancel_pipe_cb), interface_management_w);
- gtk_widget_set_tooltip_text(GTK_WIDGET(cancel_bt), "Cancel and exit dialog.");
-
- apply_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_APPLY);
- g_signal_connect(GTK_WIDGET(apply_bt), "clicked", G_CALLBACK(apply_local_cb), NULL);
- gtk_widget_set_tooltip_text(GTK_WIDGET(apply_bt), "Apply the changes to the general list of local interfaces");
-
- gtk_widget_show(bbox);
- gtk_widget_show(temp_page);
-
-
-#if defined (HAVE_PCAP_REMOTE)
- /* --- remote interfaces --- */
- temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
- tmp = gtk_label_new("Remote Interfaces");
- gtk_widget_show(tmp);
- hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX (hbox), tmp, TRUE, TRUE, 0);
- gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
-
- remote_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(remote_vb), 0);
- gtk_box_pack_start(GTK_BOX(temp_page), remote_vb, TRUE, TRUE, 0);
- gtk_widget_show(remote_vb);
-
- remote_fr = gtk_frame_new("Remote Interfaces");
- gtk_box_pack_start(GTK_BOX(remote_vb), remote_fr, TRUE, TRUE, 0);
- gtk_widget_show(remote_fr);
-
- remote_sc = scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(remote_sc),
- GTK_SHADOW_IN);
-
- gtk_container_set_border_width (GTK_CONTAINER (remote_sc), 5);
- gtk_container_add(GTK_CONTAINER(remote_fr), remote_sc);
- gtk_widget_show(remote_sc);
-
- remote_l = gtk_tree_view_new();
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Host", renderer, "text", 0, NULL);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(remote_l), column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", 1, NULL);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, 1);
- gtk_tree_view_append_column(GTK_TREE_VIEW(remote_l), column);
-
- toggle_renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes("Hide", GTK_CELL_RENDERER(toggle_renderer), "active", 2, NULL);
- g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK (remote_hide_cb), NULL);
- gtk_tree_view_column_set_cell_data_func(column, toggle_renderer, button_hide_cb, NULL, FALSE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(remote_l), column);
- gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(toggle_renderer), TRUE);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Control", renderer, "text", 3, NULL);
- gtk_tree_view_column_set_visible(column, FALSE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(remote_l), column);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(remote_l));
- gtk_tree_selection_set_select_function(selection, select_host_cb, NULL, FALSE);
-
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_L_KEY, remote_l);
- gtk_container_add(GTK_CONTAINER(remote_sc), remote_l);
- gtk_widget_show(remote_l);
-
- recent_remote_host_list_foreach(populate_existing_remotes, NULL);
- fill_remote_list();
-
- bbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_box_pack_start(GTK_BOX(temp_page), bbox, FALSE, FALSE, 5);
- gtk_widget_show(bbox);
-
- button_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_end(GTK_BOX(bbox), button_hbox, FALSE, FALSE, 0);
- gtk_widget_show(button_hbox);
- gtk_box_set_spacing(GTK_BOX(button_hbox), DLG_BUTTON_SPACING);
-
- help_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(bbox), help_hbox, FALSE, FALSE, 0);
- gtk_widget_show(help_hbox);
- gtk_box_set_spacing(GTK_BOX(help_hbox), DLG_BUTTON_SPACING);
-
- add_but = ws_gtk_button_new_from_stock(GTK_STOCK_ADD);
- g_object_set_data(G_OBJECT(bbox), GTK_STOCK_ADD, add_but);
- gtk_box_pack_start(GTK_BOX(help_hbox), add_but, FALSE, FALSE, 0);
- g_signal_connect(add_but, "clicked", G_CALLBACK(show_remote_dialog), NULL);
- gtk_widget_set_tooltip_text(GTK_WIDGET(add_but), "Add a remote host to the list");
- gtk_widget_show(add_but);
-
- delete_bt = ws_gtk_button_new_from_stock(GTK_STOCK_DELETE);
- g_object_set_data(G_OBJECT(bbox), GTK_STOCK_DELETE, delete_bt);
- gtk_box_pack_start(GTK_BOX(help_hbox), delete_bt, FALSE, FALSE, 0);
- g_signal_connect(delete_bt, "clicked", G_CALLBACK(remove_remote_host), NULL);
- gtk_widget_set_tooltip_text(GTK_WIDGET(delete_bt), "Remove a remote host from the list");
- gtk_widget_set_sensitive(GTK_WIDGET(delete_bt), FALSE);
- g_object_set_data(G_OBJECT(interface_management_w), E_REMOTE_DEL_BT_KEY, delete_bt);
- gtk_widget_show(delete_bt);
-
- ok_but = ws_gtk_button_new_from_stock(GTK_STOCK_APPLY);
- gtk_box_pack_end(GTK_BOX(button_hbox), ok_but, FALSE, FALSE, 0);
- g_signal_connect(GTK_WIDGET(ok_but), "clicked", G_CALLBACK(ok_remote_cb), NULL);
- gtk_widget_set_tooltip_text(GTK_WIDGET(ok_but), "Apply the changes to the general list of local interfaces");
- gtk_widget_show(ok_but);
-
- cancel_bt = ws_gtk_button_new_from_stock(GTK_STOCK_CLOSE);
- gtk_box_pack_end(GTK_BOX(button_hbox), cancel_bt, FALSE, FALSE, 0);
- g_signal_connect(GTK_WIDGET(cancel_bt), "clicked", G_CALLBACK(cancel_pipe_cb), interface_management_w);
- gtk_widget_set_tooltip_text(GTK_WIDGET(cancel_bt), "Cancel and exit dialog.");
- gtk_widget_show(cancel_bt);
-
- gtk_widget_show(temp_page);
-
-#endif
- gtk_widget_show_all(interface_management_w);
-}
-
-/* show capture prepare (options) dialog */
-
-/* XXX: Warning:
- Note that capture_interface_list() is called directly (or indirectly) during the
- creation of (and changes to) the capture options dialog window.
-
- Also note that capture_interface_list() indirectly runs the gtk main loop temporarily
- to process queued events (which may include button-presses, key-presses, etc).
- (This is done while awaiting a response from dumpcap which is invoked to obtain
- the capture interface list).
- This means other Wireshark callbacks can be invoked while the capture options window
- is being created or updated (in effect an "interrupt" can occur).
-
- Needless to say, "race conditions" may occur in "interrupt" code which depends upon the exact
- state of the capture options dialog window and which may be invoked during the
- creation of (or changes to) the capture options dialog window.
-
- For example: if a user hits "Capture:Options" and then immediately hits "Capture:Start",
- capture_start_cb() may be invoked before capture_prep_cb() has been completed (i.e., during
- a call to capture_interface_list() in the code which creates the capture options window).
- capture_start_cb() depends upon certain properties of the capture options window having been
- initialized and thus fails if the properties have not (yet) been initialized.
-
- An interlock has been added to handle this particular situation;
- Ideally a more general solution should be implemented since it's probably difficult
- (if not nearly impossible) to identify all the possible "race conditions".
-
- ? Prevent the temporary running of the gtk main loop in cases wherein dumpcap is invoked for a
- simple request/reply ? (e.g., capture_interface_list()) ??
-
- ? Other ??
-*/
-
-static gboolean
-columns_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- GtkWidget *menu = (GtkWidget *)data;
- GdkEventButton *event_button = NULL;
-
- /* context menu handler */
- if (event->type == GDK_BUTTON_PRESS) {
- event_button = (GdkEventButton *) event;
-
- /* To quote the "Gdk Event Structures" doc:
- * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
- if (event_button->button == 3) {
- gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, widget,
- event_button->button,
- event_button->time);
- g_signal_stop_emission_by_name(widget, "button_press_event");
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static void
-update_properties_all(void)
-{
- unsigned int i;
- interface_t device;
- gboolean capture_all;
- gboolean promisc_all;
- gboolean filter_all;
- gchar * filter_str;
- GtkWidget *promisc_b;
- GtkWidget *capture_b;
- GtkWidget *all_filter_te;
-
- /* If we don't have a Capture Options dialog open, there's nothing
- for us to do. */
- if (!cap_open_w)
- return;
-
- /* Determine whether all interfaces:
-
- are selected for capturing;
-
- all selected interfaces are in promiscuous mode;
-
- all selected interfaces have the same capture filter.
-
- Start out by assuming that all three are the case, and change that
- once we find an interface where it's not the case. */
- capture_all = TRUE;
- promisc_all = TRUE;
- filter_all = TRUE;
- filter_str = NULL;
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (!device.hidden) {
- if (!device.selected) {
- /* This interface isn't selected, so not all interfaces are selected. */
- capture_all = FALSE;
- } else {
- /* This interface is selected; is it in promiscuous mode? */
- if (!device.pmode) {
- /* No, so not all selected interfaces are in promiscuous mode. */
- promisc_all = FALSE;
- }
- /* Have we seen the same capture filter on all interfaces at
- which we've looked so far? */
- if (device.cfilter != NULL && filter_all) {
- /* Yes. Is this the first interface for which we've seen a
- filter? */
- if (filter_str == NULL) {
- /* First selected interface - save its capture filter;
- there aren't any filters against which to compare. */
- filter_str = g_strdup(device.cfilter);
- } else {
- /* Not the first selected interface; is its capture filter
- the same as the one the other interfaces we've looked
- at have? */
- if (strcmp(device.cfilter, filter_str) != 0) {
- /* No, so not all selected interfaces have the same capture
- filter. */
- g_free(filter_str);
- filter_str = NULL;
- filter_all = FALSE;
- }
- }
- }
- }
- }
- }
-
- /* If all interfaces are selected, check the "capture on all interfaces"
- checkbox, otherwise un-check it. */
- capture_b = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_KEY_ALL);
- g_signal_handler_block(capture_b, capture_all_handler_id);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(capture_b), capture_all);
- g_signal_handler_unblock(capture_b, capture_all_handler_id);
-
- /* If all selected interfaces are in promiscuous mode, check the global
- "promiscuous mode" checkbox, otherwise un-check it. */
- promisc_b = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY_ALL);
- g_signal_handler_block(promisc_b, promisc_all_handler_id);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_b), promisc_all);
- g_signal_handler_unblock(promisc_b, promisc_all_handler_id);
-
- /* If all selected interfaces have the same filter string, set the
- global filter string to it. */
- all_filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(cap_open_w), E_ALL_CFILTER_CM_KEY)));
- if (filter_all) {
- /* Either no interfaces were selected, or all selected interfaces
- have the same filter. In the former case, make the global capture
- filter empty; in the latter case, make it that filter. */
- if (filter_str != NULL) {
- gtk_entry_set_text(GTK_ENTRY(all_filter_te), filter_str);
- g_free(filter_str);
- } else {
- gtk_entry_set_text(GTK_ENTRY(all_filter_te), "");
- }
- } else {
- /* Not all selected interfaces have the same filter, so there is no
- global capture filter; make it empty to reflect that. */
- gtk_entry_set_text(GTK_ENTRY(all_filter_te), "");
- }
-}
-
-
-static gboolean
-column_button_pressed_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- GtkWidget *col = (GtkWidget *) data;
- GtkTreeView *view;
- GtkWidget *menu = (GtkWidget *)g_object_get_data(G_OBJECT(columns_menu_object), PM_COLUMNS_KEY);
-
- view = (GtkTreeView *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- g_object_set_data(G_OBJECT(view), E_MCAPTURE_COLUMNS_COLUMN_KEY, col);
- return columns_menu_handler (widget, event, menu);
-}
-
-
-void
-capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- GtkWidget *main_vb,
- *main_hb, *left_vb, *right_vb,
- *capture_fr, *capture_vb,
- *all_hb, *all_cb,
- *promisc_cb, *pcap_ng_cb,
- *file_fr, *file_vb,
- *file_hb, *file_bt, *file_lb, *file_te,
- *multi_hb, *multi_grid, *multi_files_on_cb,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_cbx,
- *file_interval_cb, *file_interval_sb, *file_interval_cbx,
- *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
- *stop_files_cb, *stop_files_sb, *stop_files_lb,
- *limit_fr, *limit_vb, *limit_hb, *limit_grid,
- *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_cbx,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_cbx,
- *display_fr, *display_vb,
- *sync_cb, *auto_scroll_cb, *hide_info_cb,
- *resolv_fr, *resolv_vb,
- *m_resolv_cb, *n_resolv_cb, *t_resolv_cb, *e_resolv_cb,
- *bbox, *close_bt,
- *all_filter_cm, *all_filter_te, *all_filter_bt, *all_filter_hb,
- *all_vb,
- *help_bt;
-#ifdef HAVE_AIRPCAP
- GtkWidget *decryption_cb;
- int err;
- gchar *err_str;
-#endif
- GtkWidget *iftype_cbx;
-
- GtkAdjustment *ringbuffer_nbf_adj,
- *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj,
- *ring_filesize_adj, *file_interval_adj;
- int row;
- guint32 value;
- gchar *cap_title;
- GtkWidget *view;
- GtkWidget *swindow;
- GtkCellRenderer *renderer;
- GtkCellRenderer *toggle_renderer;
- GtkTreeSelection *selection;
- GtkTreeViewColumn *column;
- gboolean if_present = TRUE;
- GList *all_cfilter_list, *cf_entry;
- window_geometry_t tl_geom;
- const gchar *new_cfilter;
-
- if (interfaces_dialog_window_present()) {
- destroy_if_window();
- }
- if (cap_open_w != NULL && G_IS_OBJECT(cap_open_w)) {
- /* There's already a "Capture Options" dialog box; reactivate it. */
- reactivate_window(cap_open_w);
- return;
- }
- init_columns_menu();
-
- /* use user-defined title if preference is set */
-
- cap_title = create_user_window_title("Wireshark: Capture Options");
-
- cap_open_complete = FALSE;
- cap_open_w = dlg_window_new(cap_title);
- g_free(cap_title);
-
-#ifdef HAVE_AIRPCAP
- /* update airpcap interface list */
-
- /* load the airpcap interfaces */
- g_airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
-
- /* If we don't get a list don't do any thing.
- * If the error is AIRPCAP_NOT_LOADED it avoids an unnecessary rescan of the packet list
- * ( see airpcap_loader.h for error codes).
- */
- if (g_airpcap_if_list == NULL) {
- if (err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
- g_free(err_str);
- }
- }else{
- decryption_cb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
- /* XXXX update_decryption_mode_list() triggers a rescan, should only be done if the mode is changed */
- update_decryption_mode_list(decryption_cb);
- /* select the first as default (THIS SHOULD BE CHANGED) */
- airpcap_if_active = airpcap_get_default_if(g_airpcap_if_list);
- }
-#endif
-
- main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_vb), DLG_OUTER_MARGIN);
- gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb);
-
- /* Capture-related options frame */
- capture_fr = frame_new("Capture");
- gtk_box_pack_start(GTK_BOX (main_vb), capture_fr, TRUE, TRUE, 0);
-
- capture_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(capture_vb), DLG_OUTER_MARGIN);
- gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
-
- swindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_set_size_request(swindow, 676, 100);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swindow), GTK_SHADOW_IN);
-
- view = gtk_tree_view_new ();
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW (view), TRUE);
- g_signal_connect(view, "row-activated", G_CALLBACK(options_interface_cb), (gpointer)cap_open_w);
-
- toggle_renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes("Capture", GTK_CELL_RENDERER(toggle_renderer), "active", CAPTURE, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK (toggle_callback), NULL);
- g_object_set (GTK_TREE_VIEW(view), "has-tooltip", TRUE, NULL);
- g_signal_connect (GTK_TREE_VIEW(view), "query-tooltip", G_CALLBACK (query_tooltip_tree_view_cb), NULL);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ("",
- GTK_CELL_RENDERER(renderer),
- "text", IFACE_HIDDEN_NAME,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_visible(column, FALSE);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW (view), -1, "Interface", renderer, "markup", INTERFACE, NULL);
- column = gtk_tree_view_get_column(GTK_TREE_VIEW (view), INTERFACE);
- gtk_tree_view_column_set_min_width(column, 200);
- gtk_tree_view_column_set_resizable(column, TRUE );
- gtk_tree_view_column_set_alignment(column, 0.5f);
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(INTERFACE));
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("INTERFACE"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ("Link-layer header", renderer, "text", LINK, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_clickable(column, TRUE);
- gtk_tree_view_column_set_reorderable(column, TRUE);
- gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW (view),LINK), TRUE );
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(LINK));
- g_signal_connect(gtk_tree_view_column_get_button(column), "button_press_event",
- G_CALLBACK(column_button_pressed_cb), column);
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("LINK"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- gtk_tree_view_column_set_alignment(column, 0.5f);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Prom. Mode", renderer, "text", PMODE, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- g_object_set(renderer, "xalign", 0.5f, NULL);
- gtk_tree_view_column_set_clickable(column, TRUE);
- gtk_tree_view_column_set_reorderable(column, TRUE);
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(PMODE));
- g_signal_connect(gtk_tree_view_column_get_button(column), "button_press_event",
- G_CALLBACK(column_button_pressed_cb), column);
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("PMODE"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- gtk_tree_view_column_set_alignment(column, 0.5f);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Snaplen [B]", renderer, "text", SNAPLEN, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_clickable(column, TRUE);
- gtk_tree_view_column_set_reorderable(column, TRUE);
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(SNAPLEN));
- g_signal_connect(gtk_tree_view_column_get_button(column), "button_press_event",
- G_CALLBACK(column_button_pressed_cb), column);
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("SNAPLEN"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- g_object_set(renderer, "xalign", 0.5f, NULL);
-
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Buffer [MiB]", renderer, "text", BUFFER, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_reorderable(column, TRUE);
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(BUFFER));
- gtk_tree_view_column_set_clickable(column, TRUE);
- g_signal_connect(gtk_tree_view_column_get_button(column), "button_press_event",
- G_CALLBACK(column_button_pressed_cb), column);
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("BUFFER"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- g_object_set(renderer, "xalign", 0.5f, NULL);
-#endif
-
-#if defined (HAVE_PCAP_CREATE)
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ("Mon. Mode", renderer, "text", MONITOR, NULL);
- gtk_tree_view_column_set_cell_data_func(column, renderer, activate_monitor, NULL, FALSE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_reorderable(column, TRUE);
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(MONITOR));
- gtk_tree_view_column_set_clickable(column, TRUE);
- g_signal_connect(gtk_tree_view_column_get_button(column), "button_press_event",
- G_CALLBACK(column_button_pressed_cb), column);
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("MONITOR"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- g_object_set(renderer, "xalign", 0.5f, NULL);
-#endif
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Capture Filter", renderer, "text", FILTER, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_alignment(column, 0.5f);
- create_and_fill_model(GTK_TREE_VIEW(view));
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
- gtk_tree_view_column_set_clickable(column, TRUE);
- gtk_tree_view_column_set_reorderable(column, TRUE);
- g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(FILTER));
- g_signal_connect(gtk_tree_view_column_get_button(column), "button_press_event",
- G_CALLBACK(column_button_pressed_cb), column);
- if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("FILTER"))
- gtk_tree_view_column_set_visible(column, TRUE);
- else
- gtk_tree_view_column_set_visible(column, FALSE);
- gtk_container_add (GTK_CONTAINER (swindow), view);
- gtk_box_pack_start(GTK_BOX(capture_vb), swindow, TRUE, TRUE, 0);
-
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY, view);
-
- main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
- gtk_box_pack_start(GTK_BOX(capture_vb), main_hb, FALSE, FALSE, 0);
- all_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(all_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), all_vb, TRUE, TRUE, 0);
-
- all_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(all_hb), 0);
- gtk_box_pack_start(GTK_BOX(all_vb), all_hb, TRUE, TRUE, 0);
-
- left_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
- gtk_box_pack_start(GTK_BOX(all_hb), left_vb, TRUE, TRUE, 0);
-
- right_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
- gtk_box_pack_start(GTK_BOX(all_hb), right_vb, FALSE, FALSE, 3);
-
- all_cb = gtk_check_button_new_with_mnemonic( "Capture on all interfaces");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(all_cb), FALSE);
- capture_all_handler_id = g_signal_connect(all_cb, "toggled", G_CALLBACK(capture_all_cb), NULL);
- gtk_widget_set_tooltip_text(all_cb, "Activate the box to capture on all interfaces. "
- "Deactivate it to capture on none and set the interfaces individually.");
- gtk_box_pack_start(GTK_BOX(left_vb), all_cb, TRUE, TRUE, 0);
-
- gtk_widget_set_sensitive(GTK_WIDGET(all_cb), if_present);
- /* Promiscuous mode row */
- promisc_cb = gtk_check_button_new_with_mnemonic("Use _promiscuous mode on all interfaces");
- if (!global_capture_session.session_started) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb), prefs.capture_prom_mode);
- } else {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb), get_all_prom_mode());
- }
- promisc_all_handler_id = g_signal_connect(promisc_cb, "toggled", G_CALLBACK(promisc_mode_callback), NULL);
-
- gtk_widget_set_tooltip_text(promisc_cb,
- "Usually a network adapter will only capture the traffic sent to its own network address. "
- "If you want to capture all traffic that all network adapters can \"see\", select this option. "
- "If you want to set this option on a per-interface basis, do not select this option. "
- "Instead, select the individual checkboxes in the interface list's \"Prom. Mode\" column. "
- "See the FAQ for some more details of capturing packets from a switched network.");
- gtk_box_pack_start(GTK_BOX(left_vb), promisc_cb, TRUE, TRUE, DLG_LABEL_SPACING);
-
- iftype_cbx = gtk_button_new_with_label("Manage Interfaces");
- gtk_widget_set_tooltip_text(iftype_cbx, "Add a new interface or pipe to capture from or remove "
- "an interface from the list.");
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY, iftype_cbx);
-
- gtk_box_pack_start(GTK_BOX(right_vb), iftype_cbx, FALSE, FALSE, 0);
- g_signal_connect(iftype_cbx, "clicked", G_CALLBACK(show_add_interfaces_dialog), NULL);
- gtk_widget_show(iftype_cbx);
-
- main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
- gtk_box_pack_start(GTK_BOX(main_vb), main_hb, FALSE, FALSE, 0);
-
- left_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
-
- right_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
-
- /* Filter row */
- all_filter_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_box_pack_start(GTK_BOX(all_vb), all_filter_hb, FALSE, FALSE, DLG_LABEL_SPACING);
-
- all_filter_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
- g_signal_connect(all_filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
- g_signal_connect(all_filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
- gtk_widget_set_tooltip_text(all_filter_bt,
- "Select a capture filter for all selected interfaces to reduce the amount of packets to be captured. "
- "See \"Capture Filters\" in the online help for further information how to use it."
- );
- gtk_box_pack_start(GTK_BOX(all_filter_hb), all_filter_bt, FALSE, FALSE, 0);
-
- /* Create the capture filter combo box*/
- all_filter_cm = gtk_combo_box_text_new_with_entry();
- g_object_set_data(G_OBJECT(cap_open_w), E_ALL_CFILTER_CM_KEY, all_filter_cm);
- all_filter_te = gtk_bin_get_child(GTK_BIN(all_filter_cm));
- colorize_filter_te_as_empty(all_filter_te);
- g_signal_connect(all_filter_te, "changed", G_CALLBACK(capture_all_filter_check_syntax_cb), NULL);
- g_signal_connect(all_filter_te, "destroy", G_CALLBACK(capture_filter_destroy_cb), NULL);
-
- all_cfilter_list = recent_get_cfilter_list(NULL);
- for (cf_entry = all_cfilter_list; cf_entry != NULL; cf_entry = g_list_next(cf_entry)) {
- new_cfilter = (const gchar *)cf_entry->data;
- /* If this is the default cfilter, don't put it in the list, as it'll
- be added later. */
- if (global_capture_opts.default_options.cfilter == NULL || strcmp(global_capture_opts.default_options.cfilter, new_cfilter) != 0) {
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(all_filter_cm), new_cfilter);
- }
- }
- if (global_capture_opts.default_options.cfilter && (strlen(global_capture_opts.default_options.cfilter) > 0)) {
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(all_filter_cm), global_capture_opts.default_options.cfilter);
- gtk_combo_box_set_active(GTK_COMBO_BOX(all_filter_cm), 0);
- }
-
- gtk_widget_set_tooltip_text(all_filter_cm,
- "Enter a capture filter for all selected interfaces to reduce the amount of packets to be captured. "
- "See \"Capture Filters\" in the online help for further information how to use it. "
- "Syntax checking can be disabled in Preferences -> Capture -> Syntax check capture filter."
- );
- gtk_box_pack_start(GTK_BOX(all_filter_hb), all_filter_cm, TRUE, TRUE, DLG_BUTTON_SPACING);
-
- /* let an eventually capture filters dialog know the text entry to fill in */
- g_object_set_data(G_OBJECT(all_filter_bt), E_FILT_TE_PTR_KEY, all_filter_te);
-
-#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- all_compile_bt = gtk_button_new_with_label("Compile selected BPFs");
- g_signal_connect(all_compile_bt, "clicked", G_CALLBACK(capture_all_filter_compile_cb), NULL);
- gtk_widget_set_tooltip_text(all_compile_bt,
- "Compile the capture filter expression and show the BPF (Berkeley Packet Filter) code.");
- /* We can't compile without any supported link-types, so disable the button in that case */
- gtk_box_pack_start(GTK_BOX(all_filter_hb), all_compile_bt, FALSE, FALSE, DLG_BUTTON_SPACING);
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
- } else {
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
- }
-#endif
-
- /* Capture file-related options frame */
- file_fr = frame_new("Capture Files");
- gtk_box_pack_start(GTK_BOX (left_vb), file_fr, TRUE, TRUE, 0);
-
- file_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(file_vb), DLG_OUTER_MARGIN);
- gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
-
- /* File row */
- file_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
-
- file_lb = gtk_label_new("File:");
- gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
-
- file_te = gtk_entry_new();
- gtk_widget_set_tooltip_text(file_te,
- "Enter the file name to which captured data will be written. "
- "If you don't enter something here, a temporary file will be used."
- );
- gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
-
- file_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
- gtk_widget_set_tooltip_text(file_bt,
- "Select a file to which captured data will be written, "
- "instead of entering the file name directly. "
- );
- gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 0);
-
- g_signal_connect(file_bt, "clicked", G_CALLBACK(capture_prep_file_cb), file_te);
-
- /* multiple files table */
- /* XXX We want multi_grid to shrink to its minimum size horizontally
- * and be left-aligned within file_fr. Using a horizontal GtkBox works
- * in Gtk2 but not Gtk3. The situation gets sillier below with limit_fr
- * and limit_grid because we have both horizontal and vertical GtkBoxes.
- */
- multi_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_box_pack_start(GTK_BOX(file_vb), multi_hb, FALSE, FALSE, 0);
- multi_grid = ws_gtk_grid_new();
- ws_gtk_grid_set_row_spacing(GTK_GRID(multi_grid), DLG_LABEL_SPACING);
- ws_gtk_grid_set_column_spacing(GTK_GRID(multi_grid), DLG_UNRELATED_SPACING);
- gtk_box_pack_start(GTK_BOX(multi_hb), multi_grid, FALSE, FALSE, 0);
- row = 0;
-
- /* multiple files row */
- multi_files_on_cb = gtk_check_button_new_with_mnemonic("Use _multiple files");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb),
- global_capture_opts.multi_files_on);
- g_signal_connect(multi_files_on_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity),
- cap_open_w);
- gtk_widget_set_tooltip_text(multi_files_on_cb,
- "Instead of using a single capture file, multiple files will be created. "
- "The generated file names will contain an incrementing number and the start time of the capture.");
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), multi_files_on_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- /* Pcapng row */
- pcap_ng_cb = gtk_check_button_new_with_mnemonic("Use pcapng format");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pcap_ng_cb), global_capture_opts.use_pcapng);
- gtk_widget_set_tooltip_text(pcap_ng_cb, "Capture packets in the next-generation capture file format. "
- "This is still experimental.");
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), pcap_ng_cb, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
- row++;
-
- /* Ring buffer filesize row */
- ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb),
- global_capture_opts.has_autostop_filesize || !global_capture_opts.has_file_interval);
- g_signal_connect(ring_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(ring_filesize_cb,
- "If the selected file size is exceeded, capturing switches to the next file.\n"
- "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.");
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), ring_filesize_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
- gtk_widget_set_size_request(ring_filesize_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), ring_filesize_sb, 1, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- ring_filesize_cbx = size_unit_combo_box_new(global_capture_opts.autostop_filesize);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), ring_filesize_cbx, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- value = size_unit_combo_box_set_value(global_capture_opts.autostop_filesize);
- gtk_adjustment_set_value(ring_filesize_adj, (gdouble) value);
-
- row++;
-
- /* Ring buffer duration row */
- file_interval_cb = gtk_check_button_new_with_label("Next file every");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_interval_cb),
- global_capture_opts.has_file_interval);
- g_signal_connect(file_interval_cb, "toggled",
- G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(file_interval_cb,
- "If the selected duration is exceeded, capturing switches to the next file.\n"
- "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.");
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), file_interval_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- file_interval_adj = (GtkAdjustment *)gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- file_interval_sb = gtk_spin_button_new (file_interval_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_interval_sb), TRUE);
- gtk_widget_set_size_request(file_interval_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), file_interval_sb, 1, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- file_interval_cbx = time_unit_combo_box_new(global_capture_opts.file_interval);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), file_interval_cbx, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- value = time_unit_combo_box_convert_value(global_capture_opts.file_interval);
- gtk_adjustment_set_value(file_interval_adj, (gdouble) value);
- row++;
-
- /* Ring buffer files row */
- ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
- global_capture_opts.has_ring_num_files);
- g_signal_connect(ringbuffer_nbf_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(ringbuffer_nbf_cb,
- "After capturing has switched to the next file and the given number of files has exceeded, "
- "the oldest file will be removed."
- );
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), ringbuffer_nbf_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.ring_num_files,
- 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
- ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
- gtk_widget_set_size_request(ringbuffer_nbf_sb, 80, -1);
- g_signal_connect(ringbuffer_nbf_sb, "changed", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), ringbuffer_nbf_sb, 1, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- ringbuffer_nbf_lb = gtk_label_new("files");
- gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5f);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), ringbuffer_nbf_lb, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- row++;
-
- /* Capture limits frame */
- limit_fr = frame_new("Stop Capture Automatically After...");
- gtk_box_pack_start(GTK_BOX (left_vb), limit_fr, TRUE, TRUE, 0);
-
- limit_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(limit_vb), DLG_OUTER_MARGIN);
- gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
-
- /* limits table */
- limit_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
- gtk_box_pack_start(GTK_BOX(limit_vb), limit_hb, FALSE, FALSE, 0);
- limit_grid = ws_gtk_grid_new();
- ws_gtk_grid_set_row_spacing(GTK_GRID(limit_grid), DLG_LABEL_SPACING);
- ws_gtk_grid_set_column_spacing(GTK_GRID(limit_grid), DLG_UNRELATED_SPACING);
- gtk_box_pack_start(GTK_BOX(limit_hb), limit_grid, FALSE, FALSE, 0);
- row = 0;
-
- /* Packet count row */
- stop_packets_cb = gtk_check_button_new();
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_packets_cb),
- global_capture_opts.has_autostop_packets);
- g_signal_connect(stop_packets_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(stop_packets_cb, "Stop capturing after the specified number of packets have been captured.");
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_packets_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_packets,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
- gtk_widget_set_size_request(stop_packets_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_packets_sb, 1, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_packets_lb = gtk_label_new("packet(s)");
- gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5f);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_packets_lb, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- /* Filesize row */
- stop_filesize_cb = gtk_check_button_new();
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_filesize_cb),
- global_capture_opts.has_autostop_filesize);
- g_signal_connect(stop_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(stop_filesize_cb, "Stop capturing after the specified amount of data has been captured.");
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_cb, 3, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
- gtk_widget_set_size_request(stop_filesize_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_sb, 4, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_filesize_cbx = size_unit_combo_box_new(global_capture_opts.autostop_filesize);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_cbx, 5, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- value = size_unit_combo_box_set_value(global_capture_opts.autostop_filesize);
- gtk_adjustment_set_value(stop_filesize_adj, (gdouble) value);
-
- row++;
-
- /* Files row */
- stop_files_cb = gtk_check_button_new();
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_files_cb),
- global_capture_opts.has_autostop_files);
- g_signal_connect(stop_files_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(stop_files_cb, "Stop capturing after the given number of \"file switches\" have been done.");
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_files_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_files,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
- gtk_widget_set_size_request(stop_files_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_files_sb, 1, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_files_lb = gtk_label_new("file(s)");
- gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5f);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_files_lb, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- /* Duration row */
- stop_duration_cb = gtk_check_button_new();
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_duration_cb),
- global_capture_opts.has_autostop_duration);
- g_signal_connect(stop_duration_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(stop_duration_cb, "Stop capturing after the specified amount of time has passed.");
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_cb, 3, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
- gtk_widget_set_size_request(stop_duration_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_sb, 4, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_duration_cbx = time_unit_combo_box_new(global_capture_opts.autostop_duration);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_cbx, 5, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- value = time_unit_combo_box_convert_value(global_capture_opts.autostop_duration);
- gtk_adjustment_set_value(stop_duration_adj, (gdouble) value);
- row++;
-
- /* Display-related options frame */
- display_fr = frame_new("Display Options");
- gtk_box_pack_start(GTK_BOX (right_vb), display_fr, TRUE, TRUE, 0);
-
- display_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_LABEL_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(display_vb), DLG_OUTER_MARGIN);
- gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
-
- /* "Update display in real time" row */
- sync_cb = gtk_check_button_new_with_mnemonic(
- "_Update list of packets in real time");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sync_cb),
- global_capture_opts.real_time_mode);
- g_signal_connect(sync_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(sync_cb,
- "Using this option will show the captured packets immediately on the main screen. "
- "Please note: this will slow down capturing, so increased packet drops might appear.");
- gtk_box_pack_start(GTK_BOX (display_vb), sync_cb, FALSE, TRUE, 0);
-
- /* "Auto-scroll live update" row */
- auto_scroll_cb = gtk_check_button_new_with_mnemonic("_Automatically scroll during live capture");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
- gtk_widget_set_tooltip_text(auto_scroll_cb,
- "This will scroll the \"Packet List\" automatically to the latest captured packet, "
- "when the \"Update List of packets in real time\" option is used.");
- gtk_box_pack_start(GTK_BOX (display_vb), auto_scroll_cb, FALSE, TRUE, 0);
-
- /* "Hide capture info" row */
- hide_info_cb = gtk_check_button_new_with_mnemonic("_Hide capture info dialog");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_info_cb), !global_capture_opts.show_info);
- gtk_widget_set_tooltip_text(hide_info_cb, "Hide the capture info dialog while capturing.");
- gtk_box_pack_start(GTK_BOX (display_vb), hide_info_cb, FALSE, TRUE, 0);
-
- /* Name Resolution frame */
- resolv_fr = frame_new("Name Resolution");
- gtk_box_pack_start(GTK_BOX (right_vb), resolv_fr, TRUE, TRUE, 0);
-
- resolv_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_LABEL_SPACING, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(resolv_vb), DLG_OUTER_MARGIN);
- gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
-
- m_resolv_cb = gtk_check_button_new_with_mnemonic(
- "Resolve _MAC addresses");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
- gbl_resolv_flags.mac_name);
- gtk_widget_set_tooltip_text(m_resolv_cb, "Perform MAC layer name resolution while capturing.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), m_resolv_cb, FALSE, TRUE, 0);
-
- n_resolv_cb = gtk_check_button_new_with_mnemonic(
- "Resolve _network-layer names");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
- gbl_resolv_flags.network_name);
- gtk_widget_set_tooltip_text(n_resolv_cb, "Perform network layer name resolution while capturing.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), n_resolv_cb, FALSE, TRUE, 0);
-
- t_resolv_cb = gtk_check_button_new_with_mnemonic(
- "Resolve _transport-layer name");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb),
- gbl_resolv_flags.transport_name);
- gtk_widget_set_tooltip_text(t_resolv_cb,
- "Perform transport layer name resolution while capturing.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), t_resolv_cb, FALSE, TRUE, 0);
-
- e_resolv_cb = gtk_check_button_new_with_mnemonic(
- "Use _external network name resolver");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e_resolv_cb),
- gbl_resolv_flags.use_external_net_name_resolver);
- gtk_widget_set_tooltip_text(e_resolv_cb,
- "Use the (system's) configured name resolver (e.g., DNS) to resolve network names.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), e_resolv_cb, FALSE, TRUE, 0);
-
- /* Button row: "Start", "Cancel" and "Help" buttons */
- bbox = dlg_button_row_new(WIRESHARK_STOCK_CAPTURE_START, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
- gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
-
- ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
- g_signal_connect(ok_bt, "clicked", G_CALLBACK(capture_start_cb), NULL);
- gtk_widget_set_tooltip_text(ok_bt, "Start the capture process.");
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
- }
-
- close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
- gtk_widget_set_tooltip_text(close_bt,
- "Exit dialog.");
- window_set_cancel_button(cap_open_w, close_bt, window_cancel_button_cb);
-
- help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
- gtk_widget_set_tooltip_text(help_bt,
- "Show help about capturing.");
- g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), GUINT_TO_POINTER(HELP_CAPTURE_OPTIONS_DIALOG));
- gtk_widget_grab_default(ok_bt);
-
- /* Attach pointers to needed widgets to the capture prefs window/object */
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_KEY_ALL, all_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY_ALL, promisc_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PCAP_NG_KEY, pcap_ng_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_TE_KEY, file_te);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CBX_KEY, ring_filesize_cbx);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_INTERVAL_CB_KEY, file_interval_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_INTERVAL_SB_KEY, file_interval_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_INTERVAL_CBX_KEY, file_interval_cbx);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SYNC_KEY, sync_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_HIDE_INFO_KEY, hide_info_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CBX_KEY, stop_filesize_cbx);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CBX_KEY, stop_duration_cbx);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_M_RESOLVE_KEY, m_resolv_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_N_RESOLVE_KEY, n_resolv_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_T_RESOLVE_KEY, t_resolv_cb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_E_RESOLVE_KEY, e_resolv_cb);
-
- /* Set the sensitivity of various widgets as per the settings of other
- widgets. */
- capture_prep_adjust_sensitivity(NULL, cap_open_w);
-
- update_properties_all();
- update_visible_columns_menu ();
-
- /* Catch the "activate" signal on the text
- entries, so that if the user types Return there, we act as if the
- "OK" button had been selected, as happens if Return is typed if some
- widget that *doesn't* handle the Return key has the input focus. */
- /*dlg_set_activate(gtk_bin_get_child(GTK_BIN(if_cb)), ok_bt);*/
- dlg_set_activate(file_te, ok_bt);
- dlg_set_activate(all_filter_te, ok_bt);
- gtk_widget_grab_focus(all_filter_te);
-
- g_signal_connect(cap_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(cap_open_w, "destroy", G_CALLBACK(capture_prep_destroy_cb), NULL);
-
- window_get_geometry(top_level, &tl_geom);
- gtk_window_set_default_size(GTK_WINDOW(cap_open_w), tl_geom.width * 8 / 10, -1);
-
- gtk_widget_show_all(cap_open_w);
- window_present(cap_open_w);
-
- cap_open_complete = TRUE; /* "Capture:Start" is now OK */
- global_capture_session.session_started = TRUE;
-}
-
-/* user pressed the "Start" button (in dialog or toolbar) */
-void
-capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- interface_options interface_opts;
- guint i;
- gchar * filter_str;
-
-#ifdef HAVE_AIRPCAP
- airpcap_if_active = airpcap_if_selected;
- if (airpcap_if_active)
- airpcap_set_toolbar_start_capture(airpcap_if_active);
-#endif
-
- /* XXX - will closing this remove a temporary file? */
- if(!do_file_close(&cfile, FALSE, " before starting a new capture")){
- return;
- }
- if (cap_open_w) {
- /*
- * There's an options dialog; get the values from it and close it.
- */
- gboolean success;
-
- /* Determine if "capture start" while building of the "capture options" window */
- /* is in progress. If so, ignore the "capture start. */
- /* XXX: Would it be better/cleaner for the "capture options" window code to */
- /* disable the capture start button temporarily ? */
- if (cap_open_complete == FALSE) {
- return; /* Building options window: ignore "capture start" */
- }
- success = capture_dlg_prep(cap_open_w);
- if (success)
- window_destroy(GTK_WIDGET(cap_open_w));
- if (!success)
- return; /* error in options dialog */
- }
- if (global_capture_opts.num_selected == 0) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "You didn't specify an interface on which to capture packets.");
- return;
- }
-
- /* everything's prepared, now it's really time to start the capture */
-
- /* XXX - we might need to init other pref data as well... */
- main_auto_scroll_live_changed(auto_scroll_live);
-
- /* XXX - can this ever happen? */
- if (global_capture_session.state != CAPTURE_STOPPED)
- return;
-
- /* close the currently loaded capture file */
- cf_close((capture_file *)global_capture_session.cf);
-
- /* Copy the selected interfaces to the set of interfaces to use for
- this capture. */
- collect_ifaces(&global_capture_opts);
-
- if (capture_start(&global_capture_opts, &global_capture_session, &global_info_data, main_window_update)) {
- /* The capture succeeded, which means the capture filters specified are
- valid; add them to the recent capture filter lists for the interfaces.
-
- If the same capture filter is used for all the selected interfaces,
- add it to the global recent capture filter list as well. */
- filter_str = NULL;
- for (i = 0; i < global_capture_opts.ifaces->len; i++) {
- interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
- if (interface_opts.cfilter) {
- recent_add_cfilter(interface_opts.name, interface_opts.cfilter);
- if (filter_str == NULL) {
- /* First selected interface - save its capture filter. */
- filter_str = g_strdup(interface_opts.cfilter);
- } else {
- /* Not the first selected interface; is its capture filter
- the same as the one the other interfaces we've looked
- at have? */
- if (strcmp(interface_opts.cfilter, filter_str) != 0) {
- /* No, so not all selected interfaces have the same capture filter. */
- g_free(filter_str);
- filter_str = NULL;
- }
- }
- }
- }
- if (filter_str != NULL) {
- if (filter_str[0] != '\0') {
- recent_add_cfilter(NULL, filter_str);
- }
- g_free(filter_str);
- }
- }
-}
-
-
-/* user change linktype selection;, convert to internal DLT value */
-static void
-select_link_type_cb(GtkWidget *linktype_combo_box, gpointer data _U_)
-{
- gpointer ptr;
- int dlt;
- interface_t device;
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
- if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(linktype_combo_box), &ptr)) {
- g_assert_not_reached(); /* Programming error: somehow nothing is active */
- }
- if ((dlt = GPOINTER_TO_INT(ptr)) == -1) {
- g_assert_not_reached(); /* Programming error: somehow managed to select an "unsupported" entry */
- }
- device.active_dlt = dlt;
- g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
- capture_filter_check_syntax_cb(linktype_combo_box, data);
-}
-
-/* user pressed "File" button */
-static void
-capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
-{
- file_selection_browse(file_bt, file_te, "Wireshark: Specify a Capture File", FILE_SELECTION_WRITE_BROWSE);
-}
-
-/* user pressed "Pipe" button */
-static void
-capture_prep_pipe_cb(GtkWidget *pipe_bt, GtkWidget *pipe_te)
-{
- file_selection_browse(pipe_bt, pipe_te, "Wireshark: Specify a Pipe", FILE_SELECTION_WRITE_BROWSE);
-}
-
-
-/* convert dialog settings into capture_opts values */
-static gboolean
-capture_dlg_prep(gpointer parent_w) {
- GtkWidget *pcap_ng_cb,
- *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
- *sync_cb, *auto_scroll_cb, *hide_info_cb,
- *stop_packets_cb, *stop_packets_sb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_cbx,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_cbx,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_cbx,
- *file_interval_cb, *file_interval_sb, *file_interval_cbx,
- *stop_files_cb, *stop_files_sb,
- *m_resolv_cb, *n_resolv_cb, *t_resolv_cb, *e_resolv_cb;
- const gchar *g_save_file;
- gchar *cf_name;
- gchar *dirname;
- gint32 tmp;
-
- pcap_ng_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_PCAP_NG_KEY);
- file_te = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_TE_KEY);
- multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
- ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
- ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
- ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
- ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
- ring_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CBX_KEY);
- file_interval_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_INTERVAL_CB_KEY);
- file_interval_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_INTERVAL_SB_KEY);
- file_interval_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_INTERVAL_CBX_KEY);
- sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
- auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
- hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
- stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
- stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
- stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
- stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
- stop_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CBX_KEY);
- stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
- stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
- stop_duration_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CBX_KEY);
- stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
- stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
- m_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_M_RESOLVE_KEY);
- n_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_N_RESOLVE_KEY);
- t_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_T_RESOLVE_KEY);
- e_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_E_RESOLVE_KEY);
-
- if (global_capture_opts.num_selected == 0) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "You didn't specify an interface on which to capture packets.");
- return FALSE;
- }
- global_capture_opts.use_pcapng =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pcap_ng_cb));
- /* Wireshark always saves to a capture file. */
- global_capture_opts.saving_to_file = TRUE;
- g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
- if (g_save_file && g_save_file[0]) {
- /* User specified a file to which the capture should be written. */
- global_capture_opts.save_file = g_strdup(g_save_file);
- global_capture_opts.orig_save_file = g_strdup(g_save_file);
- /* Save the directory name for future file dialogs. */
- cf_name = g_strdup(g_save_file);
- dirname = get_dirname(cf_name); /* Overwrites cf_name */
- set_last_open_dir(dirname);
- g_free(cf_name);
- } else {
- /* User didn't specify a file; save to a temporary file. */
- global_capture_opts.save_file = NULL;
- }
-
- global_capture_opts.has_autostop_packets =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
- if (global_capture_opts.has_autostop_packets)
- global_capture_opts.autostop_packets =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
-
- global_capture_opts.has_autostop_duration =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
- if (global_capture_opts.has_autostop_duration) {
- global_capture_opts.autostop_duration =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
- global_capture_opts.autostop_duration =
- time_unit_combo_box_get_value(stop_duration_cbx, global_capture_opts.autostop_duration);
- }
-
- global_capture_opts.real_time_mode =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
-
- auto_scroll_live =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
-
- global_capture_opts.show_info =
- !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
- gbl_resolv_flags.mac_name = TRUE;
- else
- gbl_resolv_flags.mac_name = FALSE;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
- gbl_resolv_flags.network_name = TRUE;
- else
- gbl_resolv_flags.network_name = FALSE;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
- gbl_resolv_flags.transport_name = TRUE;
- else
- gbl_resolv_flags.transport_name = FALSE;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(e_resolv_cb)))
- gbl_resolv_flags.use_external_net_name_resolver = TRUE;
- else
- gbl_resolv_flags.use_external_net_name_resolver = FALSE;
-
- global_capture_opts.has_ring_num_files =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
-
- global_capture_opts.ring_num_files =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
- if (global_capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
- global_capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
-#if RINGBUFFER_MIN_NUM_FILES > 0
- else if (global_capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
- global_capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
-#endif
-
- global_capture_opts.multi_files_on =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
-
- global_capture_opts.has_file_interval =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_interval_cb));
- if (global_capture_opts.has_file_interval) {
- global_capture_opts.file_interval =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_interval_sb));
- global_capture_opts.file_interval =
- time_unit_combo_box_get_value(file_interval_cbx, global_capture_opts.file_interval);
- }
-
- global_capture_opts.has_autostop_files =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
- if (global_capture_opts.has_autostop_files)
- global_capture_opts.autostop_files =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
-
- if (global_capture_opts.multi_files_on) {
- global_capture_opts.has_autostop_filesize =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
- if (global_capture_opts.has_autostop_filesize) {
- tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
- tmp = size_unit_combo_box_convert_value(ring_filesize_cbx, tmp);
- if (tmp != 0) {
- global_capture_opts.autostop_filesize = tmp;
- } else {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "%sMultiple files: Requested file size too large.%s\n\n"
- "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GiB).",
- simple_dialog_primary_start(), simple_dialog_primary_end(), (guint32)G_MAXINT + 1);
- return FALSE;
- }
- }
-
- /* test if the settings are ok for a ringbuffer */
- if (global_capture_opts.save_file == NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "%sMultiple files: No capture file name given.%s\n\n"
- "You must specify a filename if you want to use multiple files.",
- simple_dialog_primary_start(), simple_dialog_primary_end());
- return FALSE;
- } else if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_interval) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "%sMultiple files: No file limit given.%s\n\n"
- "You must specify a file size or interval at which is switched to the next capture file\n"
- "if you want to use multiple files.",
- simple_dialog_primary_start(), simple_dialog_primary_end());
- g_free(global_capture_opts.save_file);
- global_capture_opts.save_file = NULL;
- return FALSE;
- }
- } else {
- global_capture_opts.has_autostop_filesize =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
- if (global_capture_opts.has_autostop_filesize) {
- tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
- tmp = size_unit_combo_box_convert_value(stop_filesize_cbx, tmp);
- if (tmp != 0) {
- global_capture_opts.autostop_filesize = tmp;
- } else {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "%sStop Capture: Requested file size too large.%s\n\n"
- "The setting \"after x byte(s)\" can't be greater than %u bytes (2GiB).",
- simple_dialog_primary_start(), simple_dialog_primary_end(), (guint32)G_MAXINT + 1);
- return FALSE;
- }
- }
- } /* multi_files_on */
- return TRUE;
-}
-
-static GtkTreeModel *
-create_and_fill_model(GtkTreeView *view)
-{
- GtkListStore *store;
- GtkTreeIter iter;
- GList *list;
- char *temp, *snaplen_string, *linkname;
- guint i;
- link_row *linkr = NULL;
- interface_t device;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- gint buffer;
-#endif
- gint snaplen;
- gboolean hassnap, pmode;
-
-#if defined(HAVE_PCAP_CREATE)
- store = gtk_list_store_new (9, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
-#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
- store = gtk_list_store_new (8, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
-#else
- store = gtk_list_store_new (7, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-#endif
-
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (!device.hidden) {
- if (device.no_addresses == 0) {
- temp = g_strdup_printf("<b>%s</b>", device.display_name);
- } else {
- temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
- }
- set_active_dlt(&device, global_capture_opts.default_options.linktype);
- linkname = NULL;
- for (list = device.links; list != NULL; list = g_list_next(list)) {
- linkr = (link_row*)(list->data);
- if (linkr->dlt == device.active_dlt) {
- linkname = g_strdup(linkr->name);
- break;
- }
- }
- if (!linkname)
- linkname = g_strdup("unknown");
- if (capture_dev_user_pmode_find(device.name, &pmode)) {
- device.pmode = pmode;
- }
- if (capture_dev_user_snaplen_find(device.name, &hassnap, &snaplen)) {
- /* Default snap length set in preferences */
- device.snaplen = snaplen;
- device.has_snaplen = hassnap;
- } else {
- /* No preferences set yet, use default values */
- device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
- device.has_snaplen = FALSE;
- }
-
- snaplen_string = g_strdup_printf("%d", device.snaplen);
-
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- if (capture_dev_user_buffersize_find(device.name) != -1) {
- buffer = capture_dev_user_buffersize_find(device.name);
- device.buffer = buffer;
- } else {
- device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
- }
-#endif
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- gtk_list_store_append (store, &iter);
-#if defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
-#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
- gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
-#else
- gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
-#endif
- g_free(linkname);
- }
- }
- gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
- return GTK_TREE_MODEL(store);
-}
-
-static gboolean
-query_tooltip_tree_view_cb (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_tip,
- GtkTooltip *tooltip,
- gpointer data _U_)
-{
- GtkTreeIter iter;
- GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
- GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
- GtkTreePath *path = NULL;
- gchar *tmp;
- GtkTreeViewColumn *column;
- GtkCellRenderer* renderer = NULL;
- GList *renderer_list;
- gint idx;
-
- char buffer[512];
-
- if (!gtk_tree_view_get_tooltip_context (tree_view, &x, &y, keyboard_tip, &model, &path, &iter))
- return FALSE;
-
- gtk_tree_model_get (model, &iter, 0, &tmp, -1);
-
- if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view), (gint) x, (gint) y, NULL, &column, NULL, NULL)) {
- idx = col_title_to_index((const gchar *)gtk_tree_view_column_get_title(column));
-
- switch (idx)
- {
- case CAPTURE: g_snprintf (buffer, sizeof(buffer), "Choose which interface (network adapter) will be used to capture packets from. "
- "Be sure to select the correct one, as it's a common mistake to select the wrong interface.");
- break;
- case INTERFACE: g_snprintf (buffer, sizeof(buffer), "Lists the interface name and the IP address(es) assigned to it. ");
- break;
- case LINK: g_snprintf (buffer, sizeof(buffer), "Link-layer type the interface supports.");
- break;
- case PMODE: g_snprintf (buffer, sizeof(buffer), "Usually a network adapter will only capture the traffic sent to its own network address. "
- "If you want to capture all traffic that the network adapter can \"see\", promiscuous mode should be configured.");
- break;
- case SNAPLEN: g_snprintf(buffer, sizeof(buffer), "Limit the maximum number of bytes to be captured from each packet. This size includes the "
- "link-layer header and all subsequent headers.");
- break;
-#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- case BUFFER: g_snprintf (buffer, sizeof(buffer), "The memory buffer size used while capturing. "
- "If you notice packet drops, you can try increasing this size.");
- break;
-#endif
-#if defined(HAVE_PCAP_CREATE)
- case MONITOR: g_snprintf (buffer, sizeof(buffer), "Usually a Wi-Fi adapter will, even in promiscuous mode, only capture "
- "the traffic on the BSS to which it's associated. "
- "If you want to capture all traffic that the Wi-Fi adapter can \"receive\", select this option. "
- "In order to see IEEE 802.11 headers or to see radio information for captured packets, "
- "it might be necessary to turn this option on.\n\n"
- "Note that, in monitor mode, the adapter might disassociate from the network to which it's associated.");
- break;
-#endif
- case FILTER: g_snprintf(buffer, sizeof(buffer), "Selected capture filter to reduce the amount of packets to be captured.");
- break;
- default: g_snprintf(buffer, sizeof(buffer), "another option");
- }
-
- gtk_tooltip_set_markup (tooltip, buffer);
- renderer_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
- /* get the first renderer */
- if (g_list_first(renderer_list)) {
- renderer = (GtkCellRenderer*)g_list_nth_data(renderer_list, 0);
- gtk_tree_view_set_tooltip_cell (tree_view, tooltip, path, column, renderer);
- }
- }
- gtk_tree_path_free (path);
-
- return TRUE;
-}
-
-#if defined (HAVE_PCAP_CREATE)
-static void
-activate_monitor(GtkTreeViewColumn *tree_column _U_, GtkCellRenderer *renderer,
- GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data _U_)
-{
- interface_t device;
- GtkTreePath *path = gtk_tree_model_get_path(tree_model, iter);
- int indx = 0;
-
- if (gtk_tree_path_get_depth(path) == 0) {
- indx = 0;
- } else {
- indx = gtk_tree_path_get_indices(path)[0];
- }
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, indx);
-
- if (device.monitor_mode_supported == TRUE) {
- g_object_set(G_OBJECT(renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
- } else {
- g_object_set(G_OBJECT(renderer), "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
- }
-}
-#endif
-
-/* user requested to destroy the dialog */
-static void
-capture_prep_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
-{
- GtkWidget *fs;
-#ifdef HAVE_PCAP_REMOTE
- GList *if_list;
-#endif
-
- if (!cap_open_w || !G_IS_OBJECT(cap_open_w))
- return;
- /* Is there a file selection dialog associated with this
- Capture Options dialog? */
- fs = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_FILE_SEL_DIALOG_PTR_KEY);
-
-#ifdef HAVE_PCAP_REMOTE
- if_list = (GList *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY);
- if (if_list && g_list_length(if_list)>0) {
- free_interface_list(if_list);
- }
-#endif
-
- if (fs != NULL && G_IS_OBJECT(fs)) {
- /* Yes. Destroy it. */
- window_destroy(fs);
- }
-
- /* Note that we no longer have a "Capture Options" dialog box. */
- cap_open_w = NULL;
-
-#ifdef HAVE_AIRPCAP
- /* update airpcap toolbar */
- if (airpcap_if_active)
- airpcap_set_toolbar_stop_capture(airpcap_if_active);
-#endif
-}
-
-
-#ifdef HAVE_PCAP_CREATE
-/* user changed the setting of the monitor-mode checkbox */
-static void
-capture_prep_monitor_changed_cb(GtkWidget *monitor, gpointer argp _U_)
-{
- GList *lt_entry;
- gchar *if_string;
- gboolean monitor_mode;
- if_capabilities_t *caps;
- gint linktype_count = 0, i;
- data_link_info_t *data_link_info;
- interface_t device;
- link_row *linkr;
- GtkWidget *linktype_combo_box = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY);
- GtkWidget *linktype_lb = (GtkWidget *)g_object_get_data(G_OBJECT(linktype_combo_box), E_CAP_LT_CBX_LABEL_KEY);
- gchar *auth_str = NULL;
-
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
-
-
- if_string = g_strdup(device.name);
- monitor_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor));
-#ifdef HAVE_PCAP_REMOTE
- if (device.remote_opts.remote_host_opts.auth_type == CAPTURE_AUTH_PWD) {
- auth_str = g_strdup_printf("%s:%s", device.remote_opts.remote_host_opts.auth_username,
- device.remote_opts.remote_host_opts.auth_password);
- }
-#endif
- caps = capture_get_if_capabilities(if_string, monitor_mode, auth_str, NULL, main_window_update);
- g_free(auth_str);
-
- if (caps != NULL) {
- g_signal_handlers_disconnect_by_func(linktype_combo_box, G_CALLBACK(select_link_type_cb), NULL );
- ws_combo_box_clear_text_and_pointer(GTK_COMBO_BOX(linktype_combo_box));
- for (i = (gint)g_list_length(device.links)-1; i >= 0; i--) {
- GList* rem = g_list_nth(device.links, i);
- device.links = g_list_remove_link(device.links, rem);
- g_list_free_1(rem);
- }
- device.active_dlt = -1;
- linktype_count = 0;
- device.monitor_mode_supported = caps->can_set_rfmon;
- device.monitor_mode_enabled = monitor_mode;
- for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
- linkr = (link_row *)g_malloc(sizeof(link_row));
- data_link_info = (data_link_info_t *)lt_entry->data;
- /*
- * For link-layer types libpcap/WinPcap doesn't know about, the
- * name will be "DLT n", and the description will be null.
- * We mark those as unsupported, and don't allow them to be
- * used - capture filters won't work on them, for example.
- */
- if (data_link_info->description != NULL) {
- ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(linktype_combo_box),
- data_link_info->description,
- GINT_TO_POINTER(data_link_info->dlt));
- linkr->dlt = data_link_info->dlt;
- if (linktype_count == 0) {
- device.active_dlt = data_link_info->dlt;
- }
- linkr->name = g_strdup(data_link_info->description);
- } else {
- gchar *str;
- /* XXX - should we just omit them? */
- str = g_strdup_printf("%s (not supported)", data_link_info->name);
- ws_combo_box_append_text_and_pointer_full(GTK_COMBO_BOX(linktype_combo_box),
- NULL,
- str,
- GINT_TO_POINTER(-1), /* Flag as "not supported" */
- FALSE);
- linkr->dlt = -1;
- linkr->name = g_strdup(str);
- g_free(str);
- }
- device.links = g_list_append(device.links, linkr);
- linktype_count++;
- }
- free_if_capabilities(caps);
- } else {
- /* We don't know whether this supports monitor mode or not;
- don't ask for monitor mode. */
- device.monitor_mode_enabled = FALSE;
- device.monitor_mode_supported = FALSE;
- }
- gtk_widget_set_sensitive(linktype_lb, linktype_count >= 2);
- gtk_widget_set_sensitive(linktype_combo_box, linktype_count >= 2);
- ws_combo_box_set_active(GTK_COMBO_BOX(linktype_combo_box),0);
- g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
-}
-#endif
-
-/*
- * Adjust the sensitivity of various widgets as per the current setting
- * of other widgets.
- */
-static void
-capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
-{
- GtkWidget *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_cbx,
- *file_interval_cb, *file_interval_sb, *file_interval_cbx,
- *sync_cb, *auto_scroll_cb,
- *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_cbx,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_cbx,
- *stop_files_cb, *stop_files_sb, *stop_files_lb;
-
- multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
- ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
- ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
- ringbuffer_nbf_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_LB_KEY);
- ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
- ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
- ring_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CBX_KEY);
- file_interval_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_INTERVAL_CB_KEY);
- file_interval_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_INTERVAL_SB_KEY);
- file_interval_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_INTERVAL_CBX_KEY);
- sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
- auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
- stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
- stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
- stop_packets_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_LB_KEY);
- stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
- stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
- stop_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CBX_KEY);
- stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
- stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
- stop_duration_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CBX_KEY);
- stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
- stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
- stop_files_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_LB_KEY);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
- /* "Update list of packets in real time" captures enabled; we don't
- support ring buffer mode for those captures, so turn ring buffer
- mode off if it's on, and make its toggle button, and the spin
- button for the number of ring buffer files (and the spin button's
- label), insensitive. */
-#if 0
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);
-#endif
-
- /* Auto-scroll mode is meaningful only in "Update list of packets
- in real time" captures, so make its toggle button sensitive. */
- gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
-
- /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);*/
- } else {
- /* "Update list of packets in real time" captures disabled; that
- means ring buffer mode is OK, so make its toggle button
- sensitive. */
-/* gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);*/
-
- /* Auto-scroll mode is meaningful only in "Update list of packets
- in real time" captures, so make its toggle button insensitive. */
- gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
-
- /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);*/
- }
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
- /* Ring buffer mode enabled. */
-
- /* Force at least one of the "file switch" conditions (we need at least one) */
- if ((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)) == FALSE) &&
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_interval_cb)) == FALSE)) {
- if (tb == ring_filesize_cb)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_interval_cb), TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
-
- /* The ring filesize spinbox is sensitive if the "Next capture file
- after N kilobytes" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cbx),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
-
- /* The ring interval spinbox is sensitive if the "Next capture file
- after N seconds" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(file_interval_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_interval_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_interval_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(file_interval_cbx),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_interval_cb)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cbx), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
- } else {
- /* Ring buffer mode disabled. */
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cbx),FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(file_interval_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_interval_sb),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_interval_cbx),FALSE);
-
- /* The maximum file size spinbox is sensitive if the "Stop capture
- after N kilobytes" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cbx),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
- }
-
- /* The maximum packet count spinbox is sensitive if the "Stop capture
- after N packets" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
-
- /* The capture duration spinbox is sensitive if the "Stop capture
- after N seconds" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_cbx),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
-}
-
-gboolean capture_dlg_window_present(void)
-{
- return (cap_open_w?TRUE:FALSE);
-}
-
-/*
- * Refresh everything visible that shows an interface list that
- * includes local interfaces.
- */
-void
-refresh_local_interface_lists(void)
-{
- /* Reload the local interface list. */
- scan_local_interfaces(main_window_update);
-
- /* If there's an interfaces dialog up, refresh it. */
- if (interfaces_dialog_window_present())
- refresh_if_window();
-
- /* If there's a capture options dialog up, refresh it. */
- if (capture_dlg_window_present())
- capture_dlg_refresh_if();
-
- /* If the welcome screen is up, refresh its interface list. */
- if (get_welcome_window() != NULL)
- welcome_if_panel_reload();
-
- /* Refresh the 802.11 toolbar. */
- tb80211_refresh_interfaces();
-}
-
-/*
- * Refresh everything visible that shows an interface list that
- * includes non-local interfaces.
- */
-void
-refresh_non_local_interface_lists(void)
-{
- /* If there's a capture options dialog up, refresh it. */
- if (capture_dlg_window_present())
- capture_dlg_refresh_if();
-
- /* If the welcome screen is up, refresh its interface list. */
- if (get_welcome_window() != NULL)
- welcome_if_panel_reload();
-}
-
-#endif /* HAVE_LIBPCAP */
-
-/*
- * Editor modelines
- *
- * Local Variables:
- * c-basic-offset: 2
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
- */
diff --git a/ui/gtk/capture_dlg.h b/ui/gtk/capture_dlg.h
deleted file mode 100644
index 0dfeea5a93..0000000000
--- a/ui/gtk/capture_dlg.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* capture_dlg.h
- * Definitions for the "Capture Options" dialog and dialog windows popped
- * up from it
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __CAPTURE_DLG_H__
-#define __CAPTURE_DLG_H__
-
-/* extern GtkWidget* wireless_tb; */
-
-/** @file
- * "Capture Options" dialog box.
- * @ingroup dialog_group
- */
-#include "capture_opts.h"
-#include <gtk/gtk.h>
-#include "ws_attributes.h"
-
-#define CR_MAIN_NB "compile_results_main_notebook"
-
-/** Initialize background capture filter syntax checking
- */
-void capture_filter_init(void);
-
-/** User requested the "Capture Options" dialog box by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void capture_prep_cb(GtkWidget *widget, gpointer data);
-
-/** User requested capture start by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void capture_start_cb(GtkWidget *widget, gpointer data);
-
-/** User requested capture stop by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void capture_stop_cb(GtkWidget *widget, gpointer data);
-
-/** User requested capture restart by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void capture_restart_cb(GtkWidget *widget, gpointer data);
-
-/** User requested the "Capture Airpcap" dialog box by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void
-capture_air_cb(GtkWidget *widget, gpointer data);
-
-gboolean
-capture_dlg_window_present(void);
-
-void
-enable_selected_interface(gchar *name, gboolean selected);
-
-void
-options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata);
-
-void
-capture_dlg_refresh_if(void);
-
-void
-update_visible_columns_menu (void);
-
-void
-update_visible_tree_view_columns(void);
-
-/*
- * Refresh everything visible that shows an interface list that
- * includes local interfaces.
- */
-extern void refresh_local_interface_lists(void);
-
-/*
- * Refresh everything visible that shows an interface list that
- * includes non-local interfaces.
- */
-extern void refresh_non_local_interface_lists(void);
-
-#endif /* capture_dlg.h */
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
deleted file mode 100644
index bae633e28e..0000000000
--- a/ui/gtk/capture_file_dlg.c
+++ /dev/null
@@ -1,2365 +0,0 @@
-/* capture_file_dlg.c
- * Dialog boxes for handling capture files
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include <wsutil/filesystem.h>
-#include <epan/prefs.h>
-
-#include "globals.h"
-#include <epan/color_filters.h>
-
-#include <wsutil/file_util.h>
-
-#include "ui/util.h"
-#include "ui/alert_box.h"
-#include "ui/simple_dialog.h"
-#include "ui/file_dialog.h"
-#include "ui/recent.h"
-#include "ui/ws_ui_util.h"
-
-#include "ui/gtk/gtkglobals.h"
-#include "ui/gtk/old-gtk-compat.h"
-#include "ui/gtk/keys.h"
-#include "ui/gtk/filter_dlg.h"
-#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/file_dlg.h"
-#include "ui/gtk/capture_file_dlg.h"
-#include "ui/gtk/drag_and_drop.h"
-#include "ui/gtk/export_pdu_dlg.h"
-#include "ui/gtk/main.h"
-#include "ui/gtk/color_dlg.h"
-#include "ui/gtk/packet_list.h"
-#ifdef HAVE_LIBPCAP
-#include "ui/gtk/capture_dlg.h"
-#endif
-#include "ui/gtk/stock_icons.h"
-#include "ui/gtk/range_utils.h"
-#include "ui/gtk/filter_autocomplete.h"
-
-#ifdef _WIN32
-#define USE_WIN32_FILE_DIALOGS
-#endif
-
-#ifdef USE_WIN32_FILE_DIALOGS
-#include <gdk/gdkwin32.h>
-#include <windows.h>
-#include "ui/win32/file_dlg_win32.h"
-#endif
-
-static gboolean do_file_save(capture_file *cf, gboolean dont_reopen);
-static gboolean file_save_as_cmd(capture_file *cf,
- gboolean must_support_all_comments,
- gboolean dont_reopen);
-static void file_select_file_type_cb(GtkWidget *w, gpointer data);
-static int set_file_type_list(GtkWidget *combo_box, capture_file *cf,
- gboolean must_support_all_comments);
-static gboolean test_file_close(capture_file *cf, gboolean from_quit,
- const char *before_what);
-
-#define E_FILE_TYPE_COMBO_BOX_KEY "file_type_combo_box"
-#define E_COMPRESSED_CB_KEY "compressed_cb"
-
-#define PREVIEW_TABLE_KEY "preview_table_key"
-#define PREVIEW_FORMAT_KEY "preview_format_key"
-#define PREVIEW_SIZE_KEY "preview_size_key"
-#define PREVIEW_DATA_RECORDS_KEY "preview_data_records_key"
-#define PREVIEW_FIRST_ELAPSED_KEY "preview_first_elapsed_key"
-
-/* XXX - can we make these not be static? */
-static gboolean color_selected;
-
-#define PREVIEW_STR_MAX 200
-
-
-/* set a new filename for the preview widget */
-static wtap *
-preview_set_filename(GtkWidget *prev, const gchar *cf_name)
-{
- GtkWidget *label;
- wtap *wth;
- int err = 0;
- gchar *err_info;
- gchar string_buff[PREVIEW_STR_MAX];
- gint64 filesize;
-
-
- /* init preview labels */
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY);
- gtk_label_set_text(GTK_LABEL(label), "-");
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_SIZE_KEY);
- gtk_label_set_text(GTK_LABEL(label), "-");
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_DATA_RECORDS_KEY);
- gtk_label_set_text(GTK_LABEL(label), "-");
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FIRST_ELAPSED_KEY);
- gtk_label_set_text(GTK_LABEL(label), "-");
-
- if (!cf_name) {
- return NULL;
- }
-
- if (test_for_directory(cf_name) == EISDIR) {
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY);
- gtk_label_set_text(GTK_LABEL(label), "directory");
- return NULL;
- }
-
- wth = wtap_open_offline(cf_name, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
- if (wth == NULL) {
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY);
- if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT) {
- gtk_label_set_text(GTK_LABEL(label), "unknown file format");
- } else {
- gtk_label_set_text(GTK_LABEL(label), "error opening file");
- }
- return NULL;
- }
-
- /* Find the size of the file. */
- filesize = wtap_file_size(wth, &err);
- if (filesize == -1) {
- gtk_label_set_text(GTK_LABEL(label), "error getting file size");
- wtap_close(wth);
- return NULL;
- }
- g_snprintf(string_buff, PREVIEW_STR_MAX, "%" G_GINT64_MODIFIER "d bytes", filesize);
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_SIZE_KEY);
- gtk_label_set_text(GTK_LABEL(label), string_buff);
-
- /* type */
- g_strlcpy(string_buff, wtap_file_type_subtype_string(wtap_file_type_subtype(wth)), PREVIEW_STR_MAX);
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY);
- gtk_label_set_text(GTK_LABEL(label), string_buff);
-
- return wth;
-}
-
-
-/* do a preview run on the currently selected capture file */
-static void
-preview_do(GtkWidget *prev, wtap *wth)
-{
- GtkWidget *label;
- int err;
- gchar *err_info;
- ws_file_preview_stats stats;
- ws_file_preview_stats_status status;
- gchar string_buff[PREVIEW_STR_MAX];
- gchar first_buff[PREVIEW_STR_MAX];
- time_t ti_time;
- struct tm *ti_tm;
- unsigned int elapsed_time;
-
- status = get_stats_for_preview(wth, &stats, &err, &err_info);
-
- if(status == PREVIEW_READ_ERROR) {
- /* XXX - give error details? */
- g_free(err_info);
- g_snprintf(string_buff, PREVIEW_STR_MAX, "error after reading %u records", stats.records);
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_DATA_RECORDS_KEY);
- gtk_label_set_text(GTK_LABEL(label), string_buff);
- wtap_close(wth);
- return;
- }
-
- /* packet count */
- if(status == PREVIEW_TIMED_OUT) {
- g_snprintf(string_buff, PREVIEW_STR_MAX, "more than %u data records (preview timeout)", stats.data_records);
- } else {
- g_snprintf(string_buff, PREVIEW_STR_MAX, "%u", stats.data_records);
- }
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_DATA_RECORDS_KEY);
- gtk_label_set_text(GTK_LABEL(label), string_buff);
-
- /* First packet */
- if(stats.have_times) {
- /*
- * We saw at least one record with a time stamp, so we can give
- * a start time (if we have a mix of records with and without
- * time stamps, and there were records without time stamps
- * before the one with a time stamp, this may be inaccurate).
- */
- ti_time = (long)stats.start_time;
- ti_tm = localtime( &ti_time );
- if (ti_tm) {
- g_snprintf(first_buff, PREVIEW_STR_MAX,
- "%04d-%02d-%02d %02d:%02d:%02d",
- ti_tm->tm_year + 1900,
- ti_tm->tm_mon + 1,
- ti_tm->tm_mday,
- ti_tm->tm_hour,
- ti_tm->tm_min,
- ti_tm->tm_sec);
- } else {
- g_snprintf(first_buff, PREVIEW_STR_MAX, "?");
- }
- } else {
- g_snprintf(first_buff, PREVIEW_STR_MAX, "unknown");
- }
-
- /* Elapsed time */
- if(status == PREVIEW_SUCCEEDED && stats.have_times) {
- /*
- * We didn't time out, so we looked at all packets, and we got
- * at least one packet with a time stamp, so we can calculate
- * an elapsed time from the time stamp of the last packet with
- * with a time stamp (if we have a mix of records with and without
- * time stamps, and there were records without time stamps after
- * the last one with a time stamp, this may be inaccurate).
- */
- elapsed_time = (unsigned int)(stats.stop_time-stats.start_time);
- if (elapsed_time/86400) {
- g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / %02u days %02u:%02u:%02u",
- first_buff, elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
- } else {
- g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / %02u:%02u:%02u",
- first_buff, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
- }
- } else {
- g_snprintf(string_buff, PREVIEW_STR_MAX, "%s / unknown", first_buff);
- }
- label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FIRST_ELAPSED_KEY);
- gtk_label_set_text(GTK_LABEL(label), string_buff);
-
- wtap_close(wth);
-}
-
-#if 0
-/* as the dialog layout will look very ugly when using the file chooser preview mechanism,
- simply use the same layout as in GTK2.0 */
-static void
-update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
-{
- GtkWidget *prev = GTK_WIDGET(data);
- char *cf_name;
- gboolean have_preview;
-
- cf_name = gtk_file_chooser_get_preview_filename(file_chooser);
-
- have_preview = preview_set_filename(prev, cf_name);
-
- g_free(cf_name);
-
- have_preview = TRUE;
- gtk_file_chooser_set_preview_widget_active(file_chooser, have_preview);
-}
-#endif
-
-
-/* the filename text entry changed */
-static void
-file_open_entry_changed(GtkWidget *w _U_, gpointer file_sel)
-{
- GtkWidget *prev = (GtkWidget *)g_object_get_data(G_OBJECT(file_sel), PREVIEW_TABLE_KEY);
- gchar *cf_name;
- gboolean have_preview;
- wtap *wth;
-
- /* get the filename */
- cf_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_sel));
-
- /* set the filename to the preview */
- wth = preview_set_filename(prev, cf_name);
- have_preview = (wth != NULL);
-
- g_free(cf_name);
-
- /* make the preview widget sensitive */
- gtk_widget_set_sensitive(prev, have_preview);
-
- /*
- * XXX - if the Open button isn't sensitive, you can't type into
- * the location bar and select the file or directory you've typed.
- * See
- *
- * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1791
- *
- * It's not as if allowing users to click Open when they've
- * selected a file that's not a valid capture file will cause
- * anything worse than an error dialog, so we'll leave the Open
- * button sensitive for now. Perhaps making it sensitive if
- * cf_name is NULL would also work, although I don't know whether
- * there are any cases where it would be non-null when you've
- * typed in the location bar.
- *
- * XXX - Bug 1791 also notes that, with the line removed, Bill
- * Meier "somehow managed to get the file chooser window somewhat
- * wedged in that neither the cancel or open buttons were responsive".
- * That seems a bit odd, given that, without this line, we're not
- * monkeying with the Open button's sensitivity, but...
- */
-#if 0
- /* make the open/save/... dialog button sensitive */
-
- gtk_dialog_set_response_sensitive(file_sel, GTK_RESPONSE_ACCEPT, have_preview);
-#endif
-
- /* do the actual preview */
- if (have_preview)
- preview_do(prev, wth);
-}
-
-
-/* copied from summary_dlg.c */</