mbox series

[v5,0/3] net/pcap: build on Windows

Message ID 20210421193351.1909-1-dmitry.kozliuk@gmail.com (mailing list archive)
Headers
Series net/pcap: build on Windows |

Message

Dmitry Kozlyuk April 21, 2021, 7:33 p.m. UTC
  Most modern and actively maintained distribution of libpcap for Windows
is Npcap [1]. It currently doesn't provide a pkg-config file [2].
By default it is installed to C:\Program Files\Npcap and can be located
using standard environment variables [3]:

    $env:C_INCLUDE_PATH += ";C:\Program Files\Npcap"
    $env:LIBRARY_PATH += ";C:\Program Files\Npcap\Lib\x64"     # MinGW
    $env:LINK += ' /LIBPATH:"C:\Program Files\Npcap\Lib\x64"'  # Clang

The following libpcap.pc also works if placed in PKG_CONFIG_PATH:

    prefix="C:/Program Files/Npcap"
    Name: libpcap
    Version: 1.10
    Description: Platform-independent network traffic capture library
    Cflags: -I${prefix}/Include
    Libs: -L${prefix}/Lib/x64 -lwpcap

Example of collecting packets from an interface to a file:

    .\build\examples\dpdk-skeleton.exe `
        --vdev "eth_pcap0,iface=\Device\NPF_{DDD48985-A77C-4FC9-AF48-61E547C8797E}" `
        --vdev "eth_pcap1,tx_pcap=capture.pcap"

Interface name can be obtained as follows, with Wireshark installed:

    & "C:\Program Files\Wireshark\tshark.exe" -D

[1]: https://nmap.org/npcap
[2]: https://github.com/nmap/npcap/issues/299
[3]: https://mesonbuild.com/Reference-manual.html#compiler-object

v5:
    * Add timespec_get() shim for FreeBSD < 12.2 (CI, Thomas).   

Dmitry Kozlyuk (3):
  eal: add timespec_get shim
  net/pcap: move OS-dependent code to separate files
  net/pcap: build on Windows

 config/meson.build                            |   9 +-
 doc/guides/rel_notes/release_21_05.rst        |   4 +
 drivers/net/pcap/meson.build                  |  16 +--
 .../pcap/{rte_eth_pcap.c => pcap_ethdev.c}    | 109 +++-------------
 drivers/net/pcap/pcap_osdep.h                 |  18 +++
 drivers/net/pcap/pcap_osdep_freebsd.c         |  59 +++++++++
 drivers/net/pcap/pcap_osdep_linux.c           |  42 +++++++
 drivers/net/pcap/pcap_osdep_windows.c         | 118 ++++++++++++++++++
 lib/eal/freebsd/include/rte_os_shim.h         |  17 +++
 lib/eal/windows/include/rte_os_shim.h         |  32 +++++
 10 files changed, 323 insertions(+), 101 deletions(-)
 rename drivers/net/pcap/{rte_eth_pcap.c => pcap_ethdev.c} (95%)
 create mode 100644 drivers/net/pcap/pcap_osdep.h
 create mode 100644 drivers/net/pcap/pcap_osdep_freebsd.c
 create mode 100644 drivers/net/pcap/pcap_osdep_linux.c
 create mode 100644 drivers/net/pcap/pcap_osdep_windows.c
  

Comments

Thomas Monjalon April 21, 2021, 9:54 p.m. UTC | #1
> Dmitry Kozlyuk (3):
>   eal: add timespec_get shim
>   net/pcap: move OS-dependent code to separate files
>   net/pcap: build on Windows

Unfortunately the CI testing FreeBSD 11 is not running on this series,
but I feel it's OK to be part of the 21.05-rc1.

Applied, thanks