aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindPCAP.cmake
AgeCommit message (Collapse)AuthorFilesLines
2023-11-01FindPCAP: mystery solved!Guy Harris1-4/+8
Explain why __builtin_available() doesn't help with the problem in [skip ci]
2023-10-30cmake: work around a mysterious macOS dyld problem.Guy Harris1-1/+44
For some reason, there appears to be no way to build Wireshark on macOS Ventura with Xcode 15 and have the resulting program run without getting an error due to failing to find pcap_createsrcstr() at startup. In particular, there appears to be no way to use __builtin_available() to protect accesses to the routines that showed up in Sonoma, so that the run-time linker doesn't fail if the routine in question isn't present. Perhaps it requires more compiler command-line arguments. So, instead, only check for pcap_open() if 1) this isn't macOS or 2) the pcap library pathname doesn't begin with /usr/lib/ or /Application/Xcode.app/, i.e. if it's not the system libpcap. That way, we won't every try to use those APIs for a built with the system libpcap. Fixes #19436.
2023-05-26Fedora: Fix cross-compilation with mingw-wpcapJoão Valverde1-3/+9
Fix various issues preventing compilation with Fedora's MinGW WinPcap package.
2023-04-10CMake: Fix more PkgConfig invocations with MSYS2João Valverde1-1/+1
2021-12-22Corrects repeated words throughout the code.Moshe Kaplan1-2/+2
Repeated words were found with: egrep "(\b[a-zA-Z]+) +\1\b" . -Ir and then manually reviewed. Non-displayed strings (e.g., in comments) were also corrected, to ease future review.
2021-03-29Merge the caputils/ and capchild/ directoriesJoão Valverde1-1/+1
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.
2020-07-21Windows: Switch from the WpdPack SDK to vcpkg's libpcap.Gerald Combs1-38/+34
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-03-13Remove trailing whitespace.Guy Harris1-2/+2
Change-Id: I88117a93e64feb310ecd0f9f558656b29b83e815 Reviewed-on: https://code.wireshark.org/review/36384 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-03-13Require at least libpcap 0.8/WinPcap 3.1.Guy Harris1-53/+61
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-01-07case-sensitive: Fix casing for PCAP and WinSparkleMartin Boye Petersen1-2/+2
CMake is unable to find PCAP and WinSparkle under Windows when using case sensitive folders. Change-Id: I30ba4073afc6089b08cef3c010b09c257362929b Reviewed-on: https://code.wireshark.org/review/35505 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>
2019-05-03CMake: Add libpcap imported library targetJoão Valverde1-0/+8
Change-Id: I5326b87784817fb353329e2d686fe0515c32f6cb Reviewed-on: https://code.wireshark.org/review/33038 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-29FindPCAP: fix broken search logicPeter Wu1-193/+123
Do not fully trust the output from neither pkg-config nor pcap-config. These tools might provide bogus output. Instead, use their outputs as hints to let CMake find the correct include and (static) library paths. Correct some variable names (PCAP_STATIC_LIBRARIES and PCAP_INCLUDE_DIRS *must not* be the result of find_path/find_library) and ensure that an empty include directory from pkg-config does not result in an empty PCAP_INCLUDE_DIRS variable that would break the build. Change-Id: If3de90fb497d8163d92e4fe190a227159f0b6acb Fixes: v3.1.0rc0-645-gc602119bcf ("Use pkg-config if possible; if not, use pcap-config if present.") Reviewed-on: https://code.wireshark.org/review/32999 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-04-27Use pkg-config if possible; if not, use pcap-config if present.Guy Harris1-32/+219
First try finding libpcap with pkg-config. If that fails (either because the system doesn't have pkg-config or because it does but there's no .pc file for libpcap), check for pcap-config and, if it's present, use that, otherwise fall back on manually searching for it. Pick up the code from tcpdump's FindPCAP.cmake. Change-Id: I87963aaa7cccac0b5cd942f48eb5d08779695f92 Reviewed-on: https://code.wireshark.org/review/32992 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-24FindPCAP: use pkg-config to find pcap dependenciesFabrice Fontaine1-0/+10
On UNIX, when statically built, pcap can depends on other libraries such as -lnl-3. Add a call to pkg-config to find them and append them to PCAP_LIBRARIES (and so to CMAKE_REQUIRED_LIBRARIES) otherwise all check_function_exists calls will fail Change-Id: I98361c05553738d015310fae76c17dfc08e131ff Ping-Bug: 15713 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Reviewed-on: https://code.wireshark.org/review/32946 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-12CMake: Fix inconsistent find_package() report outputJoão Valverde1-1/+1
Most CMake find modules report the binary found, the modules fixed by this change represent an inconsistent exception. The first REQUIRED_VAR argument to find_package_handle_standard_args() is the one used by CMake to report on the result of find_package(). Compare (master) -- Found SNAPPY: /usr/include to (this change) -- Found SNAPPY: /usr/lib/x86_64-linux-gnu/libsnappy.so This convention of using XXX_LIBRARY matches upstream practice. Change-Id: Iaa0ec644e963430d73722354f6ee2a3694906ba7 Reviewed-on: https://code.wireshark.org/review/31498 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-30NSIS: Install NPcap instead of WinPcap.Gerald Combs1-1/+1
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-04-25Put references to autotools in the past tense.Guy Harris1-1/+1
In CMake files, we don't do some checks that our autotools scripts did; speak of those in the past tense, as the autotools scripts are gone. (Leave the comments there, to note that we *might* have to reinstate those tests, although they're for old versions of macOS and GCC.) In CMake files, we use some #defines because that's what autotools did; speak of those in the past tense as well. Change-Id: I594fe8225cf94b5087093febc11f6b0a7e42e7cd Reviewed-on: https://code.wireshark.org/review/27149 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-13CMake: Skip some header checks on Windows.Gerald Combs1-1/+21
Skip some header checks on Windows when we're sure they will always be true. Change-Id: I4ff7c867b9268a53692085553055dcbc0f90ae1d Reviewed-on: https://code.wireshark.org/review/26452 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>
2017-12-03Fix the configuration check for remote-capture support in libpcap.Guy Harris1-1/+20
In autotools, if we find pcap_open(), define HAVE_PCAP_REMOTE, so we build the remote capture support. In both autotools and CMake, only check for pcap_setsampling() if we have pcap_open(), as the compile fails if we have pcap_setsampling() but don't have remote capture. Change-Id: I0e7b78a2d372ea658a19ed2f6493532928c36872 Reviewed-on: https://code.wireshark.org/review/24680 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-08-22Add hardware timestamping supportAhmad Fatoum1-0/+1
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-05-11Revert "Revert "Get rid of HAVE_REMOTE.""Guy Harris1-1/+0
This reverts commit 8cd1fd0c993df904596390ebdf350259e7c9c5fc. Making HAVE_REMOTE a config.h #define is a really horrible idea. It's *NOT* a configuration option. Instead, HAVE_REMOTE should be defined by other mechanisms, as was done in 79eab8ca070f978415126f85b0777ab4ab02f0a2. Change-Id: I4632b63bd73a25a27c5f4686d2baf3e0beddecb3 Reviewed-on: https://code.wireshark.org/review/21604 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-11Revert "Get rid of HAVE_REMOTE."Jörg Mayer1-0/+1
This reverts commit d13b8ea13cf708a7770e7f51912ce16d0b43e459. This will only work with git HEAD of libpcap, but not with any release versions of libpcap or winpcap (the *pcap includes require the define, not Wireshark). Change-Id: I08e5ec66e3642dc02f793c83ffc4363bb348202c Reviewed-on: https://code.wireshark.org/review/21603 Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2017-05-10Get rid of HAVE_REMOTE.Guy Harris1-1/+0
We never test for it - we test for HAVE_PCAP_REMOTE - so there's no need to set it in config.h. While we're at it, note that "PCAP" in "HAVE_PCAP_REMOTE" can refer to libpcap as well as WinPcap, given that, at least in the tip of the master branch, you can configure remote support in libpcap, although it's not enabled by default (it needs to be vetted for security, as it increases the attack surface of a machine running the server *and* of an application using libpcap with remote support). Change-Id: I3c96cf16bbda19ec7c085f74cffc6f125198d45b Reviewed-on: https://code.wireshark.org/review/21589 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-05A bunch of "{Mac} OS X" -> "macOS" changes.Guy Harris1-1/+1
Avoid anachronisms, however; there was no "macOS 10.0" or even "OS X 10.0", for example. It was "Mac OS X" until 10.8 (although 10.7 was sometimes called "OS X" and sometimes called "Mac OS X"), and it was "OS X" from 10.8 to 10.11. Change-Id: Ie4a848997dcc6c45c2245c1fb84ec526032375c3 Reviewed-on: https://code.wireshark.org/review/20933 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-11-18cmake/FindPCAP: fix use of bad cached function checksPeter Wu1-46/+48
When libpcap-dev is not installed, do not look for functions like pcap_datalink_name_to_val since the negative result would be cached. Then after installing libpcap-dev, the build would fail due to redeclaration of functions. Change-Id: Ifdbad09e9cf160383b16b6459693f7ea5d65b9c3 Reviewed-on: https://code.wireshark.org/review/18834 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-01-07Move more capture device handling to the caputils library.Guy Harris1-15/+10
Move the code to open capture devices and get properties of capture devices there, joining the code to get a list of capture devices. This lets us do a better job of handling pcap_create() in WinPcap, including handling both WinPcap with pcap_create() and WinPcap without pcap_create() at run time, just in case somebody tries using WinPcap 3.x with a Wireshark built with WinPcap 4.x. It also could make it easier to use libpcap/WinPcap directly in Wireshark and TShark, if we have versions of libpcap/WinPcap that run small helper utilities to do privileged functions, allowing programs using them never to need elevated privileges themselves. That might make it easier to fix some issues with running TShark when not saving to a file (we could avoid the file entirely) and with delays when stopping a capture in Wireshark (Wireshark could stop writing to the file as soon as you click the stop button, rather than letting dumpcap do so when the signal gets to it). It might also make it easier to handle future versions of libpcap/WinPcap that support using pcap_create()/pcap_activate() for remote captures, and other future extensions to libpcap/WinPcap. Rename some XXX_linktype routines to XXX_datalink to indicate that they work with DLT_ values rather than LINKTYPE_ values; future versions of libpcap might use LINKTYPE_ values in newer APIs. Check for pcap_create() on all platforms in CMake. Change-Id: Ia12e1692c96ec945c07a135d246958771a29c817 Reviewed-on: https://code.wireshark.org/review/13062 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-03-25Have a #define for whether the capture buffer size can be set.Guy Harris1-1/+12
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-01-09CMake: Set WIRESHARK_TARGET_PLATFORM.Gerald Combs1-1/+1
Set WIRESHARK_TARGET_PLATFORM near the top of CMakeLists.txt. It's used by a couple of our modules and will be used for NSIS packaging. Change-Id: Ief43733bdf162998cd54ff3732f94c8baa3d1e11 Reviewed-on: https://code.wireshark.org/review/6458 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-01-04No *pcap should have pcap_open() without the other remote extensions.Guy Harris1-3/+1
WinPcap 3.0 introduced pcap_open(); it also introduced pcap_findalldevs_ex() and pcap_createsrcstr(). If you're going to put pcap_open() in libpcap, there's not much point to doing so but not also putting pcap_findalldevs_ex() and pcap_createsrcstr() there. (And, in the future, there'll be support for remote capturing with pcap_create() and pcap_activate(), with no need for pcap_createsrcstr(), and a replacement for pcap_findalldevs() and pcap_findalldevs_ex(), which we'll also check for.) So there's no need to check for pcap_findalldevs_ex() or pcap_createsrcstr(). Change-Id: I9323aad20136684d05d1e909326792a2f1408887 Reviewed-on: https://code.wireshark.org/review/6311 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-28Add support for getting nanosecond time stamp resolution when capturing.Guy Harris1-0/+1
If we have pcap_set_tstamp_precision(), use it to request nanosecond time stamp resolution *if* we're writing a pcap-ng file; any code that reads those files and can't handle nanosecond time stamp resolution is broken and needs to be fixed. If we're writing a pcap file, don't ask for nanosecond resolution time stamps, as that requires a different magic number for pcap files, and not all code that reads pcap files can handle that. (Unlike pcap-ng, where the ability to have non-microsecond time stamp resolution was present from Day One, it's a relatively recent addition to pcap.) We could add a command-line option/GUI option for that, like the option recent versions of tcpdump have, if it matters. Change-Id: I8fa464eb929feecb9a70be70712502c9f0cc5270 Reviewed-on: https://code.wireshark.org/review/4355 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-08-21Fix CMake checks of PCap functions, along with AirPCapGraham Bloice1-2/+3
Change-Id: If55498167d5e357258841f2194962749c0dfc81e Reviewed-on: https://code.wireshark.org/review/3787 Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Petri-Dish: Graham Bloice <graham.bloice@trihedral.com> Reviewed-by: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2014-08-01Fix comparison.Gerald Combs1-1/+1
Change-Id: If2af35c8a49f405bee70eb144e26e539a7dc61f2 Reviewed-on: https://code.wireshark.org/review/3335 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-08-01Fix the CMake WinPcap library path check.Gerald Combs1-1/+7
Look for wpcap.lib in WpdPack/Lib/x64 when our target platform is Win64. Change-Id: I9a1bac22106bcb6a1f155ce83c02e344e6ec0d55 Reviewed-on: https://code.wireshark.org/review/3331 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-06-18Don't put c-comments into cmake files. Won't work at midnight either.Joerg Mayer1-2/+2
Change-Id: I80efce78a044f477af56f82cc9d8e85c8544ffbc Reviewed-on: https://code.wireshark.org/review/2372 Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2014-06-18Fix building uiqt on Windows with the cmake build system:Joerg Mayer1-1/+5
Protecting HAVE_PCAP_CREATE was not enough for the moc run in qt, maybe it doesn't have _WIN32 set? Don't even try to detect this function on WIN32 for now. Change-Id: I0d8a8b5b110cec164f86fe11f26a7add558eee1b Reviewed-on: https://code.wireshark.org/review/2370 Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2014-03-31Continue to remove $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^\# \$Id\$/,+1 d') (start with dash) Change-Id: Ia4b5a6c2302f6a531f6a86c1ec3a2f8205c8c2dd Reviewed-on: https://code.wireshark.org/review/881 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2013-10-10Don't check for pcap_version(); we don't use it.Guy Harris1-1/+0
Sort the #cmakedefines in cmakeconfig.h.in to more closely match the order in config.h.in, to make it easier to make sure CMake and autofoo are doing the same checks. Remove some #cmakedefines that don't correspond to check that are being done either by CMake or autofoo. svn path=/trunk/; revision=52515
2013-10-10Check for bpf_image(), just as the autoconf script does.Guy Harris1-0/+1
svn path=/trunk/; revision=52514
2013-10-06Rewrite FindPCAP.cmake to current practicesJörg Mayer1-127/+58
svn path=/trunk/; revision=52405
2013-09-23Beginnings of win cmake support (not yet working), created by Graham Bloice,Jörg Mayer1-0/+9
some smaller changes by me. - README.cmake Document how to (one day) run on Windows - CMakeLists.txt Use MSVC compiler flags for MSVC instead of gcc flags - FindWSWinLibs.cmake New: Creates HINTS for finding includes and libraries inside the Wireshark support library installation. - FindXXX.cmake Make use of HINTS generated by FindWSWinLibs.cmake This has not really been tested on Windows as my installation seems to have automagically downloaded some fixes and is in an inconsistent state since. Will probably need to reinstall. svn path=/trunk/; revision=52194
2011-08-05FindGTK2: Add a check for pangocairo. It has to be linked explicitly, atGerald Combs1-5/+6
least for MacPorts. FindPCAP: Define HAVE_PCAP_CREATE if we have pcap_create. svn path=/trunk/; revision=38372
2011-07-06Add detection of rpcap support in libpcap and use it if available.Jörg Mayer1-10/+18
svn path=/trunk/; revision=37914
2010-09-28- Reset a few more variables used in FindXYZ scripts.Jörg Mayer1-0/+3
- README.cmake: small update. - Set a variable before using it for installation. svn path=/trunk/; revision=34274
2010-05-24Jose Pedro Oliveira <jpo@di.uminho.pt>Jörg Mayer1-0/+1
(via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4786) Add missing +INCLUDE(CheckVariableExists) to make the previous commit work. svn path=/trunk/; revision=32939
2010-05-24At least according to the CMake 2.6 documentation,Guy Harris1-0/+1
CHECK_VARIABLE_EXISTS() can be used to check for C variables; use that to check for pcap_version. svn path=/trunk/; revision=32938
2010-03-17Add CMake tests for pcap_datalink_val_to_description() andGuy Harris1-6/+14
pcap_free_datalinks(). Sort the CMake tests in cmake/modules/FindPCAP.cmake into the same order as the tests in the autoconf script, and note that, in the autoconf script, the checks for pcap_open_dead() and pcap_freecode() do more than just look for the routines in the library. svn path=/trunk/; revision=32225
2009-12-29- Beginnings of cmake in docbook directoryJörg Mayer1-6/+2
- Add note about "make help" - Move beginnings of packaging into its own file: CPackConfig.txt svn path=/trunk/; revision=31379
2009-09-23- Add $Id: $ tagsJörg Mayer1-0/+3
- FindHtmlViewer.cmake: Try to add reading the name of the html viewer from the HTML_VIEWER environment variable (untested) svn path=/trunk/; revision=30104
2009-09-09CMAKE: Get most of of missing *build* pieces into placeJörg Mayer1-4/+4
svn path=/trunk/; revision=29819
2006-10-30frederic heem:Jörg Mayer1-0/+35
Please find the patch that adds copyrights. svn path=/trunk/; revision=19744