aboutsummaryrefslogtreecommitdiffstats
path: root/caputils/capture-wpcap.c
AgeCommit message (Collapse)AuthorFilesLines
2021-03-29Merge the caputils/ and capchild/ directoriesJoão Valverde1-915/+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.
2020-07-21Windows: Switch from the WpdPack SDK to vcpkg's libpcap.Gerald Combs1-24/+99
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-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 Harris1-22/+2
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 Harris1-403/+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 Harris1-10/+11
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-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-02-08Convert WinPcap references to Npcap.Gerald Combs1-13/+9
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>
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-06-10Improve the secondary error messages for pcap errors.Guy Harris1-5/+7
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-08Windows: prioritize Npcap over WinPcapPascal Quantin1-3/+3
It is now considered stable enough to be our default capture driver if present Change-Id: I7f3cdabcbaea526949afa47164e520202e6b93f2 Reviewed-on: https://code.wireshark.org/review/27393 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
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-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-07caputils: use SPDX identifiers.Dario Lombardo1-14/+1
Change-Id: I7c30002025c31a74dfa60c10ca7f7c0dd384e1c9 Reviewed-on: https://code.wireshark.org/review/25559 Petri-Dish: Dario Lombardo <lomato@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-05-12Include caputils/capture-wpcap.h whether HAVE_LIBPCAP is defined or not.Guy Harris1-1/+2
It declares what's defined here, so always include it. Change-Id: I1d7d5ed071e6f2d53af9ff147ede18b05b98ecd1 Reviewed-on: https://code.wireshark.org/review/21616 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-12Don't include headers that depend on pcap if you don't have it.Guy Harris1-5/+5
Change-Id: I17234ef60411f922678b900a6ac4fb264b9ce431 Reviewed-on: https://code.wireshark.org/review/21614 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-03Move npf_sys_is_running() from wsutil to caputils.Guy Harris1-0/+38
It has nothing to do with controlling privileges; it only tests whether the NPF or Npcap service (driver) is running, so it belongs in caputils. While we're at it, fix its signature (in C, a function with no arguments must have "void" as the argument list, for backwards compatibility with pre-function-prototype C), and close the handles it opens, so we don't have open handles leaked. Change-Id: Ia99e99d81617ed2e8cda2c44e53061b4502a2b58 Reviewed-on: https://code.wireshark.org/review/15714 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-22caputils: fix crash when calling 'dumpcap -i' without having WinPcap installedPascal Quantin1-1/+2
Add a test on err_str buffer presence before trying to use it, like what is done in other code paths. Bug: 12143 Change-Id: I30ae49a33224dc190c202637767df9d7de2c0f2b Reviewed-on: https://code.wireshark.org/review/14074 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-01-07Move more capture device handling to the caputils library.Guy Harris1-15/+49
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>
2016-01-06[WINPCAP] First step to be able to use pcap_create()AndersBroman1-0/+100
Change-Id: Id95640db0e647a696b39ccbfabc8cf2922df1407 Reviewed-on: https://code.wireshark.org/review/13051 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-17Extcap: allow Wireshark to list extcap interfaces even when WinPcap / Npcap ↵Pascal Quantin1-9/+3
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-03-10Change a lot of http:// URLs to https://.Gerald Combs1-12/+4
Most of our sites are now HTTPS-only. Update URLs accordingly. Update other URLs while we're at it. Remove or comment out dead links. Change-Id: I7c4f323e6585d22760bb90bf28fc0faa6b893a33 Reviewed-on: https://code.wireshark.org/review/7621 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-02-13caputils/*.c: As needed: Add editor modelines & Fix indentationBill Meier1-62/+75
Change-Id: I081446fbbc242c01f8ac9dede575c3ea77421c42 Reviewed-on: https://code.wireshark.org/review/7103 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-07-22Get rid of NO_INTERFACES_FOUND - it's not an error.Guy Harris1-1/+1
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-04Reflect the rename of get_XXX_pcap_version() to get_XXX_caplibs_version().Guy Harris1-4/+4
Change-Id: I55108e39d9d5a3fc5e1e3e0ec0040c08c92cc576 Reviewed-on: https://code.wireshark.org/review/2844 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-04Move utility routines for capturing into a libcaputils static library.Guy Harris1-0/+990
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>