Commit Graph

56 Commits

Author SHA1 Message Date
Mikael Kanstrup 9f27e5d7d1 dumpcap: Add support for 802.11ac monitor modes
Add dumpcap support for configuring 80MHz, 80+80MHz, 160MHz monitor
modes via nl80211.

Change-Id: I2ae8955670c2a9b5051e2223d45ce522459f2c5f
Reviewed-on: https://code.wireshark.org/review/13964
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-01 15:23:44 +00:00
Guy Harris cdb7a7a25d Fix appending the list of remote interfaces.
Don't assume if_list is non-null when append_remote_list() is called; it
won't be, if we didn't find any local interfaces.  Have
append_remote_list() return the final if_list value, and assign it to
if_list.

Change-Id: I05586d5b034f3d61aa38a20f6c6d2c69117b367e
Reviewed-on: https://code.wireshark.org/review/14191
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 02:04:00 +00:00
Guy Harris 842a9b5100 Replace extcap_interface_list() with append_extcap_interface_list().
Pull the "rebuild the list of extcap interfaces and, optionally, return
a list of if_infos for them" into a separate
extcap_reload_interface_list() routine, call it in the cases where we
don't want the if_infos list, and have append_extcap_interface_list()
call it, asking it for the if_infos list, and then append the interfaces
to that list.

Change-Id: I07478ab133859484b3e0916144971639f961224b
Reviewed-on: https://code.wireshark.org/review/14189
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 01:04:33 +00:00
Guy Harris 60f87ca919 Put the extcap interfaces at the *end* of the interface list.
The list should start with the native local interfaces, as returned by
pcap, so that we default to the interface pcap gives first, rather than
to whatever extcap interface happens to be at the beginning.

This also means that, if we're only calling extcap_interface_list() to
regenerate our internal data structures, we don't bother allocating -
and leaking! - a list of if_info structures.

Change-Id: Ida651b5b081883f118a300b9f57403f2dc5c4363
Ping-Bug: 12183
Reviewed-on: https://code.wireshark.org/review/14187
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 00:37:22 +00:00
João Valverde f0fb79d534 autotools: Use pkg-config autoconf macros for GLib/GTK
Remove mostly obsolete aclocal macros. Make GTK build flags a strict superset
of GLib flags. Use GTK build variables for GTK GUI and GLib elsewhere. Add
dependency flags explicitly instead of using WS_CPPFLAGS.

Some minor improvements and fixes for missing/unnecessary variables (no impact
on our test builds).

Change-Id: I3e1f067a875f79d6516c1fa7af986f17a7a6b671
Reviewed-on: https://code.wireshark.org/review/14005
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-21 07:51:55 +00:00
João Valverde 8bee8bad81 Add inet_pton/inet_ntop interface to libwsutil
Change-Id: Ifc344ed33f2f7ca09a6912a5adb49dc35f07c81f
Reviewed-on: https://code.wireshark.org/review/13881
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-19 15:55:09 +00:00
Guy Harris 50a9165831 Remove some {-I,/I} flags.
They should not be necessary.

Change-Id: I9246d86862392c65839c18d13d8634bcf510d55e
Reviewed-on: https://code.wireshark.org/review/13992
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-18 14:38:19 +00:00
Guy Harris b32a5ee98c Don't add the wiretap directory to the list of include directories.
If you include something from the wiretap directory, always precede it
with wiretap/.

Fix some includes of files in the top-level directory to use a path
relative to the current directory, not relative to the wiretap
directory.

This makes it a bit clearer what's being included.

Change-Id: Ib99655a13c6006cf6c3112e9d4db6f47df9aff54
Reviewed-on: https://code.wireshark.org/review/13990
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-18 12:55:26 +00:00
João Valverde 265a41e14d autotools: Don't use "user variables" to set build flags
GNU coding standards recommend against it and automake is designed
around it.

This allows overriding the global build flags using AM_CFLAGS, etc.,
or per object flags, something that is difficult or impossible currently
because of automake precedence rules.

Change-Id: I3f1ea12e560af5a46b2f04b342b1882bbf123f12
Reviewed-on: https://code.wireshark.org/review/13455
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-01-28 18:13:48 +00:00
Alexis La Goutte 80d7250e36 capture_sync(.h): fix api reference
The following parameters of sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, struct _info_data *cap_data, void(*update_cb)(void)) are not documented:
  parameter 'cap_data'

Change-Id: I3733c51eddbe94e9c0d680dd8436265b7878d70c
Reviewed-on: https://code.wireshark.org/review/13545
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-01-26 09:09:46 +00:00
Roland Knall 645516b041 extcap: Sort extcap interfaces alphabetically
The interface list is not sorted at all, leading to
a very chaotic list. This sorts it alphabetically, as
well as correct a type in extcap_init_interfaces.

Bug: 11998
Change-Id: Ib5381a1761e8f07f9ba7996b3e6276da063b3932
Reviewed-on: https://code.wireshark.org/review/13220
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-12 11:07:35 +00:00
Michael Mann 444dfda793 Allow "capture info data" to not be a singleton.
It was buried as a static variable in capture_info.c, and functions were refactored to allow a pointer to the info_data_t structure to be passed in. TShark and GTK will have their own single (global) copy of the structure, while it opens up Qt to have multiple instances.

Change-Id: Ic2d7a2ad574de43f457cb18b194d6bc3fffb6120
Reviewed-on: https://code.wireshark.org/review/12691
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-19 14:22:56 +00:00
Mikael Kanstrup 479ab3bcdc Fix memory leak in capture_get_if_capabilities
Valgrind reports memory leaks like these:
154 bytes in 10 blocks are possibly lost in loss record 8,660 of 11,855
  at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0xBD9EA38: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
  by 0xBDB3358: g_strndup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
  by 0xBDB49AD: g_strsplit (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
  by 0x502291: capture_get_if_capabilities (capture_ifinfo.c:269)
  by 0x50A4CC: scan_local_interfaces (iface_lists.c:186)
  by 0x4C4BBD: refresh_local_interface_lists (capture_dlg.c:6117)
  by 0x504EC8: iface_mon_handler2 (iface_monitor.c:113)
  by 0xC9ADF1D: ??? (in /lib/libnl-3.so.200.3.0)
  by 0xC56DF19: ??? (in /usr/lib/libnl-route-3.so.200.3.0)
  by 0xC9ABE5E: nl_cache_parse (in /lib/libnl-3.so.200.3.0)
  by 0xC9AF5CA: nl_msg_parse (in /lib/libnl-3.so.200.3.0)

Under certain conditions raw_list variable was not freed properly.

Change-Id: Ibbaf0d67d983ee6912cfc9dc1a3169bc773b03c9
Reviewed-on: https://code.wireshark.org/review/12112
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-25 13:13:58 +00:00
Balint Reczey c297df134b More spelling fixes found by lintian
Change-Id: Id218dec9e5a721d6c63fd34962ffe50b6ab8dd56
Reviewed-on: https://code.wireshark.org/review/11946
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Diederik de Groot <dkgroot@talon.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-20 05:47:29 +00:00
Guy Harris bdea0d4504 Check for ECHILD, not for "not ECHILD".
That makes the logic a bit clearer (and puts the "unexpected other
error" case at the end, where it should be).

Put all the errno checks inside an else clause, making it clearer that
it runs only if waitpid() returned -1.

Add comments, including comments explaining why just driving on after
getting EINTR should be OK.

Change-Id: Iaa1b151393fcec8b4f5bd560ef913a224400932b
Reviewed-on: https://code.wireshark.org/review/11951
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-18 19:40:36 +00:00
Stephan Kappertz 5c49facc4f Error from waitpid(): Fix Code is unreachable
Change-Id: Ib93bd7d62eb16177cfdcb82148c97a64f6e497b4
Reviewed-on: https://code.wireshark.org/review/11939
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-18 18:40:25 +00:00
Gerald Combs 527e032b80 Win32: Try to fix handle leaks in capture_sync.
If CreateProcess succeeds, close our child's primary thread handle. As
the PROCESS_INFORMATION page at
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684873.aspx
says,

    If the function succeeds, be sure to call the CloseHandle function
    to close the hProcess and hThread handles when you are finished with
    them. Otherwise, when the child process exits, the system cannot
    clean up the process structures for the child process because the
    parent process still has open handles to the child process.

Closing the handle immediately doesn't seem to do any harm here, but
add a note that we might want to store it and close it later.

In sync_interface_stats_open, close our message and data descriptors
after calling sync_pipe_wait_for_child.

Ping-Bug: 11702
Change-Id: I56e0625fdceb66fba822c2dc83e07d40844329a7
Reviewed-on: https://code.wireshark.org/review/11882
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-17 08:19:44 +00:00
Pascal Quantin 167874a62b Extcap: allow Wireshark to list extcap interfaces even when WinPcap / Npcap is not installed
Bug: 11715
Change-Id: I4a043c4a298506d51cb6bf8b97aac787113a7dfa
Reviewed-on: https://code.wireshark.org/review/11869
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Guenter Ebermann <guenter.ebermann@googlemail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-17 08:17:38 +00:00
Guy Harris 14c35c31d8 Create C handles for pipes before running dumpcap.
If the C handles can't be created, there's no point in running dumpcap.

Catch some more possible _open_osfhandle() failures while we're at it.

Change-Id: I2b955378705fc932f8d383804e908e95a957be44
Ping-Bug: 11702
Reviewed-on: https://code.wireshark.org/review/11890
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-17 08:08:44 +00:00
Guy Harris 9ec2cbb1c2 Catch failure of _open_osfhandle().
This may at least prevent the crash in bug 11702, by not returning
"success" with bogus file handles of -1, if the opens fail due to
leaks chewing up all the available slots.  More investigation needs to
be done to see why we're leaking.

Change-Id: I89ecff4b03bca140f05c838e1e2604a03409f803
Ping-Bug: 11702
Reviewed-on: https://code.wireshark.org/review/11881
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-16 21:40:33 +00:00
Guy Harris 0162e54075 Clean up includes of unistd.h, fcntl.h, and sys/stat.h.
Have wsutil/file_util.h include them on UN*X, just as it includes io.h
on Windows, so we can have a rule of "if you do file operations, include
<wsutil/file_util.h> and use the routines in it".

Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't
necessary (whether because of the addition of them to wsutil/file_util.h
or because they weren't needed in the first place).

Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f
Reviewed-on: https://code.wireshark.org/review/11619
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-07 21:52:23 +00:00
Gerald Combs b05803db4b CMake: Add /WX
Add "/WX" to the Visual C++ compiler flags if DISABLE_WERROR is off,
similar to config.nmake.

We haven't compiled C++ code with -Wshorten-64-to-32 for quite 
some time so there's no need to add -Wno-shorten-64-to-32 in
ui/qt/CMakeLists.txt.

Additionally, squelch

----
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3050) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3065) : see reference to function template instantiation 'void std::_Median<_RanIt,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_RanIt,_Pr)' being compiled
        with
        [
            _RanIt=QList<QString>::iterator
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3127) : see reference to function template instantiation 'std::pair<_RanIt,_RanIt> std::_Unguarded_partition<_RanIt,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_Pr)' being compiled
        with
        [
            _RanIt=QList<QString>::iterator
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3157) : see reference to function template instantiation 'void std::_Sort<_Iter,int,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_Diff,_Pr)' being compiled
        with
        [
            _Iter=QList<QString>::iterator
,            _RanIt=QList<QString>::iterator
,            _Diff=int
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
        .\rpc_service_response_time_dialog.cpp(130) : see reference to function template instantiation 'void std::sort<QList<QString>::iterator,bool(__cdecl *)(const QString &,const QString &)>(_RanIt,_RanIt,_Pr)' being compiled
        with
        [
            _RanIt=QList<QString>::iterator
,            _Pr=bool (__cdecl *)(const QString &,const QString &)
        ]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3051) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3052) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(3053) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data (.\rpc_service_response_time_dialog.cpp)
----

in both rpc_service_response_time_dialog.cpp and wireshark_application.cpp
so that we'll compile successfully.

Change-Id: I457bcede99dcb1f3c1001f1f559c4901bb000357
Reviewed-on: https://code.wireshark.org/review/10533
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-10-16 21:32:22 +00:00
Peter Wu c647faa8a9 Fix various memleaks
Found by starting Wireshark within an empty profile, opening
Preferences, search for Protocol "IEEE 802.11" (because it has radio
buttons), then close everything again.

Many fixes are trivial, but the various recent_read_* functions in
recent.c were changed to return a boolean such that the result can
always be checked even if errno==0.

QButtonGroup leak was hinted by Clang Static Analyzer, all other
memleaks were found using ASAN/LSan.

Change-Id: Ia73f5d4c09d92f22e72377be59e23342f8ad7211
Reviewed-on: https://code.wireshark.org/review/10776
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-10-04 15:45:02 +00:00
Pascal Quantin 6452caa3b3 Fix retrieval of data link type supported by remote interfaces with authentication
Make use of -A parameter when querying data link types supported by a given interface with dumpcap.
Ensure to pass the authentication parameters configured for a remote interface when calling capture_get_if_capabilities()

Bug: 11366
Change-Id: I4efea615084a82108e4a12a64e8c46817f30a5c6
Reviewed-on: https://code.wireshark.org/review/9690
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-07-22 07:10:10 +00:00
Peter Wu 305d983442 capchild: fix uninitialized data pointer on failure
Fixes a crash / heisenbug in wireshark-qt on startup:

    ==26808==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x7fff8cf3bf70 in thread T0
        #0 0x7f42ce3b66da in __interceptor_free /build/gcc-multilib/src/gcc-5-20150519/libsanitizer/asan/asan_malloc_linux.cc:28
        #1 0x842847 in WirelessFrame::setChannel() ui/qt/wireless_frame.cpp:257
        #2 0x842bf5 in WirelessFrame::on_channelComboBox_activated(int) ui/qt/wireless_frame.cpp:282
        #3 0x84407d in WirelessFrame::timerEvent(QTimerEvent*) ui/qt/wireless_frame.cpp:134
        #4 0x7f42ba94ea92 in QObject::event(QEvent*) (/usr/lib/libQt5Core.so.5+0x2b0a92)
        #5 0x7f42bb6218ea in QWidget::event(QEvent*) (/usr/lib/libQt5Widgets.so.5+0x1948ea)
        #6 0x7f42bb71c16d in QFrame::event(QEvent*) (/usr/lib/libQt5Widgets.so.5+0x28f16d)
        #7 0x7f42bb5df62b in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/usr/lib/libQt5Widgets.so.5+0x15262b)
        #8 0x7f42bb5e4d0f in QApplication::notify(QObject*, QEvent*) (/usr/lib/libQt5Widgets.so.5+0x157d0f)
        #9 0x7f42ba91d57a in QCoreApplication::notifyInternal(QObject*, QEvent*) (/usr/lib/libQt5Core.so.5+0x27f57a)
        #10 0x7f42ba973b1c in QTimerInfoList::activateTimers() (/usr/lib/libQt5Core.so.5+0x2d5b1c)
        #11 0x7f42ba974020  (/usr/lib/libQt5Core.so.5+0x2d6020)
        #12 0x7f42cdde7a16 in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x49a16)
        #13 0x7f42cdde7c6f  (/usr/lib/libglib-2.0.so.0+0x49c6f)
        #14 0x7f42cdde7d1b in g_main_context_iteration (/usr/lib/libglib-2.0.so.0+0x49d1b)
        #15 0x7f42ba974cfe in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/usr/lib/libQt5Core.so.5+0x2d6cfe)
        #16 0x56c8ba in main_window_update wireshark-qt.cpp:128
        #17 0xe4b612 in sync_pipe_open_command capchild/capture_sync.c:972
        #18 0xe4b823 in sync_pipe_run_command_actual capchild/capture_sync.c:1034
        #19 0xe4c590 in sync_pipe_run_command capchild/capture_sync.c:1211
        #20 0xe4e9a5 in sync_if_capabilities_open capchild/capture_sync.c:1356
        #21 0xe48b7a in capture_get_if_capabilities capchild/capture_ifinfo.c:249
        #22 0xdf539a in scan_local_interfaces ui/iface_lists.c:186
        #23 0xdf6a65 in fill_in_local_interfaces ui/iface_lists.c:405
        #24 0x56e49d in main wireshark-qt.cpp:1154
        #25 0x7f42b81c178f in __libc_start_main (/usr/lib/libc.so.6+0x2078f)
        #26 0x56ba58 in _start (wireshark+0x56ba58)

    AddressSanitizer can not describe address in more detail (wild memory access suspected).
    SUMMARY: AddressSanitizer: bad-free /build/gcc-multilib/src/gcc-5-20150519/libsanitizer/asan/asan_malloc_linux.cc:28 __interceptor_free

Change-Id: I63744261096b3cfd0eddcf75bcf85103a3f0788d
Reviewed-on: https://code.wireshark.org/review/9220
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-06-29 22:48:33 +00:00
Gerald Combs ece4b01f21 Add the wireless toolbar.
Add the wireless toolbar to the Qt UI.

Start adding AirPcap support to ui/80211_utils. Add FCS validation
routines to ws80211_utils.

Move a bunch of AirPcap routines that require epan from caputils to
ui/gtk. They were required for driver key management, which we'll
leave to the AirPcap Control Panel in the Qt UI.

Move frequency-utils to wsutil.

Change-Id: I44446758046621d183f5c2ba9f6526bf01e084f1
Reviewed-on: https://code.wireshark.org/review/8910
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-06-16 03:45:54 +00:00
Guy Harris 62c3bc3596 Squelch some type-clash warnings on Windows.
Define WS_INVALID_PID to be the appropriate "there is no process" value.
On UN*X, -1 works; the "pid" is actually a HANDLE for the process on
Windows, so INVALID_HANDLE is appropriate.

Cast HANDLE to intptr_t in the _cwait() call.

Change-Id: Ica2d2319f5c95ba41f590776a745fe040fe494d2
Reviewed-on: https://code.wireshark.org/review/8871
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-10 03:10:24 +00:00
Guy Harris a10a41f5c7 Rename wsutil/process.h to wsutil/processes.h to avoid collisions.
The MSVC rules for searching for headers are a huge barrel of fun; it
appears that, for some files that need the MSVC <process.h> to declare
getpid(), they're getting our <wsutil/process.h> instead, as that's in
the current directory.  Rename it to avoid the collision.

Change-Id: I88eb70237062fa7957e38d7ff8132524390a6a5c
Reviewed-on: https://code.wireshark.org/review/8870
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-10 01:56:27 +00:00
Guy Harris af9f07475b One more ws_process_id change.
Change-Id: I21dc38c248f4412e8f48e7dfd54aa12497167e5a
Reviewed-on: https://code.wireshark.org/review/8866
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-10 00:55:36 +00:00
Guy Harris 2e76bb466a Use pid_t on UN*X, and HANDLE on Windows, for the process ID.
This avoids type punning; at least with Xcode 7 beta on El Capitan beta,
that produces warnings that get turned into errors.

Change-Id: I57f47455b9630f359828c07c92a190b5cb33816f
Reviewed-on: https://code.wireshark.org/review/8862
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-10 00:30:57 +00:00
Anders 4e60e8fb39 [MSVC 2015] Use intptr_t for "pointer stored as int" to make MSVC happy.
Change-Id: I5dbbea8527a8bb73b17e5a8a5611c3923d82459c
Reviewed-on: https://code.wireshark.org/review/8852
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-06-09 14:13:14 +00:00
Guy Harris 47cc0238b8 Fix typo.
Change-Id: Idde2f4771b42714561f65f712e680f9609aeaa57
Reviewed-on: https://code.wireshark.org/review/8535
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-05-19 01:46:42 +00:00
Guy Harris a273d9dd91 Pass the executable path to CreateProcess(), and end it with ".exe".
On Windows, 1) pass the path of the executable as the first argument to
CreateProcess(), which requires that we 2) have that path end with
".exe.

Maybe it'll fix the searching-for-dumpcap that showed up in bug 11196.

Change-Id: I9d06c07c3513fd42b98d3f8d9a1d2d545f651fe2
Reviewed-on: https://code.wireshark.org/review/8534
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-05-19 01:40:46 +00:00
Guy Harris 1871fb2b0d Keep a captured-packet count in a capture_session and use that.
Have the count in a cfile_t structure always reflect the actual number
of packets that have been read from the file, rather than, when doing a
non-update-list-of-packets-in-real-time capture, falsely increasing the
count in the cfile_t to reflect the number of packets captured but not
yet read.

Have the status bar base its captured-packet count on the count in the
capture_session structure, and base the "sorry, no packets were
captured" message on the count in the capture_session structure, as
we're no longer using the count in the cfile_t structure to count
anything in the process of a non-update-list-of-packets-in-real-time
capture.

That way, we preserve the invariant that the "frames" member of a
cfile_t will be non-null if the "count" member is non-zero, fixing bug
6217.

It also means we can get rid of cf_set_packet_count(), as we only set
the count in the capture-file-reading code.

Bug: 6217
Change-Id: I72c0e2c07c30782bad777995370b7c19e1460cc2
Reviewed-on: https://code.wireshark.org/review/7950
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-04-06 19:15:24 +00:00
Guy Harris 083f6b6e6d Have a #define for whether the capture buffer size can be set.
It can be set if either 1) this is Windows (where we're assumed to be
using WinPcap, which includes calls to set the buffer size) or 2) we
have pcap_create() (in which case we also have pcap_set_buffer_size(),
at least in a normal libpcap release).

Use that rather than testing "defined(_WIN32) ||
defined(HAVE_PCAP_CREATE)"; that makes it a bit more obvious what's
being tested.

Change-Id: Id9f8455019d19206b04dd6820a748cb97ae5ad12
Reviewed-on: https://code.wireshark.org/review/7816
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-03-25 03:22:33 +00:00
Vik dc2195711c Fix for waitpid return EINTR sometimes on launch.
The return of EINTR is not exactly a failure of child process but may be because of any number of reasons. Adding logic to retry to get status of child process.

Bug: 10889
Change-Id: Ic2de7248cb7bd9c801b917c841ce911fb7c17dcc
Reviewed-on: https://code.wireshark.org/review/7669
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-16 06:04:58 +00:00
Guy Harris 63a3d043e3 Consistently use the "g_string_free returns a C string pointer" idiom.
g_string_free(str, FALSE) frees the GString container but not the
underlying g_malloc()ed string; instead, it returns a pointer to the
g_malloc()ed string.

Fix those places that didn't already get the string pointer from
g_string_free() to do so rather than manually extracting the string
themselves.

And fix one place that didn't even need to use a string - it was just
scanning a C string without even modifying it.

Change-Id: Ibbf4872bf5b9935b9907f539b6edb1013f3053a5
Reviewed-on: https://code.wireshark.org/review/6532
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-13 23:14:13 +00:00
Graham Bloice a7a17047eb Minor CMake updates to better group build artefacts
Move capchild, caputils, codecs and wsutil into a Libs group
Move gtkui into UI group
Move update-sminmpec into tools group

Change-Id: Iaf2bfe4697265af2c3ed9c9d7de2d5d1ef3cafee
Reviewed-on: https://code.wireshark.org/review/6332
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Graham Bloice <graham.bloice@trihedral.com>
2015-01-05 23:48:46 +00:00
Bill Meier 5c529c95c5 Add '*.nativecodeanalysis.xml' to 'clean' targets
Change-Id: I90dbf0b31fc737150a01533763a7869b34c68cb6
Reviewed-on: https://code.wireshark.org/review/6220
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-01-02 01:45:16 +00:00
Gerald Combs 9ba9cd83a4 Qt: Add a CaptureFile class.
Wrap the capture_file struct in a QObject which translates cf_cb_* and
capture_cb_* events into signals. Move the global cfile to
capture_file.cpp.

Don't use a void pointer for the capture file struct.

Change-Id: Ic5d5efb4bb1db64aa0247245890e5669b1da723a
Reviewed-on: https://code.wireshark.org/review/5885
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-12-20 17:39:29 +00:00
Guy Harris 214a78c8e1 Get rid of unnecessary include of ctype.h.
Change-Id: Ib83e707ebbbb420ce269a652ede6b7366d24240e
Reviewed-on: https://code.wireshark.org/review/4792
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 21:28:21 +00:00
Gerald Combs ced39b6de8 Qt: Start capture from the command line.
Fill in the capture-related mise en place so that -k and -i work. Get
rid of global_capture_session in ui/qt and make it a member of
MainWindow.

Copy over privilege checking from GTK+.

Move the global capture session struct to MainWindow.

Change-Id: Iab5ec683860a40255a7e1d82e3872ced24fd55cb
Reviewed-on: https://code.wireshark.org/review/4382
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-09-30 18:44:59 +00:00
Bill Meier a379ac74d2 Fix spelling: cant-->can't, wont-->won't, etc
Change-Id: Ia6c3e7a25615bf8e052c3bacf096d76df775c9c2
Reviewed-on: https://code.wireshark.org/review/4126
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-16 15:31:58 +00:00
Roland Knall bed29af46d Extcap Capture Interface
Extcap is a plugin interface, which allows for the usage
 of external capture interfaces via pipes using a predefined
 configuration language which results in a graphical gui.

 This implementation seeks for a generic implementation,
 which results in a seamless integration with the current
 system, and does add all external interfaces as simple
 interfaces.

 Windows Note: Due to limitations with GTK and Windows,
 a gspawn-winXX-helper.exe, respective gspawn-winXX-helper-console.exe
 is needed, which is part of any GTK windows installation.

 The default installation directory from the build is an extcap
 subdirectory underneath the run directory. The folder used by
 extcap may be viewed in the folders tab of the about dialog.

 The default installation directory for extcap plugins with
 a pre-build or installer version of wireshark is the extcap
 subdirectory underneath the main wireshark directory.

 For more information see:

  http://youtu.be/Nn84T506SwU
  bug #9009

 Also take a look in doc/extcap_example.py for a Python-example
 and in extcap.pod for the arguments grammer.

 Todo:
   - Integrate with Qt - currently no GUI is generated, but
     the interfaces are still usable

Change-Id: I4f1239b2f1ebd8b2969f73af137915f5be1ce50f
Signed-off-by: Mike Ryan <mikeryan+wireshark@lacklustre.net>
Signed-off-by: Mike Kershaw <dragorn@kismetwireless.net>
Signed-off-by: Roland Knall <rknall@gmail.com>
Reviewed-on: https://code.wireshark.org/review/359
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-08-21 03:34:02 +00:00
Guy Harris f6ce0cdacd Get rid of NO_INTERFACES_FOUND - it's not an error.
It just means "pcap didn't give me any interfaces, and didn't report an
error".  Hopefully, in the future, there will be pcap APIs that
distinguish between the (admittedly unlikely, these days) case of "there
really *are* no interfaces on which *anybody* can capture" and "you
don't have sufficient permission to capture", and we can report the
latter as an error.  (Given that pcap supports more than just "regular
interfaces", though, there are cases where you don't have permission to
capture on those but you have permission to capture raw USB traffic, for
example, so perhaps what's really needed is per-interface indications of
permissions.)

Change-Id: I7b8abb0829e8502f5259c95e8af31655f79d36a1
Reviewed-on: https://code.wireshark.org/review/3169
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-22 23:53:49 +00:00
Guy Harris 4261109e1e Don't return an error string for NO_INTERFACES_FOUND.
Most callers of capture_interface_list() don't expect an error string
for NO_INTERFACES_FOUND, because that's not really an error, it's just a
statement of face (and perhaps an error of 0 should be returned), so
they don't bother freeing the error string, causing a leak.

Instead, have the one place that *did* expect it to return an error
string just put "No interfaces found" itself.

Also, have that place not check for an error string if interfaces *were*
found, as no error code or string is returned in that case.

Change-Id: I9cb8ed7ad22810b23e2251d2833d9b7ab02eec03
Reviewed-on: https://code.wireshark.org/review/3165
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-22 18:51:47 +00:00
Роман Донченко 696cb6c17b Use forward slashes in paths to runlex.sh
This gets rid of "MS-DOS style path detected" warnings from Cygwin.

Change-Id: Id10429669704aa371dbf56a9398947c8002260ad
Reviewed-on: https://code.wireshark.org/review/3024
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Wireshark Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2014-07-20 13:15:59 +00:00
Guy Harris 9e6487f247 Move utility routines for capturing into a libcaputils static library.
Some of those routines are used only in dumpcap; others are used in
TShark and Wireshark as well.

Change-Id: I9d92483f2fcff57a7d8b6bf6bdf2870505d19fb7
Reviewed-on: https://code.wireshark.org/review/2841
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-04 07:25:26 +00:00
Irene Ruengeler f3c5f14bc4 Manage Interfaces
- Add dialog to manage interfaces
- Add and delete pipes
- Hide local interfaces

Change-Id: I08323c306c2ea736f99e57c28e2fe3170a0c2216
Reviewed-on: https://code.wireshark.org/review/2613
Tested-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Tüxen <tuexen@wireshark.org>
2014-07-02 20:56:37 +00:00
Guy Harris ad1391aa4e Move capture.[ch] to libui.
Change-Id: I86e7e781cc9e14abab0374a18b95438529b046f0
Reviewed-on: https://code.wireshark.org/review/2711
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-30 05:38:57 +00:00