aboutsummaryrefslogtreecommitdiffstats
path: root/capchild/capture_ifinfo.c
AgeCommit message (Collapse)AuthorFilesLines
2021-03-29Merge the caputils/ and capchild/ directoriesJoão Valverde1-373/+0
The distinction between the different kinds of capture utility may not warrant a special subfolfer for each, and sometimes the distinction is not be clear or some functions could stradle multiple "categories" (like capture_ifinfo.[ch]). Simplify by having only a generic 'capture' subfolder. The separate CMake libraries are kept as a way to reuse object code efficiently.
2021-03-06if_capabilities: Use a structured error msg from dumpcapJoão Valverde1-17/+19
Have dumpcap in child mode return an error message with a primary and secondary string, instead of using stderr. When writing to the console log we ignore the second message to prevent flooding the log with tutorial-like info on permissions.
2020-12-22Detect and replace bad allocation patternsMoshe Kaplan1-4/+4
Adds a pre-commit hook for detecting and replacing occurrences of `g_malloc()` and `wmem_alloc()` with `g_new()` and `wmem_new()`, to improve the readability of Wireshark's code, and occurrences of `g_malloc(sizeof(struct myobj) * foo)` with `g_new(struct myobj, foo)` to prevent integer overflows Also fixes all existing occurrences across the codebase.
2018-05-01Fix comment end after SPDX identifierStig Bjørlykke1-1/+2
Move */ to a separate line below the SPDX identifier. Change-Id: Id1032215449cfccae0933147b45e04b65e0b727f Reviewed-on: https://code.wireshark.org/review/27211 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-27capture_ifinfo: Don't try to write to an invalid address.Gerald Combs1-1/+3
Make sure err_str is valid before trying to assign a value. Change-Id: I4e6524b93101ef28158996797e8462168e44dc2a Reviewed-on: https://code.wireshark.org/review/27173 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-04-26Fix crash (double-free) on refreshing interfaces listPeter Wu1-0/+1
When normal interfaces are unavailable (chmod -x dumpcap), and after toggling "Disable external capture interfaces" twice and then refreshing the interfaces list (F5), a double-free occurs in ui/iface_lists.c:147 for "global_capture_opts.ifaces_err_info". Change-Id: I98697653ab1c123186892408112c34afdd1766f5 Fixes: v1.99.0-rc1-1005-g35b4487538 ("Handle empty interface lists when the list changes.") Reviewed-on: https://code.wireshark.org/review/27161 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-02capchild: use SPDX identifiers.Dario Lombardo1-14/+1
Change-Id: I123e043c3266993081f9bff404da5d7db76ee68e Reviewed-on: https://code.wireshark.org/review/25558 Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-01-08extcap: remove conditional compilation.Dario Lombardo1-22/+0
Change-Id: Ia54bba388755cf27a343fe6d69d244bf1ab897f9 Reviewed-on: https://code.wireshark.org/review/25186 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-10-26Add a ws_in6_addr typedef for struct e_in6_addr.Guy Harris1-1/+1
That allows a parallel typedef of ws_in4_addr for guint32. Change-Id: I03b230247065e0e3840eb87635315a8e523ef562 Reviewed-on: https://code.wireshark.org/review/24073 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-08-22Add hardware timestamping supportAhmad Fatoum1-6/+29
pcap provides a pcap_set_tstamp_type function, which can be used to request hardware timestamps from a supporting kernel. This patch adds support for aforementioned function as well as two new command line options to dumpcap, wireshark and tshark: --list-time-stamp-types List time stamp types supported for the interface --time-stamp-type <type> Change the interface's timestamp method Name choice mimics those used by tcpdump(1), which already supports this feature. However, unlike tcpdump, we provide both options unconditionally. If Wireshark was configured without pcap_set_tstamp_type being available, --list-time-stamp-types reports an empty list. Change-Id: I418a4b2b84cb01949cd262aad0ad8427f5ac0652 Signed-off-by: Ahmad Fatoum <ahmad.fatoum@siemens.com> Reviewed-on: https://code.wireshark.org/review/23113 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-03-19Fix various compile warnings turning error on Linux with gcc6 whenJoerg Mayer1-4/+4
compiling with HAVE_PCAP_REMOTE (and ENABLE_ECHLD) Change-Id: If5524f2d3dcacca9c82a46167480c8436dd8b1b2 Reviewed-on: https://code.wireshark.org/review/20615 Petri-Dish: Jörg Mayer <jmayer@loplof.de> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2017-02-20Yell at the user less.Gerald Combs1-4/+4
Our user-facing messages should have a helpful (or at the very least neutral) tone. In English, exclamation points are neither. Replace a bunch of them with periods. Change-Id: I29c3b2f84c25e06aae5b559860224559053a0378 Reviewed-on: https://code.wireshark.org/review/20189 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-10-21capchild: Fix loading of extcap with no winpcap.dllRoland Knall1-9/+22
If the loading of the physical interface list failed, no extcap interfaces will be loaded as well. Fix that, so that we search for the extcap interfaces, even when no other interfaces have been found Change-Id: Ib8e86f1f8d2a1565724ef3532d41ecea3ceddb55 Reviewed-on: https://code.wireshark.org/review/18352 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-02-27Fix appending the list of remote interfaces.Guy Harris1-2/+3
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-27Replace extcap_interface_list() with append_extcap_interface_list().Guy Harris1-1/+1
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-27Put the extcap interfaces at the *end* of the interface list.Guy Harris1-4/+7
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-19Add inet_pton/inet_ntop interface to libwsutilJoão Valverde1-19/+3
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>
2015-11-25Fix memory leak in capture_get_if_capabilitiesMikael Kanstrup1-0/+2
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-17Extcap: allow Wireshark to list extcap interfaces even when WinPcap / Npcap ↵Pascal Quantin1-1/+1
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-10-04Fix various memleaksPeter Wu1-0/+1
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-07-22Fix retrieval of data link type supported by remote interfaces with ↵Pascal Quantin1-1/+2
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>
2014-12-20Qt: Add a CaptureFile class.Gerald Combs1-2/+3
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-08-21Extcap Capture InterfaceRoland Knall1-0/+31
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-07-22Get rid of NO_INTERFACES_FOUND - it's not an error.Guy Harris1-3/+2
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-22Don't return an error string for NO_INTERFACES_FOUND.Guy Harris1-4/+1
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-04Move utility routines for capturing into a libcaputils static library.Guy Harris1-1/+1
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-06-30Move capture_session.h to capchild; what it declares is defined there.Guy Harris1-1/+1
Change-Id: I8b1407839390b7ac0b45bf6f583c1a509073f002 Reviewed-on: https://code.wireshark.org/review/2709 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-27Report more information on a sync_xxx_open() call failure.Guy Harris1-2/+6
Trying to get more information for http://ask.wireshark.org/questions/34057/waitpid-error-starting Change-Id: Ifc0eb58f5b69c2c4a4638aa95f6b5f8f628bef02 Reviewed-on: https://code.wireshark.org/review/2685 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-24For capchild headers, include <capchild/XXX.h>.Guy Harris1-2/+2
Change-Id: I780c69ee637dcd9846756a2e2d6a35baf02d826d Reviewed-on: https://code.wireshark.org/review/2594 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-23Move the routines to talk to dumpcap into a static libcapchild.Guy Harris1-0/+342
This pulls some stuff out of the top-level directory, and means we don't have to build them once for every program using them. Change-Id: I37b31fed20f2d5c3563ecd2bae9fd86af70afff5 Reviewed-on: https://code.wireshark.org/review/2591 Reviewed-by: Guy Harris <guy@alum.mit.edu>