Giter Club home page Giter Club logo

seladb / pcapplusplus Goto Github PK

View Code? Open in Web Editor NEW
2.6K 95.0 631.0 90.13 MB

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.

Home Page: https://pcapplusplus.github.io/

License: The Unlicense

C++ 95.01% C 0.44% Shell 0.06% Batchfile 0.07% Python 2.68% CMake 1.75%
pf-ring dpdk packet-parsing winpcap pcap-files pcap packet-processing cpp libpcap multiplatform

pcapplusplus's Introduction

PcapPlusPlus Logo

GitHub Workflow Status Cirrus CI - Base Branch Build Status GitHub Workflow Status Codecov GitHub contributors
Twitter Follow GitHub Repo stars

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use.

PcapPlusPlus enables decoding and forging capabilities for a large variety of network protocols. It also provides easy to use C++ wrappers for the most popular packet processing engines such as libpcap, WinPcap, Npcap, DPDK, eBPF AF_XDP and PF_RING.

Table Of Contents

Download

You can choose between downloading from GitHub release page, use a package manager or build PcapPlusPlus yourself. For more details please visit the Download page in PcapPlusPlus web-site.

GitHub all releases

GitHub Release Page

https://github.com/seladb/PcapPlusPlus/releases/latest

Homebrew

brew install pcapplusplus

Homebrew formulae: https://formulae.brew.sh/formula/pcapplusplus

Vcpkg

Windows:

.\vcpkg install pcapplusplus

MacOS/Linux:

vcpkg install pcapplusplus

Vcpkg port: https://github.com/microsoft/vcpkg/tree/master/ports/pcapplusplus

Conan

conan install "pcapplusplus/[>0]@" -u

The package in ConanCenter: https://conan.io/center/pcapplusplus

Build It Yourself

Clone the git repository:

git clone https://github.com/seladb/PcapPlusPlus.git

Follow the build instructions according to your platform in the Build From Source page in PcapPlusPlus web-site.

Feature Overview

  • Packet capture through an easy to use C++ wrapper for popular packet capture engines such as libpcap, WinPcap, Npcap, Intel DPDK, eBPF AF_XDP, ntop’s PF_RING and raw sockets [Learn more]
  • Packet parsing and crafting including detailed analysis of protocols and layers, packet generation and packet edit for a large variety of network protocols [Learn more]
  • Read and write packets from/to files in both PCAP and PCAPNG formats [Learn more]
  • Packet processing in line rate through an efficient and easy to use C++ wrapper for DPDK, eBPF AF_XDP and PF_RING [Learn more]
  • Multiplatform support - PcapPlusPlus is fully supported on Linux, MacOS, Windows, Android and FreeBSD
  • Packet reassembly - unique implementation of TCP Reassembly which includes TCP retransmission, out-of-order TCP packets and missing TCP data, and IP Fragmentation and Defragmentation to create and reassemble IPv4 and IPv6 fragments [Learn more]
  • Packet filtering that makes libpcap's BPF filters a lot more user-friendly [Learn more]
  • TLS Fingerprinting - a C++ implementation of JA3 and JA3S TLS fingerprinting [Learn more]

Getting Started

Writing applications with PcapPlusPlus is very easy and intuitive. Here is a simple application that shows how to read a packet from a PCAP file and parse it:

#include <iostream>
#include "IPv4Layer.h"
#include "Packet.h"
#include "PcapFileDevice.h"

int main(int argc, char* argv[])
{
    // open a pcap file for reading
    pcpp::PcapFileReaderDevice reader("1_packet.pcap");
    if (!reader.open())
    {
        std::cerr << "Error opening the pcap file" << std::endl;
        return 1;
    }

    // read the first (and only) packet from the file
    pcpp::RawPacket rawPacket;
    if (!reader.getNextPacket(rawPacket))
    {
        std::cerr << "Couldn't read the first packet in the file" << std::endl;
        return 1;
    }

    // parse the raw packet into a parsed packet
    pcpp::Packet parsedPacket(&rawPacket);

    // verify the packet is IPv4
    if (parsedPacket.isPacketOfType(pcpp::IPv4))
    {
        // extract source and dest IPs
        pcpp::IPv4Address srcIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getSrcIPv4Address();
        pcpp::IPv4Address destIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getDstIPv4Address();

        // print source and dest IPs
        std::cout << "Source IP is '" << srcIP << "'; Dest IP is '" << destIP << "'" << std::endl;
    }

    // close the file
    reader.close();

    return 0;
}

You can find much more information in the Getting Started page in PcapPlusPlus web-site. This page will walk you through few easy steps to have an app up and running.

API Documentation

PcapPlusPlus consists of 3 libraries:

  1. Packet++ - a library for parsing, creating and editing network packets
  2. Pcap++ - a library for intercepting and sending packets, providing network and NIC info, stats, etc. It is actually a C++ wrapper for packet capturing engines such as libpcap, WinPcap, Npcap, DPDK and PF_RING
  3. Common++ - a library with some common code utilities used by both Packet++ and Pcap++

You can find an extensive API documentation in the API documentation section in PcapPlusPlus web-site. If you see any missing data please contact us.

Multi Platform Support

PcapPlusPlus is currently supported on Windows , Linux , MacOS , Android and FreeBSD . Please visit PcapPlusPlus web-site to see all of the supported platforms and refer to the Download section to start using PcapPlusPlus on your platform.

Supported Network Protocols

PcapPlusPlus currently supports parsing, editing and creation of packets of the following protocols:

Data Link Layer (L2)

  1. Ethernet II
  2. IEEE 802.3 Ethernet
  3. LLC (Only BPDU supported)
  4. Null/Loopback
  5. Packet trailer (a.k.a footer or padding)
  6. PPPoE
  7. SLL (Linux cooked capture)
  8. SLL2 (Linux cooked capture v2)
  9. STP
  10. VLAN
  11. VXLAN
  12. Wake on LAN (WoL)
  13. NFLOG (Linux Netfilter NFLOG) - parsing only (no editing capabilities)

Network Layer (L3)

  1. ARP
  2. GRE
  3. ICMP
  4. ICMPv6
  5. IGMP (IGMPv1, IGMPv2 and IGMPv3 are supported)
  6. IPv4
  7. IPv6
  8. MPLS
  9. NDP
  10. Raw IP (IPv4 & IPv6)
  11. VRRP (IPv4 & IPv6)

Transport Layer (L4)

  1. COTP
  2. GTP (v1)
  3. IPSec AH & ESP - parsing only (no editing capabilities)
  4. TCP
  5. TPKT
  6. UDP

Session Layer (L5)

  1. SDP
  2. SIP

Presentation Layer (L6)

  1. SSL/TLS - parsing only (no editing capabilities)

Application Layer (L7)

  1. ASN.1 decoder and encoder
  2. BGP (v4)
  3. DHCP
  4. DHCPv6
  5. DNS
  6. FTP
  7. HTTP headers (request & response)
  8. NTP (v3, v4)
  9. Radius
  10. S7 Communication (S7comm)
  11. SMTP
  12. SOME/IP
  13. SSH - parsing only (no editing capabilities)
  14. Telnet - parsing only (no editing capabilities)
  15. Generic payload

DPDK And PF_RING Support

The Data Plane Development Kit (DPDK) is a set of data plane libraries and network interface controller drivers for fast packet processing.

PF_RING™ is a new type of network socket that dramatically improves the packet capture speed.

Both frameworks provide very fast packets processing (up to line speed) and are used in many network applications such as routers, firewalls, load balancers, etc. PcapPlusPLus provides a C++ abstraction layer over DPDK & PF_RING. This abstraction layer provides an easy to use interface that removes a lot of the boilerplate involved in using these frameworks. You can learn more by visiting the DPDK & PF_RING support pages in PcapPlusPlus web-site.

Benchmarks

We used Matias Fontanini's packet-capture-benchmarks project to compare the performance of PcapPlusPlus with other similar C++ libraries (such as libtins and libcrafter).

You can see the results in the Benchmarks page in PcapPlusPlus web-site.

Provide Feedback

We'd be more than happy to get feedback, please feel free to reach out to us in any of the following ways:

If you like this project please Star us on GitHub — it helps! ⭐ ⭐

Please visit the PcapPlusPlus web-site to learn more.

Contributing

We would very much appreciate any contribution to this project. If you're interested in contributing please visit the contribution page in PcapPlusPlus web-site.

License

PcapPlusPlus is released under the Unlicense license.

GitHub

pcapplusplus's People

Contributors

akvinikym avatar cartman-156 avatar clementperon avatar dependabot[bot] avatar dimi1010 avatar dysl3xik avatar echo-mike avatar egecetin avatar eteran avatar github-actions[bot] avatar jafar75 avatar jpcofr avatar kolbex avatar lapshin avatar makefriend8 avatar maruu avatar max197616 avatar miketruman avatar nanxiao avatar rickyzhang82 avatar sashashura avatar seladb avatar skorup101 avatar solvingj avatar szokovacs avatar tigercosmos avatar vicenterb avatar vrobles-gee avatar wivien19 avatar zlowram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pcapplusplus's Issues

'in.h' file not found #include <in.h>

Hello
I am running on Mac OS X and getting this probleme

And have an issue when running the DNSSpoof example file.. Please help
Full Error:

main.cpp:16:10: fatal error: 'in.h' file not found

include <in.h>

Segmentation fault: 11

On Mac Yosemite version 10.10.3, I'm trying to display the response times of each HTTP session from a pcap file.

I downloaded this pcap file::
https://github.com/open-nsm/course/blob/master/pcaps/nitroba.pcap

I downloaded PcapSplitter from here:
https://www.dropbox.com/sh/5go4ca778nu4zrm/AABbpDieIPBWQ0sGFNCWU7mza?dl=0

Ran this command:
PcapSplitter -m connection -f nitroba.pcap -o pcs

And got this error:
Started... Segmentation fault: 11

Any suggestions on what I'm doing wrong?

Thanks,

--Erik

Bad boundary check in TcpLayer.getTcpOptionData(TcpOption)

The TcpLayer.getTcpOptionData(TcpOption) method does boundary checking on the entire packet when parsing TCP options instead of the end of the TCP header.

This works fine when there is no payload in the packet (e.g. it's a SYN packet) and the end of the packet is the same as the end of the header, but when the packet has payload and the end of the entire packet is not the end of the header, it will either get stuck in an infinite loop when a 0 is read as option size somewhere in the payload, or return garbage as option data if the requested option code is found somewhere in the payload.

To fix it, the boundary check in the while loop should be changed from
while ((curOptPtr - m_Data) < m_DataLen)
to:
while ((curOptPtr - m_Data) < (((tcphdr *)m_Data)->dataOffset * 4))

Several cast errors in MinGW x64 4.8.1

Hello! I can't compile in MinGW x64 4.8.1, because the file Common/src/debug_new.cpp contains the error
debug_new.cpp:30:46: error: cast from 'void_' to 'long unsigned int' loses precision [-fpermissive]
#define DEBUG_NEW_HASH(p) (((unsigned long)(p) >> 8) % DEBUG_NEW_HASHTABLESIZE)
Also there are some other cast errors
src/PcapFilter.cpp:113:35: error: cast from 'uint8_t_ {aka unsigned char_}' to 'long int' loses precision
uint64_t addrLowerBytes = (long)addrAsArr;
src/PcapFilter.cpp:114:48: error: cast from 'uint8_t_ {aka unsigned char*}' to 'long int' loses precision
uint64_t addrHigherBytes = (long)(addrAsArr+8);

cannot find -lgcc_s

I'm attemping to build PcapTest++Test, then get the following error:

uname is: Linux
Building target: Pcap++Test
Invoking C++ Linker
g++ -L/home/moshe/git/PcapPlusPlus/Dist -L/home/moshe/git/PF_RING/kernel//userland/lib  -o "./Bin/Pcap++Test" Obj/main.o -lPcap++ -lPacket++ -lCommon++ -lpcap -lpthread -Wl,-Bstatic -lpfring -lnuma -lrt
/usr/bin/ld: cannot find -lgcc_s
/home/moshe/git/PcapPlusPlus/Dist/libCommon++.a(debug_new.o): In function `memset':
/usr/include/x86_64-linux-gnu/bits/string3.h:81: warning: memset used with constant zero length parameter; this could be due to transposed parameters
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make: *** [Pcap++Test] Error 1

The compiler version is:
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4

and I could find the lib file libgcc_s.so.1.

sudo ldconfig -p |grep gcc
    libuno_salhelpergcc3.so.3 (libc6,x86-64) => /usr/lib/libuno_salhelpergcc3.so.3
    libuno_purpenvhelpergcc3.so.3 (libc6,x86-64) => /usr/lib/libuno_purpenvhelpergcc3.so.3
    libuno_cppuhelpergcc3.so.3 (libc6,x86-64) => /usr/lib/libuno_cppuhelpergcc3.so.3
    libgccpp.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgccpp.so.1
    libgcc_s.so.1 (libc6,x32) => /usr/libx32/libgcc_s.so.1
    libgcc_s.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libgcc_s.so.1
    libgcc_s.so.1 (libc6) => /usr/lib32/libgcc_s.so.1
    libgcc_s.so (libc6,x86-64) => /usr/local/lib/libgcc_s.so

Off by one error in "Packet++/src/RawPacket.cpp RawPacket::insertData()

The method RawPacket::insertData() copies one extra byte when moving existing data. In the append case this writes 1 byte beyond the allocated memory for the packet.

I propose the following code for that method:

void RawPacket::insertData(int atIndex, const uint8_t* dataToInsert, size_t dataToInsertLen)
{
    int index = m_RawDataLen-1;
    while (index > atIndex)
    {
        m_pRawData[index+dataToInsertLen] = m_pRawData[index];
        index--;
    }

    memcpy((uint8_t*)m_pRawData+atIndex, dataToInsert, dataToInsertLen);
    m_RawDataLen += dataToInsertLen;
}

Expose pcap_set_immediate_mode()

It would be nice if this setting was exposed. Sometimes you need to get to packets in the fastest way possible (assuming there is not a lot of them).

PcapSplitter: Max. Bytes per File limited to 1.9 Gbyte

The total size per files uses an int to store the given parameter value. As the maximum value of an int is limited to 2,147,483,647, the largest max. bytes per file is 1.99 Gbyte. I know that this is just an example, but as the latest release contains the PcapSplitter as binary it also does a great job as an standalone utility. Therefore I would suggest adapting the PcapSplitter to support splitting into larger files.

I am looking into this because I need a splitting by file size and tcpdump, editcap and other tools, have the same limitation or do not provide splitting by file size at all. Would someone be so kind to tell me which customization is required to make this work? Thanks a lot!

Issue in setDeviceMacAddress

Hey there,

I think you have a bug in the setDeviceMacAddress. Firstly, thank you for making this library. I've been looking all over for an easy way to get a device MAC address in searching I found this to use a reference.

I believe that you need to actually allocate enough memory for your packet. Right now you're stomping over the stack when you do the packet request, because the PACKET_OID_DATA structure only has enough data for 1 byte.

So you need to allocate enough memory for the PACKET_OID_DATA and the MAC (6Bytes).

Also, just as a quick style comment. I've seen you have using std; in header files. This pollutes namespaces and you shouldn't force people using your library to get the entire std namespace brought into their project.

Build fails on some architectures

Namely ppc64:

In file included from src/DnsLayer.cpp:4:0:
src/DnsLayer.cpp: In member function 'bool pcpp::DnsResource::setData(const string&)':
../Common++/header/Logger.h:182:144: warning: format '%d' expects argument of type 'int', but argument 5 has type 'std::__cxx11::basic_string<char>::size_type {aka long unsigned int}' [-Wformat=]
      snprintf(pcpp::LoggerPP::getInstance().getErrorString(), pcpp::LoggerPP::getInstance().getErrorStringLength(), format "\n", ## __VA_ARGS__); \
                                                                                                                                                ^
src/DnsLayer.cpp:351:4: note: in expansion of macro 'LOG_ERROR'
    LOG_ERROR("DNS data for DNS type %d should be an hex stream with an even number of character. "
    ^~~~~~~~~
../Common++/header/Logger.h:184:49: warning: format '%d' expects argument of type 'int', but argument 4 has type 'std::__cxx11::basic_string<char>::size_type {aka long unsigned int}' [-Wformat=]
      fprintf(stderr, format "\n", ## __VA_ARGS__); \
                                                 ^
src/DnsLayer.cpp:351:4: note: in expansion of macro 'LOG_ERROR'
    LOG_ERROR("DNS data for DNS type %d should be an hex stream with an even number of character. "
    ^~~~~~~~~
 
Building file: src/IcmpLayer.cpp
Invoking: GCC C++ Compiler
g++ -DLINUX -I"./src" -I"./header" -I"../Common++/header" -I/usr/include/netinet -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"Obj/IcmpLayer.d" -MT"Obj/IcmpLayer.d" -o "Obj/IcmpLayer.o" "src/IcmpLayer.cpp"
In file included from ./header/IPv6Layer.h:5:0,
                 from src/IPv6Layer.cpp:3:
../Common++/header/IpAddress.h:78:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(char* addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv6Layer.h:5,
                 from src/IPv6Layer.cpp:3:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from ./header/IPv6Layer.h:5:0,
                 from src/IPv6Layer.cpp:3:
../Common++/header/IpAddress.h:86:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(std::string addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv6Layer.h:5,
                 from src/IPv6Layer.cpp:3:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from ./header/IPv4Layer.h:5:0,
                 from src/NullLoopbackLayer.cpp:2:
../Common++/header/IpAddress.h:78:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(char* addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv4Layer.h:5,
                 from src/NullLoopbackLayer.cpp:2:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from ./header/IPv4Layer.h:5:0,
                 from src/NullLoopbackLayer.cpp:2:
../Common++/header/IpAddress.h:86:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(std::string addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv4Layer.h:5,
                 from src/NullLoopbackLayer.cpp:2:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from ./header/IPv4Layer.h:5:0,
                 from src/PacketUtils.cpp:4:
../Common++/header/IpAddress.h:78:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(char* addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv4Layer.h:5,
                 from src/PacketUtils.cpp:4:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from ./header/IPv4Layer.h:5:0,
                 from src/PacketUtils.cpp:4:
../Common++/header/IpAddress.h:86:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(std::string addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv4Layer.h:5,
                 from src/PacketUtils.cpp:4:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
src/PacketUtils.cpp: In function 'uint32_t pcpp::hash5Tuple(pcpp::Packet*)':
src/PacketUtils.cpp:74:59: error: attempt to take address of bit-field
   vec[4].buffer = &(ipv6Layer->getIPv6Header()->nextHeader);
                                                           ^
In file included from ./header/IPv4Layer.h:5:0,
                 from ./header/IcmpLayer.h:5,
                 from src/IcmpLayer.cpp:3:
../Common++/header/IpAddress.h:78:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(char* addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv4Layer.h:5,
                 from ./header/IcmpLayer.h:5,
                 from src/IcmpLayer.cpp:3:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from ./header/IPv4Layer.h:5:0,
                 from ./header/IcmpLayer.h:5,
                 from src/IcmpLayer.cpp:3:
../Common++/header/IpAddress.h:86:15: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   static std::auto_ptr<IPAddress> fromString(std::string addressAsString);
               ^~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from ../Common++/header/IpAddress.h:4,
                 from ./header/IPv4Layer.h:5,
                 from ./header/IcmpLayer.h:5,
                 from src/IcmpLayer.cpp:3:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
Error 1

and s390x:

Building file: src/PacketUtils.cpp
Invoking: GCC C++ Compiler
g++ -DLINUX -I"./src" -I"./header" -I"../Common++/header" -I/usr/include/netinet -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"Obj/PacketUtils.d" -MT"Obj/PacketUtils.d" -o "Obj/PacketUtils.o" "src/PacketUtils.cpp"
src/PacketUtils.cpp: In function 'uint32_t pcpp::hash5Tuple(pcpp::Packet*)':
src/PacketUtils.cpp:74:59: error: attempt to take address of bit-field structure member 'pcpp::ip6_hdr::nextHeader'
   vec[4].buffer = &(ipv6Layer->getIPv6Header()->nextHeader);
                                                            ^
Makefile:35: recipe for target 'Obj/PacketUtils.o' failed
make[1]: *** [Obj/PacketUtils.o] Error 1

(note: ppc64le works).

I'm not sure whether those targets are officially supported yet, but I thought you should know.

Error compiling with boost asio included before TcpLayer.h

A simple program fails to compile

#include <boost/asio.hpp>
#include <TcpLayer.h>

int main() {
  return 0;
}

Error is

/home/krepver/Dev/lib/PcapPlusPlus-master/Dist/header/TcpLayer.h:88:3: error: expected identifier before numeric constant
   TCPOPT_NOP =    1,
   ^

Boost ends up including <netinet/tcp.h>, which has line 163 # define TCPOPT_NOP 1, so TCPOPT_NOP in TcpOption enum is replaced by "1".

My system is Ubuntu 16.04, gcc 4.9, boost 1.55

Bug in IDnsResource::decodeName.

If non-dns packet gets into DnsLayer, then we will get SIGSEGV, because function size_t IDnsResource::decodeName not checking going beyond the limits of the packet.

Pollution of global namespace

The library does not live in a namespace and is polluting the global namespace.
It would be nice if the library uses a namespace for all types and a prefix for all defines.
The issue can be reproduced by the following code snippet.

#include <iostream>
#include <boost/asio.hpp>
#include "TcpLayer.h"
int main() {
    return 0;
}

This leads on a Kubuntu 16.04 to the following error:

In file included from ../src/main.cpp:14:0:
/opt/pcapplusplus/header/TcpLayer.h:14:8: error: redefinition of ‘struct tcphdr’
struct tcphdr {
^
In file included from /usr/include/boost/asio/detail/socket_types.hpp:73:0,
from /usr/include/boost/asio/detail/epoll_reactor.hpp:30,
from /usr/include/boost/asio/detail/reactor.hpp:21,
from /usr/include/boost/asio/detail/impl/task_io_service.ipp:24,
from /usr/include/boost/asio/detail/task_io_service.hpp:198,
from /usr/include/boost/asio/impl/io_service.hpp:71,
from /usr/include/boost/asio/io_service.hpp:767,
from /usr/include/boost/asio/basic_io_object.hpp:19,
from /usr/include/boost/asio/basic_socket.hpp:20,
from /usr/include/boost/asio/basic_datagram_socket.hpp:20,
from /usr/include/boost/asio.hpp:21,
from ../src/main.cpp:13:
/usr/include/netinet/tcp.h:82:8: error: previous definition of ‘struct tcphdr’
struct tcphdr
^
/opt/pcapplusplus/header/TcpLayer.h:81:2: error: expected identifier before numeric constant
TCPOPT_NOP = 1,
^
/opt/pcapplusplus/header/TcpLayer.h:81:2: error: expected ‘}’ before numeric constant
/opt/pcapplusplus/header/TcpLayer.h:81:2: error: expected unqualified-id before numeric constant
In file included from ../src/main.cpp:14:0:
/opt/pcapplusplus/header/TcpLayer.h:128:1: error: expected declaration before ‘}’ token
};

I will create a pull request how I fixed this issue for me. Maybe it is helpful.

Support for DPDK 17.02?

Any plan to support DPDK 17.02? It looks like compiles with old versions (as it was mentioned in the README)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.