aboutsummaryrefslogtreecommitdiffstats
path: root/caputils
AgeCommit message (Collapse)AuthorFilesLines
2021-03-29Merge the caputils/ and capchild/ directoriesJoão Valverde18-7910/+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-17caputils: pull the includes out of extern "C" { ... }.Guy Harris1-21/+24
Have separate #ifdef HAVE_LIBPCAP ... #endif sections for the includes and the definitions/declarations. (There are no good solutions that don't require hopping in a time machine and changing history.)
2021-03-17caputils: get rid of the extern "C" { idiom.Guy Harris1-18/+18
Instead, declare each function with EXTERN_C, #defined as extern "C" in C++ and just extern in C. This avoids all the thrashing to try to keep headers outside extern "C" { by the simple expedient of not *having* extern "C" {.
2021-03-17caputils: fix compilation without pcap.Dario Lombardo1-4/+4
The extern declaration must be put outside the ifdef to match the closing statement as well as surrounding al the functions. Fixes: 2820156fbd4b0213ca015216d8cd97c31b503c8c (Move still *more* headers outside of extern "C".)
2021-03-16Move still *more* headers outside of extern "C".Guy Harris2-6/+6
If a header declares a function, or anything else requiring the extern "C" decoration, have it wrap the declaration itself; don't rely on the header itself being included inside extern "C".
2021-03-06if_capabilities: Use a structured error msg from dumpcapJoão Valverde1-1/+2
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.
2021-03-04wsutil: rename frequency-utils.[ch] to 802_11-utils.[ch].Guy Harris1-1/+1
It's 802.11-specific, and may include non-frequency/channel-related items in the future.
2021-02-10Moving glib.h out of extern CMichal Ruprich1-2/+2
2021-01-19No need to check for both "not null" and "is space".Guy Harris1-1/+1
The latter implies the former. Squelches a cppcheck redundantCondition warning.
2021-01-19Make some loop indices private to their loops.Guy Harris1-5/+5
This also squelches a cppcheck unreadVariable warning.
2020-12-22Detect and replace bad allocation patternsMoshe Kaplan2-5/+5
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.
2020-07-21Windows: Switch from the WpdPack SDK to vcpkg's libpcap.Gerald Combs3-116/+190
Switch from WinPcap's WpdPack SDK to a libpcap package built with vcpkg. We explictly load wpcap.dll on Windows, so make sure we don't link with pcap.lib. Move timestamp code from capture-pcap-util-unix.c to capture-pcap-util.c. Add timestap routines to capture-wpcap.c and make a couple of other updates. Change-Id: If0e3dbeb7378c42ed9e3f91b2f15add95d22a2bb Reviewed-on: https://code.wireshark.org/review/37905 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-14Don't call any routines from WinPcap/Npcap packet32.dll.Guy Harris3-313/+0
We aren't using them now; stick to libpcap APIs (including Windows-only libpcap APIs). Change-Id: I812eaa31ba1e6e611418853105d3e00c9130a420 Reviewed-on: https://code.wireshark.org/review/37852 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-04-01Handle -k better on platforms that don't support it.Guy Harris2-5/+10
Have ws80211_init() return an indication that channel setting isn't supported on those platforms. In dumpcap, try to set up ws80211 before checking the channel argument and, if it fails, report the failure, rather than failing because the "convert channel name to channel code" routine fails. See https://ask.wireshark.org/question/15535/dumpcap-k-is-not-accepting-channel-type-values/ for an example of confusion caused by the previous behavior. Change-Id: I303f560704700bbcd4f0ecea041f8632744212f3 Reviewed-on: https://code.wireshark.org/review/36659 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-03-15capture-wpcap: gracefully exit when has_wpcap is false.Dario Lombardo1-10/+17
Fix rawshark crash. Bug: 16442 Change-Id: Id65f160d86a4ab204eedd1369e3ed9fa36f9c9e0 Reviewed-on: https://code.wireshark.org/review/36445 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-15Put common code into get_interface_list_findalldevs_ex().Guy Harris4-50/+31
Remove duplication of code. Change-Id: I7cd1bd73ee9eda962a37468cadb72de291f1ec6a Reviewed-on: https://code.wireshark.org/review/36432 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-15Check for "is wpcap.dll loaded"? when getting the remote interface list.Guy Harris1-0/+11
That check is required for remote capture just as it's required for local capture. Change-Id: I9341ef4aeeef706db9728c8abb8531bec8306bdc Reviewed-on: https://code.wireshark.org/review/36430 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-15Remove an out-of-date comment.Guy Harris1-4/+0
We always use pcap_findalldevs(), as we now require it. Change-Id: Ia0897ccd80c836dbb8b5f1d9890cf8d4aef05c14 Reviewed-on: https://code.wireshark.org/review/36425 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-15Remove no-longer-necessary tests.Guy Harris1-2/+2
wpcap.dll now won't load if pcap_findalldevs() or pcap_freealldevs() are missing, so if it's loaded, we know they were found. Change-Id: I981816561c1213a4c5c60fae90bd05dbbb9d2f1d Reviewed-on: https://code.wireshark.org/review/36424 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-13Require at least libpcap 0.8/WinPcap 3.1.Guy Harris4-768/+17
2004 called, they want their libpcap/WinPcap back. RHEL 6 initially shipped with libpcap 1.0; even old Enterprise(TM) versions of OSes ship with something shinier than 0.7.x these days. This lets us get rid of a bunch of #ifdefs and workaround code for missing APIs. Change-Id: I862cb027418b0a0c0f45a26979acea82f93f833b Reviewed-on: https://code.wireshark.org/review/36383 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-12Fix some places where we forgot to mention Npcap.Guy Harris5-23/+25
Mostly comments, but a few messages. Change-Id: Iff7380eb15f064bf6a3078e131c70987e36bca44 Reviewed-on: https://code.wireshark.org/review/36381 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-11-17caputils: remove unneeded check.Dario Lombardo1-1/+1
Change-Id: Ie24598ac8f6dde4fe23e7f9ffe8dcf91e593a4cc Reviewed-on: https://code.wireshark.org/review/35106 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-21MSVC: Warn about unused formal parametersTomasz Moń1-7/+8
Provide _U_ macro definition for Visual Studio. Change the way _U_ macro is ifdefed for some targets to allow Visual Studio to recognize it. Ping-Bug: 15832 Change-Id: Ic7ce145cbe9e8aa751d64c9c09ce8ba6c1bbbd30 Reviewed-on: https://code.wireshark.org/review/34530 Tested-by: Petri Dish Buildbot Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-08-11make interface update libnl1 compatibleJaap Keuter1-1/+7
With libnl1 its not possible to get from the message the same notice of the interface being added or removed as with libnl3. This code has to be reserved for libnl3 only. Make compilation of this code conditionsal. Bug: 15981 Change-Id: I2588fd2ba6508a8544bdd4eac46436b4f78ee524 Reviewed-on: https://code.wireshark.org/review/34242 Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-08-01caputils: cast g_malloc pointer.Dario Lombardo1-2/+2
Fix compilation on FreeBBSD: ../caputils/capture-pcap-util.c: In function 'if_info_get': ../caputils/capture-pcap-util.c:383:17: error: request for implicit conversion from 'gpointer' {aka 'void *'} to 'char *' not permitted in C++ [-Werror=c++-compat] description = g_malloc(descr_size); ^ Change-Id: I4a3452a8b21c2bee853a50a977c418dd92a5d4b4 Reviewed-on: https://code.wireshark.org/review/34152 Reviewed-by: Guy Harris <guy@alum.mit.edu> Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot
2019-07-27HTTPS In More Places, update some URLs.Guy Harris3-7/+8
Change-Id: Ice2e1e2e4d94f6c9da7c651866cfa1a8ac4a31d8 Reviewed-on: https://code.wireshark.org/review/34096 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26HTTPS (almost) everywhere.Guy Harris8-8/+8
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-10Doxygen: Try to fix reported warnings.Anders Broman1-13/+13
Change-Id: Ia2e08265681c6700328a5782a70c3108eeb443bf Reviewed-on: https://code.wireshark.org/review/33887 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-07-10airpcap.h: Try to resolve doxygen warnings.Anders Broman1-2/+2
Change-Id: I88078e6e8119984792e30e928a0fd15686a9fb0f Reviewed-on: https://code.wireshark.org/review/33884 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-03CMake: Remove wsutil pcap dependencyJoão Valverde4-3/+4
Change-Id: Ic5a3653cb8bcc33e0be108c8b201567e7090f9f5 Reviewed-on: https://code.wireshark.org/review/33043 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: João Valverde <j@v6e.pt>
2019-04-29caputils: Convert error string to UTF-8 on WindowsTomasz Moń1-19/+95
The libpcap library on Windows can fill error buffer with localized message obtained from system. The localized message is encoded in active code page and can contain non-ASCII characters. Bug: 15715 Change-Id: I7451c6831ae83503ddeb5314e172c76f3dab500e Reviewed-on: https://code.wireshark.org/review/32993 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-29caputils: Fix endless recursive loop on WindowsTomasz Moń1-5/+5
The functions loaded from dll are prefixed with "p_". Use the dll functions where appropriate. Change-Id: I7cf2c7dc0d04502fa7f922ca2822808bdc02f324 Reviewed-on: https://code.wireshark.org/review/33010 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-15Don't pass "-g deprecated-gtk" to checkAPIs.pl.Gerald Combs1-2/+1
The deprecated-gtk and deprecated-gtk-todo API groups were removed last year in g7853d0e354. Change-Id: I9b299d54da043bbda91d639ec7c94a58f459149f Reviewed-on: https://code.wireshark.org/review/32865 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-03-24Add routines to return "Please report this as a bug" message strings.Guy Harris1-9/+3
(Routines, so that if we internationalize strings not in the Qt code, this can return the appropriately translated version.) Change-Id: I1c169d79acde2f0545af7af2a737883d58f52509 Reviewed-on: https://code.wireshark.org/review/32549 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-08Remove the periodic interface update in wireless toolbarMikael Kanstrup2-5/+15
The wireless toolbar retrieves the full list of network interfaces every 1.5 seconds to keep its list of interfaces updated. This not only adds unnecessary load on the system it also generates plenty of netlink traffic. When capturing packets on nlmon interfaces they are flooded with packets generated by Wireshark itself making it hard to understand the traffic that's really present on the system. Remove the periodic interface update and instead listen to network interface change events and update only when something has changed. The wireless toolbar need to know all when wireless interfaces are added/removed, not only whether an interface is 'up' or not so iface_monitor changes were also necessary. Bug: 15576 Change-Id: I8fb19fd919dfef1b6b35bf48790b105ecd2b60a8 Reviewed-on: https://code.wireshark.org/review/32350 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-08Convert WinPcap references to Npcap.Gerald Combs3-18/+10
Convert WinPcap references and URLs in error messages and the FAQ to their Npcap equivalents. Remove some obsolete FAQ entries. Change-Id: I695d358a2c9cff0939f4ea84ba02d4c62ad7dd01 Reviewed-on: https://code.wireshark.org/review/31943 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-01-20CMake: Replace PACKAGELIST magicJoão Valverde1-1/+11
This is more explicit and easier to read with slightly better locality while using less code. Also less awkward when the package doesn't fit the narrow package list expectations. The ws_find_package() macro doesn't include all the status messages. The choice was to rely on standard find_package() and feature_summary() output and be less verbose. Avoid polluting the CLI build interface. Per target include paths and macro definitions are preferred. Because this patch intentionally removes the global CMAKE_*_FLAGS and include_directories() usage in favor of target properties, some untested build configurations may inadvertently break because of missing ${PACKAGE}_INCLUDE_DIRS or ${PACKAGE}_DEFINITIONS. This required a manual review of dependencies that might have been incomplete. ${PACKAGE_VAR}_LINK_FLAGS seems to be unused. Changing the CMake Qt code to use more modern CMake component syntax is left as future work. Change-Id: I3ed75252189a6e05a23ed6e619088f519cd7ed78 Reviewed-on: https://code.wireshark.org/review/31496 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-25prefs: Document the possible hidden interface typesJim Young1-10/+14
The preferences file includes an optional comma-separated string of hidden interface type integer values (gui.interfaces_hidden_types). Augment the interface_type enum and the preferences file to better document what these interface type integer values stand for. Change-Id: Idd268ed7f252cfa56dd046d24ff7ff597018f5d3 Reviewed-on: https://code.wireshark.org/review/31191 Petri-Dish: Jim Young <jim.young.ws@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-30NSIS: Install NPcap instead of WinPcap.Gerald Combs1-3/+9
Install NPcap 0.99-r7 instead of WinPcap in the NSIS installer. Update and/or remove installer text, variables, and variable names accordingly. Change-Id: Ied36f00c2516127969894f55698e70401dfffb4f Reviewed-on: https://code.wireshark.org/review/30829 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-29CMake: Fix some transitive link dependenciesJoão Valverde1-0/+6
libwireshark and libwiretap have their INTERFACE link dependencies changed to the required set. libwsutil keeps a default public visibility. Further work may show some unneeded link requirements. The executable dependencies are adjusted accordingly. Change-Id: I3a534f72403819cac136ae47a3d80acee76e0fb3 Reviewed-on: https://code.wireshark.org/review/30815 Reviewed-by: João Valverde <j@v6e.pt>
2018-08-21Clean up includes for SIOCGIFDESCR.Guy Harris1-5/+9
Change-Id: Ib92f7d85355540cff23f7bb08db911f200541f5f Reviewed-on: https://code.wireshark.org/review/29231 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-08-21We use errno, so we need to include <errno.h>.Guy Harris1-0/+1
Change-Id: Ic6d88c508594aa9daf36bd0a6a9f2fe4f0db71bd Reviewed-on: https://code.wireshark.org/review/29230 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-08-21Wrong snprintf() wrapper.Guy Harris1-1/+1
Change-Id: I7d8d83cd1829bed8cc940fa3d9c86cdc94f361af Reviewed-on: https://code.wireshark.org/review/29229 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-08-21We need sys/sockio.h to define SIOCGIFDESCR.Guy Harris1-0/+4
Change-Id: Ief8830d7a5ce47ea7f486a4700f49859003519db Reviewed-on: https://code.wireshark.org/review/29225 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-08-13Put the interface descrptions into the IDB when capturing to pcapng.Guy Harris2-8/+156
capture_opts_add_iface_opt(), when called in a program acting as a capture child, will fetch the description for the interface, and will also generate a "display name" for the interface. In the process, we clean up capture_opts_add_iface_opt() a bit, combining duplicate code. We rename console_display_name to just display_name, as it may also be used in the title bar of Wireshark when capturing. Change-Id: Ifd18955bb3cb41df4c0ed4362d4854068c825b96 Reviewed-on: https://code.wireshark.org/review/29117 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-26Remove code specific to older versions of Visual Studio.Gerald Combs1-30/+0
Remove -DBUILD_WINDOWS and sections of code that we no longer use. Bug: 14715 Change-Id: Iae1a950e2f52f4ce45fcf0ae5dea06c1172c3a28 Reviewed-on: https://code.wireshark.org/review/28466 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-06-11Fix names in declarations to match definitions.Guy Harris2-5/+7
Change-Id: I7b3dd147b523fd3251d93dd1917d2e2c47433207 Reviewed-on: https://code.wireshark.org/review/28195 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-10Improve the secondary error messages for pcap errors.Guy Harris5-132/+193
On Windows, if WinPcap isn't installed, warn about that for errors other than failed attempts to start capturing. On HP-UX, if we appear to have an old version of libpcap, warn about that for errors other than failed attempts to start capturing. If we know the error is a permissions problem, don't make suggestions appropriate to other problems. If we know the error is *not* a permissions problem, don't make suggestions appropriate to permissions problems. For permissions problems, or possible permissions problems, on Linux, suggest doing dpkg-reconfigure wireshark-common if you've installed from a package on Debian or a Debian derivative such as Ubuntu. Change-Id: If4aac0343095ac0b984eebc21853920c3b6d3c63 Ping-Bug: 14847 Reviewed-on: https://code.wireshark.org/review/28189 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23make our version of nla_for_each_nested() publicMartin Kaiser1-21/+2
caputils/ws80211_utils.c contains a re-definition of the linux kernel's nla_for_each_nested() macro that applies the correct casts to allow compilation with a C++ compiler. Make this definition public by moving it into a new wsutil/netlink.h file. Include the kernel's original definition before we overwrite it. This way, it's not necessary for a .c file to include wsutil/netlink.h after the system includes. Use our nla_for_each_nested() version in extcap/dpauxmon.c to squelch the following compiler warning: [1664/2251] Building C object extcap/CMakeFiles/dpauxmon.dir/dpauxmon.c.o ../extcap/dpauxmon.c: In function ‘family_handler’: ../extcap/dpauxmon.c:168:13: warning: request for implicit conversion from ‘void *’ to ‘struct nlattr *’ not permitted in C++ [-Wc++-compat] nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) { Change-Id: I6ba40ef6343c5d168c1b0c4554f13202911ded76 Reviewed-on: https://code.wireshark.org/review/27688 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-18Older versions of Clang don't understand -Wpedantic.Guy Harris2-8/+8
Define DIAG_OFF_PEDANTIC and DIAG_ON_PEDANTIC, and have it do nothing on Clang prior to 4.0. Change-Id: Ic6b2e607659db66f3210401024bf3f2239665506 Reviewed-on: https://code.wireshark.org/review/27649 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>