You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2017/11/14 01:48:22 UTC
[08/25] nifi-minifi-cpp git commit: MINIFICPP-250: Initial
implementation fo CapturePacket Processor that uses lipcap.
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PcapFilter.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PcapFilter.h b/thirdparty/pcap++/Pcap++/header/PcapFilter.h
new file mode 100644
index 0000000..f6671d1
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PcapFilter.h
@@ -0,0 +1,690 @@
+#ifndef PCAPP_FILTER
+#define PCAPP_FILTER
+
+#include <string>
+#include <vector>
+#include "ProtocolType.h"
+#include <stdint.h>
+#include <ArpLayer.h>
+
+/**
+ * @file
+ * Most packet capture engines contain packet filtering capabilities. In order to set the filters there should be a known syntax user can use.
+ * The most popular syntax is Berkeley Packet Filter (BPF) - see more in here: http://en.wikipedia.org/wiki/Berkeley_Packet_Filter.
+ * Detailed explanation of the syntax can be found here: http://www.tcpdump.org/manpages/pcap-filter.7.html.<BR>
+ * The problem with BPF is that, for my opinion, the syntax is too complicated and too poorly documented. In addition the BPF filter compilers
+ * may output syntax errors that are hard to understand. My experience with BPF was not good, so I decided to make the filters mechanism more
+ * structured, easier to understand and less error-prone by creating classes that represent filters. Each possible filter phrase is represented
+ * by a class. The filter, at the end, is that class.<BR>
+ * For example: the filter "src host 1.1.1.1" will be represented by IPFilter instance; "dst port 80" will be represented by PortFilter, and
+ * so on.<BR>
+ * So what about complex filters that involve "and", "or"? There are also 2 classes: AndFilter and OrFilter that can store more filters (in a
+ * composite idea) and connect them by "and" or "or". For example: "src host 1.1.1.1 and dst port 80" will be represented by an AndFilter that
+ * h olds IPFilter and PortFilter inside it
+ */
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ /**
+ * An enum that contains direction (source or destination)
+ */
+ typedef enum
+ {
+ /** Source */
+ SRC,
+ /** Destination */
+ DST,
+ /** Source or destination */
+ SRC_OR_DST
+ } Direction;
+
+
+ /**
+ * Supported operators enum
+ */
+ typedef enum
+ {
+ /** Equals */
+ EQUALS,
+ /** Not equals */
+ NOT_EQUALS,
+ /** Greater than */
+ GREATER_THAN,
+ /** Greater or equal */
+ GREATER_OR_EQUAL,
+ /** Less than */
+ LESS_THAN,
+ /** Less or equal */
+ LESS_OR_EQUAL
+ } FilterOperator;
+
+
+ /**
+ * @class GeneralFilter
+ * The base class for all filter classes. This class is virtual and abstract, hence cannot be instantiated.<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class GeneralFilter
+ {
+ public:
+ /**
+ * A method that parses the class instance into BPF string format
+ * @param[out] result An empty string that the parsing will be written into. If the string isn't empty, its content will be overridden
+ */
+ virtual void parseToString(std::string& result) = 0;
+
+ /**
+ * Virtual destructor, does nothing for this class
+ */
+ virtual ~GeneralFilter();
+ };
+
+
+ /**
+ * @class IFilterWithDirection
+ * An abstract class that is the base class for all filters which contain a direction (source or destination). This class cannot be instantiated<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class IFilterWithDirection : public GeneralFilter
+ {
+ private:
+ Direction m_Dir;
+ protected:
+ void parseDirection(std::string& directionAsString);
+ inline Direction getDir() { return m_Dir; }
+ IFilterWithDirection(Direction dir) { m_Dir = dir; }
+ public:
+ /**
+ * Set the direction for the filter (source or destination)
+ * @param[in] dir The direction
+ */
+ void setDirection(Direction dir) { m_Dir = dir; }
+ };
+
+
+ /**
+ * @class IFilterWithOperator
+ * An abstract class that is the base class for all filters which contain an operator (e.g X equals Y; A is greater than B; Z1 not equals Z2, etc.).
+ * This class cannot be instantiated<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class IFilterWithOperator : public GeneralFilter
+ {
+ private:
+ FilterOperator m_Operator;
+ protected:
+ std::string parseOperator();
+ inline FilterOperator getOperator() { return m_Operator; }
+ IFilterWithOperator(FilterOperator op) { m_Operator = op; }
+ public:
+ /**
+ * Set the operator for the filter
+ * @param[in] op The operator to set
+ */
+ void setOperator(FilterOperator op) { m_Operator = op; }
+ };
+
+
+
+ /**
+ * @class IPFilter
+ * A class for representing IPv4 address filter, equivalent to "net src x.x.x.x" or "net dst x.x.x.x"<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ * @todo Add IPv6 filtering support
+ */
+ class IPFilter : public IFilterWithDirection
+ {
+ private:
+ std::string m_Address;
+ std::string m_IPv4Mask;
+ int m_Len;
+ void convertToIPAddressWithMask(std::string& ipAddrmodified, std::string& mask);
+ void convertToIPAddressWithLen(std::string& ipAddrmodified, int& len);
+ public:
+ /**
+ * The basic constructor that creates the filter from an IPv4 address and direction (source or destination)
+ * @param[in] ipAddress The IPv4 address to build the filter with. If this address is not a valid IPv4 address an error will be
+ * written to log and parsing this filter will fail
+ * @param[in] dir The address direction to filter (source or destination)
+ */
+ IPFilter(const std::string& ipAddress, Direction dir) : IFilterWithDirection(dir), m_Address(ipAddress), m_IPv4Mask(""), m_Len(0) {}
+
+ /**
+ * A constructor that enable to filter only part of the address by using a mask (aka subnet). For example: "filter only IP addresses that matches
+ * the subnet 10.0.0.x"
+ * @param[in] ipAddress The IPv4 address to use. Only the part of the address that is not masked will be matched. For example: if the address
+ * is "1.2.3.4" and the mask is "255.255.255.0" than the part of the address that will be matched is "1.2.3.X". If this address is not a
+ * valid IPv4 address an error will be written to log and parsing this filter will fail
+ * @param[in] dir The address direction to filter (source or destination)
+ * @param[in] ipv4Mask The mask to use. Mask should also be in a valid IPv4 format (i.e x.x.x.x), otherwise parsing this filter will fail
+ */
+ IPFilter(const std::string& ipAddress, Direction dir, const std::string& ipv4Mask) : IFilterWithDirection(dir), m_Address(ipAddress), m_IPv4Mask(ipv4Mask), m_Len(0) {}
+
+ /**
+ * A constructor that enables to filter by a subnet. For example: "filter only IP addresses that matches the subnet 10.0.0.3/24" which means
+ * the part of the address that will be matched is "10.0.0.X"
+ * @param[in] ipAddress The IPv4 address to use. Only the part of the address that is not masked will be matched. For example: if the address
+ * is "1.2.3.4" and the subnet is "/24" than the part of the address that will be matched is "1.2.3.X". If this address is not a
+ * valid IPv4 address an error will be written to log and parsing this filter will fail
+ * @param[in] dir The address direction to filter (source or destination)
+ * @param[in] len The subnet to use (e.g "/24")
+ */
+ IPFilter(const std::string& ipAddress, Direction dir, int len) : IFilterWithDirection(dir), m_Address(ipAddress), m_IPv4Mask(""), m_Len(len) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the IPv4 address
+ * @param[in] ipAddress The IPv4 address to build the filter with. If this address is not a valid IPv4 address an error will be
+ * written to log and parsing this filter will fail
+ */
+ void setAddr(const std::string& ipAddress) { m_Address = ipAddress; }
+
+ /**
+ * Set the IPv4 mask
+ * @param[in] ipv4Mask The mask to use. Mask should also be in a valid IPv4 format (i.e x.x.x.x), otherwise parsing this filter will fail
+ */
+ void setMask(const std::string& ipv4Mask) { m_IPv4Mask = ipv4Mask; m_Len = 0; }
+
+ /**
+ * Set the subnet
+ * @param[in] len The subnet to use (e.g "/24")
+ */
+ void setLen(int len) { m_IPv4Mask = ""; m_Len = len; }
+ };
+
+
+
+ /**
+ * @class IpV4IDFilter
+ * A class for filtering IPv4 traffic by IP ID field of the IPv4 protocol, For example:
+ * "filter only IPv4 traffic which IP ID is greater than 1234"<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class IpV4IDFilter : public IFilterWithOperator
+ {
+ private:
+ uint16_t m_IpID;
+ public:
+ /**
+ * A constructor that gets the IP ID to filter and the operator and creates the filter out of them
+ * @param[in] ipID The IP ID to filter
+ * @param[in] op The operator to use (e.g "equal", "greater than", etc.)
+ */
+ IpV4IDFilter(uint16_t ipID, FilterOperator op) : IFilterWithOperator(op), m_IpID(ipID) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the IP ID to filter
+ * @param[in] ipID The IP ID to filter
+ */
+ void setIpID(uint16_t ipID) { m_IpID = ipID; }
+ };
+
+
+
+ /**
+ * @class IpV4TotalLengthFilter
+ * A class for filtering IPv4 traffic by "total length" field of the IPv4 protocol, For example:
+ * "filter only IPv4 traffic which "total length" value is less than 60B"<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class IpV4TotalLengthFilter : public IFilterWithOperator
+ {
+ private:
+ uint16_t m_TotalLength;
+ public:
+ /**
+ * A constructor that gets the total length to filter and the operator and creates the filter out of them
+ * @param[in] totalLength The total length value to filter
+ * @param[in] op The operator to use (e.g "equal", "greater than", etc.)
+ */
+ IpV4TotalLengthFilter(uint16_t totalLength, FilterOperator op) : IFilterWithOperator(op), m_TotalLength(totalLength) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the total length value
+ * @param[in] totalLength The total length value to filter
+ */
+ void setTotalLength(uint16_t totalLength) { m_TotalLength = totalLength; }
+ };
+
+
+
+ /**
+ * @class PortFilter
+ * A class for filtering TCP or UDP traffic by port, for example: "dst port 80" or "src port 12345"<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class PortFilter : public IFilterWithDirection
+ {
+ private:
+ std::string m_Port;
+ void portToString(uint16_t portAsInt);
+ public:
+ /**
+ * A constructor that gets the port and the direction and creates the filter
+ * @param[in] port The port to create the filter with
+ * @param[in] dir The port direction to filter (source or destination)
+ */
+ PortFilter(uint16_t port, Direction dir);
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the port
+ * @param[in] port The port to create the filter with
+ */
+ void setPort(uint16_t port) { portToString(port); }
+ };
+
+
+
+ /**
+ * @class PortRangeFilter
+ * A class for filtering TCP or UDP port ranges, meaning match only packets which port is within this range, for example: "src portrange 1000-2000"
+ * will match only TCP or UDP traffic which source port is in the range of 1000 - 2000<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class PortRangeFilter : public IFilterWithDirection
+ {
+ private:
+ uint16_t m_FromPort;
+ uint16_t m_ToPort;
+ public:
+ /**
+ * A constructor that gets the port range the the direction and creates the filter with them
+ * @param[in] fromPort The lower end of the port range
+ * @param[in] toPort The higher end of the port range
+ * @param[in] dir The port range direction to filter (source or destination)
+ */
+ PortRangeFilter(uint16_t fromPort, uint16_t toPort, Direction dir) : IFilterWithDirection(dir), m_FromPort(fromPort), m_ToPort(toPort) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the lower end of the port range
+ * @param[in] fromPort The lower end of the port range
+ */
+ void setFromPort(uint16_t fromPort) { m_FromPort = fromPort; }
+
+ /**
+ * Set the higher end of the port range
+ * @param[in] toPort The higher end of the port range
+ */
+ void setToPort(uint16_t toPort) { m_ToPort = toPort; }
+ };
+
+
+
+ /**
+ * @class MacAddressFilter
+ * A class for filtering Ethernet traffic by MAC addresses, for example: "ether src 12:34:56:78:90:12" or "ether dst "10:29:38:47:56:10:29"<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class MacAddressFilter : public IFilterWithDirection
+ {
+ private:
+ MacAddress m_MacAddress;
+ public:
+ /**
+ * A constructor that gets the MAC address and the direction and creates the filter with them
+ * @param[in] address The MAC address to use for filtering
+ * @param[in] dir The MAC address direction to filter (source or destination)
+ */
+ MacAddressFilter(MacAddress address, Direction dir) : IFilterWithDirection(dir), m_MacAddress(address) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the MAC address
+ * @param[in] address The MAC address to use for filtering
+ */
+ void setMacAddress(MacAddress address) { m_MacAddress = address; }
+ };
+
+
+
+ /**
+ * @class EtherTypeFilter
+ * A class for filtering by EtherType field of the Ethernet protocol. This enables to filter packets from certain protocols, such as ARP, IPv4,
+ * IPv6, VLAN tags, etc.<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class EtherTypeFilter : public GeneralFilter
+ {
+ private:
+ uint16_t m_EtherType;
+ public:
+ /**
+ * A constructor that gets the EtherType and creates the filter with it
+ * @param[in] etherType The EtherType value to create the filter with
+ */
+ EtherTypeFilter(uint16_t etherType) : m_EtherType(etherType) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the EtherType value
+ * @param[in] etherType The EtherType value to create the filter with
+ */
+ void setEtherType(uint16_t etherType) { m_EtherType = etherType; }
+ };
+
+
+
+ /**
+ * @class AndFilter
+ * A class for connecting several filters into one filter with logical "and" between them. For example: if the 2 filters are: "IPv4 address =
+ * x.x.x.x" + "TCP port dst = 80", then the new filter will be: "IPv4 address = x.x.x.x _AND_ TCP port dst = 80"<BR>
+ * This class follows the composite design pattern<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ * @todo add some methods: "addFilter", "removeFilter", "clearAllFilter"
+ */
+ class AndFilter : public GeneralFilter
+ {
+ private:
+ std::vector<GeneralFilter*> m_FilterList;
+ public:
+
+ /**
+ * An empty constructor for this class. Use addFilter() to add filters to the and condition
+ */
+ AndFilter() {}
+
+ /**
+ * A constructor that gets a list of pointers to filters and creates one filter from all filters with logical "and" between them
+ * @param[in] filters The list of pointers to filters
+ */
+ AndFilter(std::vector<GeneralFilter*>& filters);
+
+ /**
+ * Add filter to the and condition
+ * @param[in] filter The filter to add
+ */
+ void addFilter(GeneralFilter* filter) { m_FilterList.push_back(filter); }
+
+ void parseToString(std::string& result);
+ };
+
+
+
+ /**
+ * @class OrFilter
+ * A class for connecting several filters into one filter with logical "or" between them. For example: if the 2 filters are: "IPv4 address =
+ * x.x.x.x" + "TCP port dst = 80", then the new filter will be: "IPv4 address = x.x.x.x _OR_ TCP port dst = 80"<BR>
+ * This class follows the composite design pattern<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ * @todo add some methods: "addFilter", "removeFilter", "clearAllFilter"
+ */
+ class OrFilter : public GeneralFilter
+ {
+ private:
+ std::vector<GeneralFilter*> m_FilterList;
+ public:
+
+ /**
+ * An empty constructor for this class. Use addFilter() to add filters to the or condition
+ */
+ OrFilter() {}
+
+ /**
+ * A constructor that gets a list of pointers to filters and creates one filter from all filters with logical "or" between them
+ * @param[in] filters The list of pointers to filters
+ */
+ OrFilter(std::vector<GeneralFilter*>& filters);
+
+ /**
+ * Add filter to the or condition
+ * @param[in] filter The filter to add
+ */
+ void addFilter(GeneralFilter* filter) { m_FilterList.push_back(filter); }
+
+ void parseToString(std::string& result);
+ };
+
+
+
+ /**
+ * @class NotFilter
+ * A class for creating a filter which is inverse to another filter<BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class NotFilter : public GeneralFilter
+ {
+ private:
+ GeneralFilter* m_FilterToInverse;
+ public:
+ /**
+ * A constructor that gets a pointer to a filter and create the inverse version of it
+ * @param[in] filterToInverse A pointer to filter which the created filter be the inverse of
+ */
+ NotFilter(GeneralFilter* filterToInverse) { m_FilterToInverse = filterToInverse; }
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set a filter to create an inverse filter from
+ * @param[in] filterToInverse A pointer to filter which the created filter be the inverse of
+ */
+ void setFilter(GeneralFilter* filterToInverse) { m_FilterToInverse = filterToInverse; }
+ };
+
+
+
+ /**
+ * @class ProtoFilter
+ * A class for filtering traffic by protocol. Notice not all protocols are supported, only the following are supported:
+ * ::TCP, ::UDP, ::ICMP, ::VLAN, ::IPv4, ::IPv6, ::ARP, ::Ethernet. <BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class ProtoFilter : public GeneralFilter
+ {
+ private:
+ ProtocolType m_Proto;
+ public:
+ /**
+ * A constructor that gets the protocol and creates the filter
+ * @param[in] proto The protocol to filter, only packets matching this protocol will be received. Please note not all protocols are
+ * supported. List of supported protocols is found in the class description
+ */
+ ProtoFilter(ProtocolType proto) { m_Proto = proto; }
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the protocol to filter with
+ * @param[in] proto The protocol to filter, only packets matching this protocol will be received. Please note not all protocols are
+ * supported. List of supported protocols is found in the class description
+ */
+ void setProto(ProtocolType proto) { m_Proto = proto; }
+ };
+
+
+
+ /**
+ * @class ArpFilter
+ * A class for filtering ARP packets according the ARP opcode. When using this filter only ARP packets with the relevant opcode will be
+ * received <BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class ArpFilter : public GeneralFilter
+ {
+ private:
+ ArpOpcode m_OpCode;
+ public:
+ /**
+ * A constructor that get the ARP opcode and creates the filter
+ * @param[in] opCode The ARP opcode: ::ARP_REQUEST or ::ARP_REPLY
+ */
+ ArpFilter(ArpOpcode opCode) { m_OpCode = opCode; }
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the ARP opcode
+ * @param[in] opCode The ARP opcode: ::ARP_REQUEST or ::ARP_REPLY
+ */
+ void setOpCode(ArpOpcode opCode) { m_OpCode = opCode; }
+ };
+
+
+
+ /**
+ * @class VlanFilter
+ * A class for filtering VLAN tagged packets by VLAN ID. When using this filter only packets tagged with VLAN which has the specific VLAN ID
+ * will be received <BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class VlanFilter : public GeneralFilter
+ {
+ private:
+ uint16_t m_VlanID;
+ public:
+ /**
+ * A constructor the gets the VLAN ID and creates the filter
+ * @param[in] vlanId The VLAN ID to use for the filter
+ */
+ VlanFilter(uint16_t vlanId) : m_VlanID(vlanId) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set the VLAN ID of the filter
+ * @param[in] vlanId The VLAN ID to use for the filter
+ */
+ void setVlanID(uint16_t vlanId) { m_VlanID = vlanId; }
+ };
+
+
+
+ /**
+ * @class TcpFlagsFilter
+ * A class for filtering only TCP packets which certain TCP flags are set in them <BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class TcpFlagsFilter : public GeneralFilter
+ {
+ public:
+ /**
+ * An enum of all TCP flags that can be use in the filter
+ */
+ enum TcpFlags
+ {
+ /** TCP FIN flag */
+ tcpFin = 1,
+ /** TCP SYN flag */
+ tcpSyn = 2,
+ /** TCP RST flag */
+ tcpRst = 4,
+ /** TCP PSH flag */
+ tcpPush = 8,
+ /** TCP ACK flag */
+ tcpAck = 16,
+ /** TCP URG flag */
+ tcpUrg = 32
+ };
+
+ /**
+ * An enum for representing 2 type of matches: match only packets that contain all flags defined in the filter or match packets that
+ * contain at least one of the flags defined in the filter
+ */
+ enum MatchOptions
+ {
+ /** Match only packets that contain all flags defined in the filter */
+ MatchAll,
+ /** Match packets that contain at least one of the flags defined in the filter */
+ MatchOneAtLeast
+ };
+ private:
+ uint8_t m_TcpFlagsBitMask;
+ MatchOptions m_MatchOption;
+ public:
+ /**
+ * A constructor that gets a 1-byte bitmask containing all TCP flags participating in the filter and the match option, and
+ * creates the filter
+ * @param[in] tcpFlagBitMask A 1-byte bitmask containing all TCP flags participating in the filter. This parameter can contain the
+ * following value for example: TcpFlagsFilter::tcpSyn | TcpFlagsFilter::tcpAck | TcpFlagsFilter::tcpUrg
+ * @param[in] matchOption The match option: TcpFlagsFilter::MatchAll or TcpFlagsFilter::MatchOneAtLeast
+ */
+ TcpFlagsFilter(uint8_t tcpFlagBitMask, MatchOptions matchOption) : m_TcpFlagsBitMask(tcpFlagBitMask), m_MatchOption(matchOption) {}
+
+ /**
+ * Set the TCP flags and the match option
+ * @param[in] tcpFlagBitMask A 1-byte bitmask containing all TCP flags participating in the filter. This parameter can contain the
+ * following value for example: TcpFlagsFilter::tcpSyn | TcpFlagsFilter::tcpAck | TcpFlagsFilter::tcpUrg
+ * @param[in] matchOption The match option: TcpFlagsFilter::MatchAll or TcpFlagsFilter::MatchOneAtLeast
+ */
+ void setTcpFlagsBitMask(uint8_t tcpFlagBitMask, MatchOptions matchOption) { m_TcpFlagsBitMask = tcpFlagBitMask; m_MatchOption = matchOption; }
+
+ void parseToString(std::string& result);
+ };
+
+
+
+ /**
+ * @class TcpWindowSizeFilter
+ * A class for filtering TCP packets that matches TCP window-size criteria <BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class TcpWindowSizeFilter : public IFilterWithOperator
+ {
+ private:
+ uint16_t m_WindowSize;
+ public:
+ /**
+ * A constructor that get the window-size and operator and creates the filter. For example: "filter all TCP packets with window-size
+ * less than 1000"
+ * @param[in] windowSize The window-size value that will be used in the filter
+ * @param[in] op The operator to use (e.g "equal", "greater than", etc.)
+ */
+ TcpWindowSizeFilter(uint16_t windowSize, FilterOperator op) : IFilterWithOperator(op), m_WindowSize(windowSize) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set window-size value
+ * @param[in] windowSize The window-size value that will be used in the filter
+ */
+ void setWindowSize(uint16_t windowSize) { m_WindowSize = windowSize; }
+ };
+
+
+
+ /**
+ * @class UdpLengthFilter
+ * A class for filtering UDP packets that matches UDP length criteria <BR>
+ * For deeper understanding of the filter concept please refer to PcapFilter.h
+ */
+ class UdpLengthFilter : public IFilterWithOperator
+ {
+ private:
+ uint16_t m_Length;
+ public:
+ /**
+ * A constructor that get the UDP length and operator and creates the filter. For example: "filter all UDP packets with length
+ * greater or equal to 500"
+ * @param[in] legnth The length value that will be used in the filter
+ * @param[in] op The operator to use (e.g "equal", "greater than", etc.)
+ */
+ UdpLengthFilter(uint16_t legnth, FilterOperator op) : IFilterWithOperator(op), m_Length(legnth) {}
+
+ void parseToString(std::string& result);
+
+ /**
+ * Set legnth value
+ * @param[in] legnth The legnth value that will be used in the filter
+ */
+ void setLength(uint16_t legnth) { m_Length = legnth; }
+ };
+
+} // namespace pcpp
+
+#endif
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PcapLiveDevice.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PcapLiveDevice.h b/thirdparty/pcap++/Pcap++/header/PcapLiveDevice.h
new file mode 100644
index 0000000..ee1fa22
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PcapLiveDevice.h
@@ -0,0 +1,405 @@
+//TODO: replace all these defines with #pragma once
+#ifndef PCAPPP_LIVE_DEVICE
+#define PCAPPP_LIVE_DEVICE
+
+#include <PcapDevice.h>
+#include <vector>
+#include <string.h>
+#include "IpAddress.h"
+#include <Packet.h>
+
+
+/// @file
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ class PcapLiveDevice;
+
+ /**
+ * @typedef OnPacketArrivesCallback
+ * A callback that is called when a packet is captured by PcapLiveDevice
+ * @param[in] pPacket A pointer to the raw packet
+ * @param[in] pDevice A pointer to the PcapLiveDevice instance
+ * @param[in] userCookie A pointer to the object put by the user when packet capturing stared
+ */
+ typedef void (*OnPacketArrivesCallback)(RawPacket* pPacket, PcapLiveDevice* pDevice, void* userCookie);
+
+ /**
+ * @typedef OnPacketArrivesStopBlocking
+ * A callback that is called when a packet is captured by PcapLiveDevice
+ * @param[in] pPacket A pointer to the raw packet
+ * @param[in] pDevice A pointer to the PcapLiveDevice instance
+ * @param[in] userCookie A pointer to the object put by the user when packet capturing stared
+ * @return True when main thread should stop blocking or false otherwise
+ */
+ typedef bool (*OnPacketArrivesStopBlocking)(RawPacket* pPacket, PcapLiveDevice* pDevice, void* userData);
+
+
+ /**
+ * @typedef OnStatsUpdateCallback
+ * A callback that is called periodically for stats collection if user asked to start packet capturing with periodic stats collection
+ * @param[in] stats A reference to the most updated stats
+ * @param[in] userCookie A pointer to the object put by the user when packet capturing stared
+ */
+ typedef void (*OnStatsUpdateCallback)(pcap_stat& stats, void* userCookie);
+
+ // for internal use only
+ typedef void* (*ThreadStart)(void*);
+
+ struct PcapThread;
+
+ /**
+ * @class PcapLiveDevice
+ * A class that wraps a network interface (each of the interfaces listed in ifconfig/ipconfig).
+ * This class wraps the libpcap capabilities of capturing packets from the network, filtering packets and sending packets back to the network.
+ * This class is relevant for Linux applications only. On Windows the WinPcapLiveDevice (which inherits this class) is used. Both classes are
+ * almost similar in capabilities, the main difference between them is adapting some capabilities to the specific OS.
+ * This class cannot be instantiated by the user (it has a private constructor), as network interfaces aren't dynamic. Instances of
+ * this class (one instance per network interface) are created by PcapLiveDeviceList singleton on application startup and the user can get
+ * access to them by using PcapLiveDeviceList public methods such as PcapLiveDeviceList#getPcapLiveDeviceByIp()<BR>
+ * Main capabilities of this class:
+ * - Get all available information for this network interfaces such as name, IP addresses, MAC address, MTU, etc. This information is taken
+ * from both libpcap and the OS
+ * - Capture packets from the network. Capturing is always conducted on a different thread. PcapPlusPlus creates this
+ * thread when capturing starts and kills it when capturing ends. This prevents the application from being stuck while waiting for packets or
+ * processing them. Currently only one capturing thread is allowed, so when the interface is in capture mode, no further capturing is allowed.
+ * In addition to capturing the user can get stats on packets that were received by the application, dropped by the NIC (due to full
+ * NIC buffers), etc. Stats collection can be initiated by the user by calling getStatistics() or be pushed to the user periodically by
+ * supplying a callback and a timeout to startCapture()
+ * - Send packets back to the network. Sending the packets is done on the caller thread. No additional threads are created for this task
+ */
+ class PcapLiveDevice : public IPcapDevice
+ {
+ friend class PcapLiveDeviceList;
+ protected:
+ // This is a second descriptor for the same device. It is needed because of a bug
+ // that occurs in libpcap on Linux (on Windows using WinPcap it works well):
+ // It's impossible to capture packets sent by the same descriptor
+ pcap_t* m_PcapSendDescriptor;
+ const char* m_Name;
+ const char* m_Description;
+ bool m_IsLoopback;
+ uint16_t m_DeviceMtu;
+ std::vector<pcap_addr_t> m_Addresses;
+ MacAddress m_MacAddress;
+ IPv4Address m_DefaultGateway;
+ PcapThread* m_CaptureThread;
+ bool m_CaptureThreadStarted;
+ PcapThread* m_StatsThread;
+ bool m_StatsThreadStarted;
+ bool m_StopThread;
+ OnPacketArrivesCallback m_cbOnPacketArrives;
+ void* m_cbOnPacketArrivesUserCookie;
+ OnStatsUpdateCallback m_cbOnStatsUpdate;
+ void* m_cbOnStatsUpdateUserCookie;
+ OnPacketArrivesStopBlocking m_cbOnPacketArrivesBlockingMode;
+ void* m_cbOnPacketArrivesBlockingModeUserCookie;
+ int m_IntervalToUpdateStats;
+ RawPacketVector* m_CapturedPackets;
+ bool m_CaptureCallbackMode;
+
+ // c'tor is not public, there should be only one for every interface (created by PcapLiveDeviceList)
+ PcapLiveDevice(pcap_if_t* pInterface, bool calculateMTU, bool calculateMacAddress, bool calculateDefaultGateway);
+ // copy c'tor is not public
+ PcapLiveDevice( const PcapLiveDevice& other );
+ PcapLiveDevice& operator=(const PcapLiveDevice& other);
+
+ void setDeviceMtu();
+ void setDeviceMacAddress();
+ void setDefaultGateway();
+ static void* captureThreadMain(void *ptr);
+ static void* statsThreadMain(void *ptr);
+ static void onPacketArrives(uint8_t *user, const struct pcap_pkthdr *pkthdr, const uint8_t *packet);
+ static void onPacketArrivesNoCallback(uint8_t *user, const struct pcap_pkthdr *pkthdr, const uint8_t *packet);
+ static void onPacketArrivesBlockingMode(uint8_t *user, const struct pcap_pkthdr *pkthdr, const uint8_t *packet);
+ std::string printThreadId(PcapThread* id);
+ virtual ThreadStart getCaptureThreadStart();
+ public:
+ /**
+ * The type of the live device
+ */
+ enum LiveDeviceType {
+ /** libPcap live device */
+ LibPcapDevice,
+ /** WinPcap live device */
+ WinPcapDevice,
+ /** WinPcap Remote Capture device */
+ RemoteDevice
+ };
+
+ /**
+ * Device capturing mode
+ */
+ enum DeviceMode {
+ /** Only packets that their destination is this NIC are captured */
+ Normal = 0,
+ /** All packets that arrive to the NIC are captured, even packets that their destination isn't this NIC */
+ Promiscuous = 1
+ };
+
+ /**
+ * A destructor for this class
+ */
+ virtual ~PcapLiveDevice();
+
+ /**
+ * @return The type of the device (libPcap, WinPcap or a remote device)
+ */
+ virtual LiveDeviceType getDeviceType() { return LibPcapDevice; }
+
+ /**
+ * @return The name of the device (e.g eth0), taken from pcap_if_t->name
+ */
+ inline const char* getName() { return m_Name; }
+
+ /**
+ * @return A human-readable description of the device, taken from pcap_if_t->description. May be NULL in some interfaces
+ */
+ inline const char* getDesc() { return m_Description; }
+
+ /**
+ * @return True if this interface is a loopback interface, false otherwise
+ */
+ inline bool getLoopback() { return m_IsLoopback; }
+
+ /**
+ * @return The device's maximum transmission unit (MTU) in bytes
+ */
+ virtual inline uint16_t getMtu() { return m_DeviceMtu; }
+
+ /**
+ * @return A vector containing all addresses defined for this interface, each in pcap_addr_t struct
+ */
+ inline std::vector<pcap_addr_t>& getAddresses() { return m_Addresses; }
+
+ /**
+ * @return The MAC address for this interface
+ */
+ virtual inline MacAddress getMacAddress() { return m_MacAddress; }
+
+ /**
+ * @return The IPv4 address for this interface. If multiple IPv4 addresses are defined for this interface, the first will be picked.
+ * If no IPv4 addresses are defined, a zeroed IPv4 address (IPv4Address#Zero) will be returned
+ */
+ IPv4Address getIPv4Address();
+
+ /**
+ * @return The default gateway defined for this interface. If no default gateway is defined, if it's not IPv4 or if couldn't extract
+ * default gateway IPv4Address#Zero will be returned. If multiple gateways were defined the first one will be returned
+ */
+ IPv4Address getDefaultGateway();
+
+ /**
+ * @return A list of all DNS servers defined for this machine. If this list is empty it means no DNS servers were defined or they
+ * couldn't be extracted from some reason. This list is created in PcapLiveDeviceList class and can be also retrieved from there.
+ * This method exists for convenience - so it'll be possible to get this list from PcapLiveDevice as well
+ */
+ std::vector<IPv4Address>& getDnsServers();
+
+ /**
+ * Start capturing packets on this network interface (device). Each time a packet is captured the onPacketArrives callback is called.
+ * The capture is done on a new thread created by this method, meaning all callback calls are done in a thread other than the
+ * caller thread. Capture process will stop and this capture thread will be terminated when calling stopCapture(). This method must be
+ * called after the device is opened (i.e the open() method was called), otherwise an error will be returned.
+ * @param[in] onPacketArrives A callback that is called each time a packet is captured
+ * @param[in] onPacketArrivesUserCookie A pointer to a user provided object. This object will be transferred to the onPacketArrives callback
+ * each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example:
+ * objects that counts packets, manages flow state or manages the application state according to the packet that was captured
+ * @return True if capture started successfully, false if (relevant log error is printed in any case):
+ * - Capture is already running
+ * - Device is not opened
+ * - Capture thread could not be created
+ */
+ virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void* onPacketArrivesUserCookie);
+
+ /**
+ * Start capturing packets on this network interface (device) with periodic stats collection. Each time a packet is captured the onPacketArrives
+ * callback is called. In addition, each intervalInSecondsToUpdateStats seconds stats are collected from the device and the onStatsUpdate
+ * callback is called. Both the capture and periodic stats collection are done on new threads created by this method, each on a different thread,
+ * meaning all callback calls are done in threads other than the caller thread. Capture process and stats collection will stop and threads will be
+ * terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called), otherwise an
+ * error will be returned.
+ * @param[in] onPacketArrives A callback that is called each time a packet is captured
+ * @param[in] onPacketArrivesUserCookie A pointer to a user provided object. This object will be transferred to the onPacketArrives callback
+ * each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example:
+ * objects that counts packets, manages flow state or manages the application state according to the packet that was captured
+ * @param[in] intervalInSecondsToUpdateStats The interval in seconds to activate periodic stats collection
+ * @param[in] onStatsUpdate A callback that will be called each time intervalInSecondsToUpdateStats expires and stats are collected. This
+ * callback will contain the collected stats
+ * @param[in] onStatsUpdateUserCookie A pointer to a user provided object. This object will be transferred to the onStatsUpdate callback
+ * each time it is called
+ * @return True if capture started successfully, false if (relevant log error is printed in any case):
+ * - Capture is already running
+ * - Device is not opened
+ * - Capture thread could not be created
+ * - Stats collection thread could not be created
+ */
+ virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void* onPacketArrivesUserCookie, int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void* onStatsUpdateUserCookie);
+
+ /**
+ * Start capturing packets on this network interface (device) with periodic stats collection only. This means that packets arriving to the
+ * network interface aren't delivered to the user but only counted. Each intervalInSecondsToUpdateStats seconds stats are collected from the
+ * device and the onStatsUpdate callback is called with the updated counters. The periodic stats collection is done on a new thread created
+ * by this method, meaning all callback calls are done in threads other than the caller thread. Stats collection will stop and threads will
+ * be terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called),
+ * otherwise an error will be returned.
+ * @param[in] intervalInSecondsToUpdateStats The interval in seconds to activate periodic stats collection
+ * @param[in] onStatsUpdate A callback that will be called each time intervalInSecondsToUpdateStats expires and stats are collected. This
+ * callback will contain the collected stats
+ * @param[in] onStatsUpdateUserCookie A pointer to a user provided object. This object will be transferred to the onStatsUpdate callback
+ * each time it is called
+ * @return True if capture started successfully, false if (relevant log error is printed in any case):
+ * - Capture is already running
+ * - Device is not opened
+ * - Stats collection thread could not be created
+ */
+ virtual bool startCapture(int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void* onStatsUpdateUserCookie);
+
+ /**
+ * Start capturing packets on this network interface (device). All captured packets are added to capturedPacketsVector, so at the end of
+ * the capture (when calling stopCapture()) this vector contains pointers to all captured packets in the form of RawPacket. The capture
+ * is done on a new thread created by this method, meaning capturedPacketsVector is updated from another thread other than the caller
+ * thread (so user should avoid changing or iterating this vector while capture is on). Capture process will stop and this capture thread
+ * will be terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called),
+ * otherwise an error will be returned.
+ * @param[in] capturedPacketsVector A reference to a RawPacketVector, meaning a vector of pointer to RawPacket objects
+ * @return True if capture started successfully, false if (relevant log error is printed in any case):
+ * - Capture is already running
+ * - Device is not opened
+ * - Capture thread could not be created
+ */
+ virtual bool startCapture(RawPacketVector& capturedPacketsVector);
+
+ /**
+ * Start capturing packets on this network interface (device) in blocking mode, meaning this method blocks and won't return until
+ * the user frees the blocking (via onPacketArrives callback) or until a user defined timeout expires.
+ * Whenever a packets is captured the onPacketArrives callback is called and lets the user handle the packet. In each callback call
+ * the user should return true if he wants to release the block or false if it wants it to keep blocking. Regardless of this callback
+ * a timeout is defined when start capturing. When this timeout expires the method will return.<BR>
+ * Please notice that stopCapture() isn't needed here because when the method returns (after timeout or per user decision) capturing
+ * on the device is stopped
+ * @param[in] onPacketArrives A callback given by the user for handling incoming packets. After handling each packet the user needs to
+ * return a boolean value. True value indicates stop capturing and stop blocking and false value indicates continue capturing and blocking
+ * @param[in] userCookie A pointer to a user provided object. This object will be transferred to the onPacketArrives callback
+ * each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example:
+ * objects that counts packets, manages flow state or manages the application state according to the packet that was captured
+ * @param[in] timeout A timeout in seconds for the blocking to stop even if the user didn't return "true" in the onPacketArrives callback
+ * If this timeout is set to 0 or less the timeout will be ignored, meaning the method will keep blocking until the user frees it via
+ * the onPacketArrives callback
+ * @return -1 if timeout expired, 1 if blocking was stopped via onPacketArrives callback or 0 if an error occurred (such as device
+ * not open etc.). When returning 0 an appropriate error message is printed to log
+ */
+ virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void* userCookie, int timeout);
+
+ /**
+ * Stop a currently running packet capture. This method terminates gracefully both packet capture thread and periodic stats collection
+ * thread (both if exist)
+ */
+ void stopCapture();
+
+ /**
+ * Send a RawPacket to the network
+ * @param[in] rawPacket A reference to the raw packet to send. This method treats the raw packet as read-only, it doesn't change anything
+ * in it
+ * @return True if packet was sent successfully. False will be returned in the following cases (relevant log error is printed in any case):
+ * - Device is not opened
+ * - Packet length is 0
+ * - Packet length is larger than device MTU
+ * - Packet could not be sent due to some error in libpcap/WinPcap
+ */
+ bool sendPacket(RawPacket const& rawPacket);
+
+ /**
+ * Send a buffer containing packet raw data (including all layers) to the network
+ * @param[in] packetData The buffer containing the packet raw data
+ * @param[in] packetDataLength The length of the buffer
+ * @return True if packet was sent successfully. False will be returned in the following cases (relevant log error is printed in any case):
+ * - Device is not opened
+ * - Packet length is 0
+ * - Packet length is larger than device MTU
+ * - Packet could not be sent due to some error in libpcap/WinPcap
+ */
+ bool sendPacket(const uint8_t* packetData, int packetDataLength);
+
+ /**
+ * Send a parsed Packet to the network
+ * @param[in] packet A pointer to the packet to send. This method treats the packet as read-only, it doesn't change anything in it
+ * @return True if packet was sent successfully. False will be returned in the following cases (relevant log error is printed in any case):
+ * - Device is not opened
+ * - Packet length is 0
+ * - Packet length is larger than device MTU
+ * - Packet could not be sent due to some error in libpcap/WinPcap
+ */
+ bool sendPacket(Packet* packet);
+
+ /**
+ * Send an array of RawPacket objects to the network
+ * @param[in] rawPacketsArr The array of RawPacket objects to send. This method treats all packets as read-only, it doesn't change anything
+ * in them
+ * @param[in] arrLength The length of the array
+ * @return The number of packets sent successfully. Sending a packet can fail if:
+ * - Device is not opened. In this case no packets will be sent, return value will be 0
+ * - Packet length is 0
+ * - Packet length is larger than device MTU
+ * - Packet could not be sent due to some error in libpcap/WinPcap
+ */
+ virtual int sendPackets(RawPacket* rawPacketsArr, int arrLength);
+
+ /**
+ * Send an array of pointers to Packet objects to the network
+ * @param[in] packetsArr The array of pointers to Packet objects to send. This method treats all packets as read-only, it doesn't change
+ * anything in them
+ * @param[in] arrLength The length of the array
+ * @return The number of packets sent successfully. Sending a packet can fail if:
+ * - Device is not opened. In this case no packets will be sent, return value will be 0
+ * - Packet length is 0
+ * - Packet length is larger than device MTU
+ * - Packet could not be sent due to some error in libpcap/WinPcap
+ */
+ virtual int sendPackets(Packet** packetsArr, int arrLength);
+
+ /**
+ * Send a vector of pointers to RawPacket objects to the network
+ * @param[in] rawPackets The array of pointers to RawPacket objects to send. This method treats all packets as read-only, it doesn't change
+ * anything in them
+ * @return The number of packets sent successfully. Sending a packet can fail if:
+ * - Device is not opened. In this case no packets will be sent, return value will be 0
+ * - Packet length is 0
+ * - Packet length is larger than device MTU
+ * - Packet could not be sent due to some error in libpcap/WinPcap
+ */
+ virtual int sendPackets(const RawPacketVector& rawPackets);
+
+ //override methods
+
+ /**
+ * Open the device using libpcap pcap_open_live. Opening the device only makes the device ready for use, it doesn't start packet capturing.
+ * For packet capturing the user should call startCapture(). This implies that calling this method is a must before calling startCapture()
+ * (otherwise startCapture() will fail with a "device not open" error). The device is opened in promiscuous mode
+ * @return True if the device was opened successfully, false otherwise. When opening the device fails an error will be printed to log
+ * as well
+ */
+ bool open();
+
+ void close();
+
+ virtual void getStatistics(pcap_stat& stats);
+
+ /**
+ * Same as open(), but enables to open the device in normal or promiscuous mode
+ * @param[in] mode Normal or promiscuous mode
+ * @return Same as open()
+ */
+ bool open(DeviceMode mode);
+ protected:
+ pcap_t* doOpen(DeviceMode mode);
+ };
+
+} // namespace pcpp
+
+#endif
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PcapLiveDeviceList.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PcapLiveDeviceList.h b/thirdparty/pcap++/Pcap++/header/PcapLiveDeviceList.h
new file mode 100644
index 0000000..48bbf54
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PcapLiveDeviceList.h
@@ -0,0 +1,101 @@
+#ifndef PCAPPP_LIVE_DEVICE_LIST
+#define PCAPPP_LIVE_DEVICE_LIST
+
+#include <IpAddress.h>
+#include <PcapLiveDevice.h>
+#include <WinPcapLiveDevice.h>
+#include <vector>
+
+
+/// @file
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ /**
+ * @class PcapLiveDeviceList
+ * A singleton class that creates, stores and provides access to all PcapLiveDevice (on Linux) or WinPcapLiveDevice (on Windows) instances. All live
+ * devices are initialized on startup and wrap the network interfaces installed on the machine. This class enables access to them through
+ * their IP addresses or get a vector of all of them so the user can search them in some other way
+ */
+ class PcapLiveDeviceList
+ {
+ private:
+ std::vector<PcapLiveDevice*> m_LiveDeviceList;
+
+ std::vector<IPv4Address> m_DnsServers;
+
+ // private c'tor
+ PcapLiveDeviceList();
+ // private copy c'tor
+ PcapLiveDeviceList( const PcapLiveDeviceList& other );
+ PcapLiveDeviceList& operator=(const PcapLiveDeviceList& other);
+ // private d'tor
+ ~PcapLiveDeviceList();
+
+ void setDnsServers();
+ public:
+ /**
+ * The access method to the singleton
+ * @return The singleton instance of this class
+ */
+ static inline PcapLiveDeviceList& getInstance()
+ {
+ static PcapLiveDeviceList instance;
+ return instance;
+ }
+
+ /**
+ * @return A vector containing pointers to all live devices currently installed on the machine
+ */
+ inline const std::vector<PcapLiveDevice*>& getPcapLiveDevicesList() { return m_LiveDeviceList; }
+
+ /**
+ * Get a pointer to the live device by its IP address. IP address can be both IPv4 or IPv6
+ * @param[in] ipAddr The IP address defined for the device
+ * @return A pointer to the live device if this IP address exists. NULL otherwise
+ */
+ PcapLiveDevice* getPcapLiveDeviceByIp(IPAddress* ipAddr);
+
+ /**
+ * Get a pointer to the live device by its IPv4 address
+ * @param[in] ipAddr The IPv4 address defined for the device
+ * @return A pointer to the live device if this IPv4 address exists. NULL otherwise
+ */
+ PcapLiveDevice* getPcapLiveDeviceByIp(IPv4Address ipAddr);
+
+ /**
+ * Get a pointer to the live device by its IPv6 address
+ * @param[in] ip6Addr The IPv6 address defined for the device
+ * @return A pointer to the live device if this IPv6 address exists. NULL otherwise
+ */
+ PcapLiveDevice* getPcapLiveDeviceByIp(IPv6Address ip6Addr);
+
+ /**
+ * Get a pointer to the live device by its IP address represented as string. IP address can be both IPv4 or IPv6
+ * @param[in] ipAddrAsString The IP address defined for the device as string
+ * @return A pointer to the live device if this IP address is valid and exists. NULL otherwise
+ */
+ PcapLiveDevice* getPcapLiveDeviceByIp(const char* ipAddrAsString);
+
+ /**
+ * Get a pointer to the live device by its name
+ * @param[in] name The name of the interface (e.g eth0)
+ * @return A pointer to the live device if this name exists. NULL otherwise
+ */
+ PcapLiveDevice* getPcapLiveDeviceByName(const std::string& name);
+
+ /**
+ * @return A list of all DNS servers defined for this machine. If this list is empty it means no DNS servers were defined or they
+ * couldn't be extracted from some reason
+ */
+ std::vector<IPv4Address>& getDnsServers();
+ };
+
+} // namespace pcpp
+
+#endif
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PcapRemoteDevice.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PcapRemoteDevice.h b/thirdparty/pcap++/Pcap++/header/PcapRemoteDevice.h
new file mode 100644
index 0000000..c013663
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PcapRemoteDevice.h
@@ -0,0 +1,147 @@
+#ifndef PCAPPP_PCAP_REMOTE_DEVICE
+#define PCAPPP_PCAP_REMOTE_DEVICE
+
+#if defined(WIN32) || defined(WINx64)
+
+#include <vector>
+#include <PcapLiveDevice.h>
+
+
+/// @file
+
+struct pcap_rmtauth;
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ /**
+ * @struct PcapRemoteAuthentication
+ * The remote daemon (rpcapd) can be configured to require authentication before allowing a client to connect. This is done for
+ * security reasons of course. This struct wraps the WinPcap authentication object (pcap_rmtauth) and can (but not must) be given to
+ * PcapRemoteDeviceList when initiating a connection to the remote daemon
+ */
+ struct PcapRemoteAuthentication
+ {
+ public:
+ /**
+ * A constructor that sets username and password
+ * @param[in] username The username for authentication with the remote daemon
+ * @param[in] password The password for authentication with the remote daemon
+ */
+ PcapRemoteAuthentication(const std::string username, const std::string password) { userName = username; this->password = password; }
+
+ /**
+ * A copy c'tor for this object
+ * @param[in] other The object to copy from
+ */
+ PcapRemoteAuthentication(const PcapRemoteAuthentication& other) { userName = other.userName; password = other.password; }
+
+ /**
+ * The username for authentication
+ */
+ std::string userName;
+
+ /**
+ * The password for authentication
+ */
+ std::string password;
+
+ /**
+ * A conversion method from PcapRemoteAuthentication to pcap_rmtauth. Note: the char* pointers of the returned pcap_rmtauth points
+ * to the same places in memory as PcapRemoteAuthentication::userName and PcapRemoteAuthentication::password so the user should avoid
+ * freeing this memory
+ * @return A pcap_rmtauth that is converted from this class
+ */
+ pcap_rmtauth getPcapRmAuth();
+ };
+
+ /**
+ * @class PcapRemoteDevice
+ * A class that provides a C++ wrapper for WinPcap Remote Capture feature. This feature allows to interact to a remote machine and capture
+ * packets that are being transmitted on the remote network interfaces. This requires a remote daemon (called rpcapd) which performs the
+ * capture and sends data back and the local client (represented by PcapRemoteDevice) that sends the appropriate commands and receives the
+ * captured data. You can read more about this feature in WinPcap Remote Capture manual: https://www.winpcap.org/docs/docs_412/html/group__remote.html<BR>
+ * Since this feature is supported in WinPcap only and not in libpcap, PcapRemoteDevice can only be used in Windows only.<BR>
+ * This class provides a wrapper for the local client, meaning it assumes the daemon (rpcapd) is already running on the remote machine and it
+ * tries to connect to it and start receiving/sending packets from/to it. This class assumes rpcapd is in passive mode, meaning
+ * PcapRemoteDevice connects to the remote daemon, sends the appropriate commands to it, and starts capturing packets, rather than letting the
+ * daemon connect to the client by itself. Using PcapRemoteDevice is very similar to using the other live devices (PcapLiveDevice or
+ * WinPcapLiveDevice), meaning the API's are the same and the same logic is used (for example: capturing is done on a different thread,
+ * sending packets are done on the same thread, etc.). For the full API and explanations, please refer to PcapLiveDevice. The reason for the
+ * similar API is that WinPcap's API is very similar between Remote Capture and local network interface capture. The things that are different
+ * are some are some implementation details, mainly in making the connection to the remote daemon, and the way the user can get the instance
+ * of PcapRemoteDevice. For more details on that please refer to PcapRemoteDeviceList
+ */
+ class PcapRemoteDevice : public PcapLiveDevice
+ {
+ friend class PcapRemoteDeviceList;
+ private:
+ IPAddress* m_RemoteMachineIpAddress;
+ uint16_t m_RemoteMachinePort;
+ PcapRemoteAuthentication* m_RemoteAuthentication;
+
+ // c'tor is private, as only PcapRemoteDeviceList should create instances of it, and it'll create only one for every remote interface
+ PcapRemoteDevice(pcap_if_t* iface, PcapRemoteAuthentication* remoteAuthentication, IPAddress* remoteMachineIP, uint16_t remoteMachinePort);
+
+ // private copy c'tor
+ PcapRemoteDevice( const PcapRemoteDevice& other );
+ // private assignment operator
+ PcapRemoteDevice& operator=(const PcapRemoteDevice& other);
+
+ static void* remoteDeviceCaptureThreadMain(void *ptr);
+
+ //overridden methods
+ ThreadStart getCaptureThreadStart();
+
+ public:
+ virtual ~PcapRemoteDevice() {}
+
+ /**
+ * @return The IP address of the remote machine where packets are transmitted from the remote machine to the client machine
+ */
+ IPAddress* getRemoteMachineIpAddress() { return m_RemoteMachineIpAddress; }
+
+ /**
+ * @return The port of the remote machine where packets are transmitted from the remote machine to the client machine
+ */
+ uint16_t getRemoteMachinePort() { return m_RemoteMachinePort; }
+
+ //overridden methods
+
+ virtual LiveDeviceType getDeviceType() { return RemoteDevice; }
+
+ /**
+ * MTU isn't supported for remote devices
+ * @return 0
+ */
+ virtual uint16_t getMtu();
+
+ /**
+ * MAC address isn't supported for remote devices
+ * @return MacAddress#Zero
+ */
+ virtual MacAddress getMacAddress();
+
+ /**
+ * Open the device using pcap_open. Opening the device makes the connection to the remote daemon (including authentication if needed
+ * and provided). If this methods succeeds it means the connection to the remote daemon succeeded and the device is ready for use.
+ * As in PcapLiveDevice, packet capturing won't start yet. For packet capturing the user should call startCapture(). This implies
+ * that calling this method is a must before calling startCapture() (otherwise startCapture() will fail with a "device not open" error).
+ * The remote deamon is asked to capture packets in promiscuous mode
+ * @return True if the device was opened successfully, false otherwise. When opening the device fails an error will be printed to log
+ * as well, including the WinPcap error if exists
+ */
+ virtual bool open();
+
+ void getStatistics(pcap_stat& stats);
+ };
+
+} // namespace pcpp
+
+#endif // WIN32 || WINx64
+
+#endif /* PCAPPP_PCAP_REMOTE_DEVICE */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PcapRemoteDeviceList.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PcapRemoteDeviceList.h b/thirdparty/pcap++/Pcap++/header/PcapRemoteDeviceList.h
new file mode 100644
index 0000000..a4ac064
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PcapRemoteDeviceList.h
@@ -0,0 +1,152 @@
+#ifndef PCAPP_PCAP_REMOTE_DEVICE_LIST
+#define PCAPP_PCAP_REMOTE_DEVICE_LIST
+
+#if defined(WIN32) || defined(WINx64)
+
+#include <IpAddress.h>
+#include <PcapRemoteDevice.h>
+
+/// @file
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ /**
+ * @class PcapRemoteDeviceList
+ * A class that creates, stores and provides access to all instances of PcapRemoteDevice for a certain remote machine. To get an instance
+ * of this class use one of the static methods of getRemoteDeviceList(). These methods creates a PcapRemoteDeviceList instance for the
+ * certain remote machine which holds a list of PcapRemoteDevice instances, one for each remote network interface. Note there is
+ * not a public constructor for this class, so the only way to get an instance of it is through getRemoteDeviceList(). After getting
+ * this object, this class provides ways to access the PcapRemoteDevice instances: either through IP address of the remote network interface or
+ * by iterating the PcapRemoteDevice instances (through the PcapRemoteDeviceList#RemoteDeviceListIterator iterator)<BR>
+ * Since Remote Capture is supported in WinPcap only, this class is available in Windows only
+ */
+ class PcapRemoteDeviceList
+ {
+ private:
+ std::vector<PcapRemoteDevice*> m_RemoteDeviceList;
+ IPAddress* m_RemoteMachineIpAddress;
+ uint16_t m_RemoteMachinePort;
+ PcapRemoteAuthentication* m_RemoteAuthentication;
+
+ // private c'tor. User should create the list via static methods PcapRemoteDeviceList::getRemoteDeviceList()
+ PcapRemoteDeviceList() : m_RemoteMachineIpAddress(NULL), m_RemoteMachinePort(0), m_RemoteAuthentication(NULL) {};
+ // private copy c'tor
+ PcapRemoteDeviceList(const PcapRemoteDeviceList& other);
+ PcapRemoteDeviceList& operator=(const PcapRemoteDeviceList& other);
+
+ void setRemoteMachineIpAddress(const IPAddress* ipAddress);
+ void setRemoteMachinePort(uint16_t port);
+ void setRemoteAuthentication(const PcapRemoteAuthentication* remoteAuth);
+
+ public:
+ /**
+ * Iterator object that can be used for iterating all PcapRemoteDevice in list
+ */
+ typedef typename std::vector<PcapRemoteDevice*>::iterator RemoteDeviceListIterator;
+
+ /**
+ * Const iterator object that can be used for iterating all PcapRemoteDevice in a constant list
+ */
+ typedef typename std::vector<PcapRemoteDevice*>::const_iterator ConstRemoteDeviceListIterator;
+
+ ~PcapRemoteDeviceList();
+
+ /**
+ * A static method for creating a PcapRemoteDeviceList instance for a certain remote machine. This methods creates the instance, and also
+ * creates a list of PcapRemoteDevice instances stored in it, one for each remote network interface. Notice this method allocates
+ * the PcapRemoteDeviceList instance and returns a pointer to it. It's the user responsibility to free it when done using it<BR>
+ * This method overload is for remote daemons which don't require authentication for accessing them. For daemons which do require authentication
+ * use the other method overload
+ * @param[in] ipAddress The IP address of the remote machine through which clients can connect to the rpcapd daemon
+ * @param[in] port The port of the remote machine through which clients can connect to the rpcapd daemon
+ * @return A pointer to the newly created PcapRemoteDeviceList, or NULL if (an appropriate error will be printed to log in each case):
+ * - IP address provided is NULL or not valid
+ * - WinPcap encountered an error in creating the remote connection string
+ * - WinPcap encountered an error connecting to the rpcapd daemon on the remote machine or retrieving devices on the remote machine
+ */
+ static PcapRemoteDeviceList* getRemoteDeviceList(IPAddress* ipAddress, uint16_t port);
+
+ /**
+ * An overload of the previous getRemoteDeviceList() method but with authentication support. This method is suitable for connecting to
+ * remote daemons which require authentication for accessing them
+ * @param[in] ipAddress The IP address of the remote machine through which clients can connect to the rpcapd daemon
+ * @param[in] port The port of the remote machine through which clients can connect to the rpcapd daemon
+ * @param[in] remoteAuth A pointer to the authentication object which contains the username and password for connecting to the remote
+ * daemon
+ * @return A pointer to the newly created PcapRemoteDeviceList, or NULL if (an appropriate error will be printed to log in each case):
+ * - IP address provided is NULL or not valid
+ * - WinPcap encountered an error in creating the remote connection string
+ * - WinPcap encountered an error connecting to the rpcapd daemon on the remote machine or retrieving devices on the remote machine
+ */
+ static PcapRemoteDeviceList* getRemoteDeviceList(IPAddress* ipAddress, uint16_t port, PcapRemoteAuthentication* remoteAuth);
+
+ /**
+ * @return The IP address of the remote machine
+ */
+ IPAddress* getRemoteMachineIpAddress() { return m_RemoteMachineIpAddress; }
+
+ /**
+ * @return The port of the remote machine where packets are transmitted from the remote machine to the client machine
+ */
+ uint16_t getRemoteMachinePort() { return m_RemoteMachinePort; }
+
+ /**
+ * Search a PcapRemoteDevice in the list by its IPv4 address
+ * @param[in] ip4Addr The IPv4 address
+ * @return The PcapRemoteDevice if found, NULL otherwise
+ */
+ PcapRemoteDevice* getRemoteDeviceByIP(IPv4Address ip4Addr);
+
+ /**
+ * Search a PcapRemoteDevice in the list by its IPv6 address
+ * @param[in] ip6Addr The IPv6 address
+ * @return The PcapRemoteDevice if found, NULL otherwise
+ */
+ PcapRemoteDevice* getRemoteDeviceByIP(IPv6Address ip6Addr);
+
+ /**
+ * Search a PcapRemoteDevice in the list by its IP address (IPv4 or IPv6)
+ * @param[in] ipAddr The IP address
+ * @return The PcapRemoteDevice if found, NULL otherwise
+ */
+ PcapRemoteDevice* getRemoteDeviceByIP(IPAddress* ipAddr);
+
+ /**
+ * Search a PcapRemoteDevice in the list by its IP address
+ * @param[in] ipAddrAsString The IP address in string format
+ * @return The PcapRemoteDevice if found, NULL otherwise
+ */
+ PcapRemoteDevice* getRemoteDeviceByIP(const char* ipAddrAsString);
+
+ /**
+ * @return An iterator object pointing to the first PcapRemoteDevice in list
+ */
+ inline RemoteDeviceListIterator begin() { return m_RemoteDeviceList.begin(); }
+
+ /**
+ * @return A const iterator object pointing to the first PcapRemoteDevice in list
+ */
+ inline ConstRemoteDeviceListIterator begin() const { return m_RemoteDeviceList.begin(); }
+
+ /**
+ * @return An iterator object pointing to the last PcapRemoteDevice in list
+ */
+ inline RemoteDeviceListIterator end() { return m_RemoteDeviceList.end(); }
+
+ /**
+ * @return A const iterator object pointing to the last PcapRemoteDevice in list
+ */
+ inline ConstRemoteDeviceListIterator end() const { return m_RemoteDeviceList.end(); }
+
+ };
+
+} // namespace pcpp
+
+#endif // WIN32 || WINx64
+
+#endif /* PCAPP_PCAP_REMOTE_DEVICE_LIST */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PfRingDevice.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PfRingDevice.h b/thirdparty/pcap++/Pcap++/header/PfRingDevice.h
new file mode 100644
index 0000000..3ca0d08
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PfRingDevice.h
@@ -0,0 +1,345 @@
+#ifndef PCAPPP_PF_RING_DEVICE
+#define PCAPPP_PF_RING_DEVICE
+
+#include <PcapDevice.h>
+#include <PcapFilter.h>
+#include <MacAddress.h>
+#include <SystemUtils.h>
+#include <RawPacket.h>
+#include <Packet.h>
+#include <pthread.h>
+
+/// @file
+
+// forward declaration of PF_RING structs
+struct __pfring;
+typedef struct __pfring pfring;
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ class PfRingDevice;
+
+ typedef void (*OnPfRingPacketsArriveCallback)(RawPacket* packets, uint32_t numOfPackets, uint8_t threadId, PfRingDevice* device, void* userCookie);
+
+
+ /**
+ * @class PfRingDevice
+ * A class representing a PF_RING port
+ */
+ class PfRingDevice : public IPcapDevice
+ {
+ friend class PfRingDeviceList;
+ private:
+
+ struct CoreConfiguration
+ {
+ pthread_t RxThread;
+ pfring* Channel;
+ bool IsInUse;
+ bool IsAffinitySet;
+
+ CoreConfiguration();
+ void clear();
+ };
+
+ pfring** m_PfRingDescriptors;
+ uint8_t m_NumOfOpenedRxChannels;
+ char m_DeviceName[30];
+ int m_InterfaceIndex;
+ MacAddress m_MacAddress;
+ int m_DeviceMTU;
+ CoreConfiguration m_CoreConfiguration[MAX_NUM_OF_CORES];
+ bool m_StopThread;
+ OnPfRingPacketsArriveCallback m_OnPacketsArriveCallback;
+ void* m_OnPacketsArriveUserCookie;
+ bool m_ReentrantMode;
+ bool m_HwClockEnabled;
+ bool m_IsFilterCurrentlySet;
+
+ PfRingDevice(const char* deviceName);
+
+ bool initCoreConfigurationByCoreMask(CoreMask coreMask);
+ static void* captureThreadMain(void *ptr);
+
+ int openSingleRxChannel(const char* deviceName, pfring** ring);
+
+ inline bool getIsHwClockEnable() { setPfRingDeviceAttributes(); return m_HwClockEnabled; }
+ bool setPfRingDeviceClock(pfring* ring);
+
+ void clearCoreConfiguration();
+ int getCoresInUseCount();
+
+ void setPfRingDeviceAttributes();
+
+ bool sendData(const uint8_t* packetData, int packetDataLength, bool flushTxQueues);
+ public:
+
+ /**
+ * An enum representing the type of packet distribution between different RX channels
+ */
+ enum ChannelDistribution
+ {
+ /**
+ * Packets are distributed between channels in a round-robin manner
+ */
+ RoundRobin,
+ /**
+ * Packets are distributed between channels per flow (each flow goes for different channel)
+ */
+ PerFlow
+ };
+
+ /**
+ * A destructor for PfRingDevice class
+ */
+ ~PfRingDevice();
+
+ /**
+ * Get the MAC address of the current device
+ * @return The MAC address of the current device
+ */
+ MacAddress getMacAddress() { setPfRingDeviceAttributes(); return m_MacAddress; }
+
+ /**
+ * Get PF_RING interface index of the current device
+ * @return PF_RING interface index of the current device
+ */
+ int getInterfaceIndex() { setPfRingDeviceAttributes(); return m_InterfaceIndex; }
+
+ /**
+ * Get MTU of the current device
+ * @return Upon success return the device MTU, 0 otherwise
+ */
+ int getMtu() { setPfRingDeviceAttributes(); return m_DeviceMTU; }
+
+ /**
+ * Return true if device supports hardware timestamping. If it does, this feature will be automatically set
+ * for this device. You can read more about this in PF_RING documentation
+ * @return True if device supports hardware timestamping, false otherwise
+ */
+ bool isHwClockEnabledForDevice() { setPfRingDeviceAttributes(); return m_HwClockEnabled; }
+
+ /**
+ * Gets the interface name (e.g eth0, eth1, etc.)
+ * @return The interface name
+ */
+ inline std::string getDeviceName() { return std::string(m_DeviceName); }
+
+
+ /**
+ * Start single-threaded capturing with callback. Works with open() or openSingleRxChannel().
+ * @param[in] onPacketsArrive A callback to call whenever a packet arrives
+ * @param[in] onPacketsArriveUserCookie A cookie that will be delivered to onPacketsArrive callback on every packet
+ * @return True if this action succeeds, false otherwise
+ */
+ bool startCaptureSingleThread(OnPfRingPacketsArriveCallback onPacketsArrive, void* onPacketsArriveUserCookie);
+
+ /**
+ * Start multi-threaded (multi-core) capturing with callback. Works with openMultiRxChannels().
+ * This method will return an error if the number of opened channels is different than the number of threads/cores
+ * requested
+ * @param[in] onPacketsArrive A callback to call whenever a packet arrives
+ * @param[in] onPacketsArriveUserCookie A cookie that will be delivered to onPacketsArrive callback on every packet
+ * @param[in] coreMask The cores to be used as mask. For example:
+ * @return True if this action succeeds, false otherwise
+ */
+ bool startCaptureMultiThread(OnPfRingPacketsArriveCallback onPacketsArrive, void* onPacketsArriveUserCookie, CoreMask coreMask);
+
+ /**
+ * Stops capturing packets (works will all type of startCapture*)
+ */
+ void stopCapture();
+
+
+ /**
+ * Opens a single RX channel (=RX queue) on this interface. All packets will be received on a single thread
+ * without core affinity. If the channel ID requested doesn't exist on this interface, the method will fail
+ * (return false)
+ * @param[in] channelId The requested channel ID
+ * @return True if this action succeeds, false otherwise
+ */
+ bool openSingleRxChannel(uint8_t channelId);
+
+ /**
+ * Opens a set of RX channels (=RX queues) on this interface, identified by their IDs. All packets will be received on a single thread
+ * without core affinity. If one of the channel IDs requested doesn't exist on this interface, the method will fail
+ * (return false)
+ * @param[in] channelIds An array of channel IDs
+ * @param[in] numOfChannelIds The channel ID array size
+ * @return True if this action succeeds, false otherwise
+ */
+ bool openMultiRxChannels(const uint8_t* channelIds, int numOfChannelIds);
+
+ /**
+ * Opens numOfRxChannelsToOpen RX channels. If numOfRxChannelsToOpen is larger than available RX queues for this
+ * interface than a number of RX channels will be opened on each RX queue. For example: if the user asks for 10
+ * RX channels but the interface has only 4 RX queues, then 3 RX channels will be opened for RX-queue0 and RX-queue2,
+ * and 2 RX channels will be opened for RX-queue2 and RX-queue3.
+ * Packets will be distributed between different RX queues on per-flow manner, but within multiple RX channels in
+ * the same RX queue packet will be distributed according to distribution requested by "dist"
+ * @param[in] numOfRxChannelsToOpen Number of RX channels to open
+ * @param[in] dist Distribution method
+ * @return True if this action succeeds, false otherwise
+ */
+ bool openMultiRxChannels(uint8_t numOfRxChannelsToOpen, ChannelDistribution dist);
+
+ /**
+ * Gets the number of RX channels currently open. RX channels aren't necessary interface's RX queues
+ * because in some cases the user asks to open several channels on the same queue. For example: if the user uses
+ * openMultiRxChannels() and asks to open 8 channels but interface has only 4 RX queues, 2 channels will be
+ * opened for each RX queue
+ * @return Number of opened RX channels
+ */
+ inline uint8_t getNumOfOpenedRxChannels() { return m_NumOfOpenedRxChannels; }
+
+ /**
+ * Gets the total number of RX channels (RX queues) this interface has
+ * @return The number of RX channels (queues) for this interface
+ */
+ uint8_t getTotalNumOfRxChannels();
+
+ /**
+ * Gets the core used in the current thread context
+ * @return The system core used in the current thread context
+ */
+ SystemCore getCurrentCoreId();
+
+ /**
+ * Get the statistics of a specific thread/core (=RX channel)
+ * @param[in] core The requested core
+ * @param[out] stats A reference for the stats object where the stats are written. Current values will be overriden
+ */
+ void getThreadStatistics(SystemCore core, pcap_stat& stats);
+
+ /**
+ * Get the statistics of the current thread/core (=RX channel)
+ * @param[out] stats A reference for the stats object where the stats are written. Current values will be overriden
+ */
+ void getCurrentThreadStatistics(pcap_stat& stats);
+
+
+
+ // implement abstract methods
+
+
+ /**
+ * Opens the entire device (including all RX channels/queues on this interface). All packets will be received
+ * on a single thread without core affinity
+ * @return True if this action succeeds, false otherwise
+ */
+ bool open();
+
+ /**
+ * Closes all RX channels currently opened in device
+ */
+ void close();
+
+ /**
+ * Get the statistics for the entire device. If more than 1 RX channel is opened, this method aggregates the stats
+ * of all channels
+ * @param[out] stats A reference for the stats object where the stats are written. Current values will be overriden
+ */
+ void getStatistics(pcap_stat& stats);
+
+
+ /**
+ * Sets a filter to the device
+ * @param[in] filter The filter to set
+ */
+ bool setFilter(GeneralFilter& filter);
+
+ /**
+ * Sets a BPF filter to the device
+ * @param[in] filterAsString The BPF filter in string format
+ */
+ bool setFilter(std::string filterAsString);
+
+ /**
+ * Remove a filter if currently set
+ * @return True if filter was removed successfully or if no filter was set, false otherwise
+ */
+ bool removeFilter();
+
+ /**
+ * Return true if filter is currently set
+ * @return True if filter is currently set, false otherwise
+ */
+ bool isFilterCurrentlySet();
+
+
+ /**
+ * Send a raw packet. This packet must be fully specified (the MAC address up)
+ * and it will be transmitted as-is without any further manipulation.
+ * This method doesn't change or manipulate the data in any way (hence the "const" declaration).
+ * Note this method flushes the TX queues after the data is sent. So if you want to send several packets
+ * In the burst please use sendPackets()
+ * @param[in] rawPacket The raw packet to send
+ * @return True if raw packet was sent completely, false otherwise
+ */
+ bool sendPacket(const RawPacket& rawPacket);
+
+ /**
+ * Send raw data. This data must be a valid and fully specified packet (the MAC address up);
+ * it will be transmitted as-is without any further manipulation.
+ * This method doesn't change or manipulate the data in any way (hence the "const" declaration).
+ * Note this method flushes the TX queues after the data is sent. So if you want to send several packets
+ * in the burst please use sendPackets()
+ * @param[in] packetData The raw data to send
+ * @param[in] packetDataLength the length of packetData
+ * @return True if raw packet was sent completely, false otherwise
+ *
+ */
+ bool sendPacket(const uint8_t* packetData, int packetDataLength);
+
+ /**
+ * Send a packet. This packet must be fully specified (the MAC address up)
+ * and it will be transmitted as-is without any further manipulation.
+ * This method doesn't change or manipulate the data in any way (hence the "const" declaration).
+ * Note this method flushes the TX queues after the data is sent. So if you want to send several packets
+ * In the burst please use sendPackets()
+ * @param[in] packet The packet to send
+ * @return True if raw packet was sent completely, false otherwise
+ */
+ bool sendPacket(const Packet& packet);
+
+ /**
+ * Send raw packets. All raw packets must be fully specified (the MAC address up)
+ * and it will be transmitted as-is without any further manipulation.
+ * This method doesn't change or manipulate the raw packets data in any way (hence the "const" declaration).
+ * This method flushes the TX queues only when the last packet is sent
+ * @param[in] rawPacketsArr The RawPacket array
+ * @param[in] arrLength RawPacket array length
+ * @return Number of packets that were sent completely
+ */
+ int sendPackets(const RawPacket* rawPacketsArr, int arrLength);
+
+ /**
+ * Send packets. All packets must be fully specified (the MAC address up)
+ * and it will be transmitted as-is without any further manipulation.
+ * This method doesn't change or manipulate the packets data in any way (hence the "const" declaration).
+ * This method flushes the TX queues only when the last packet is sent
+ * @param[in] packetsArr An array of pointers to Packet objects
+ * @param[in] arrLength Packet pointers array length
+ * @return Number of packets that were sent completely
+ */
+ int sendPackets(const Packet** packetsArr, int arrLength);
+
+ /**
+ * Send all raw packets pointed by the RawPacketVector. All packets must be fully specified (the MAC address up)
+ * and it will be transmitted as-is without any further manipulation.
+ * This method doesn't change or manipulate the packets data in any way (hence the "const" declaration).
+ * This method flushes the TX queues only when the last packet is sent
+ * @param[in] rawPackets The raw packet vector
+ * @return Number of raw packets that were sent completely
+ */
+ int sendPackets(const RawPacketVector& rawPackets);
+ };
+
+} // namespace pcpp
+
+#endif /* PCAPPP_PF_RING_DEVICE */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/PfRingDeviceList.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/PfRingDeviceList.h b/thirdparty/pcap++/Pcap++/header/PfRingDeviceList.h
new file mode 100644
index 0000000..06544b0
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/PfRingDeviceList.h
@@ -0,0 +1,68 @@
+#ifndef PCAPPP_PF_RING_DEVICE_LIST
+#define PCAPPP_PF_RING_DEVICE_LIST
+
+#include <PfRingDevice.h>
+
+/// @file
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ /**
+ * @class PfRingDeviceList
+ * A singleton class that holds all available PF_RING devices. Through this class the user can iterate all PF_RING devices or find a specific
+ * device by name
+ */
+ class PfRingDeviceList
+ {
+ private:
+ std::vector<PfRingDevice*> m_PfRingDeviceList;
+ std::string m_PfRingVersion;
+
+ PfRingDeviceList();
+ // private copy c'tor
+ PfRingDeviceList(const PfRingDeviceList& other);
+ PfRingDeviceList& operator=(const PfRingDeviceList& other);
+ // private d'tor
+ ~PfRingDeviceList();
+
+ void calcPfRingVersion(void* ring);
+ public:
+ /**
+ * A static method that returns the singleton object for PfRingDeviceList
+ * @return PfRingDeviceList singleton
+ */
+ static inline PfRingDeviceList& getInstance()
+ {
+ static PfRingDeviceList instance;
+ return instance;
+ }
+
+ /**
+ * Return a list of all available PF_RING devices
+ * @return a list of all available PF_RING devices
+ */
+ inline const std::vector<PfRingDevice*>& getPfRingDevicesList() { return m_PfRingDeviceList; }
+
+ /**
+ * Get a PF_RING device by name. The name is the Linux interface name which appears in ifconfig
+ * (e.g eth0, eth1, etc.)
+ * @return A pointer to the PF_RING device
+ */
+ PfRingDevice* getPfRingDeviceByName(const std::string devName);
+
+
+ /**
+ * Get installed PF_RING version
+ * @return A string representing PF_RING version
+ */
+ inline std::string getPfRingVersion() { return m_PfRingVersion; }
+ };
+
+} // namespace pcpp
+
+#endif /* PCAPPP_PF_RING_DEVICE_LIST */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/Pcap++/header/WinPcapLiveDevice.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/Pcap++/header/WinPcapLiveDevice.h b/thirdparty/pcap++/Pcap++/header/WinPcapLiveDevice.h
new file mode 100644
index 0000000..efb4b84
--- /dev/null
+++ b/thirdparty/pcap++/Pcap++/header/WinPcapLiveDevice.h
@@ -0,0 +1,64 @@
+#ifndef PCAPP_WINPCAP_LIVE_DEVICE
+#define PCAPP_WINPCAP_LIVE_DEVICE
+
+#if defined(WIN32) || defined(WINx64)
+
+/// @file
+
+#include <PcapLiveDevice.h>
+
+/**
+* \namespace pcpp
+* \brief The main namespace for the PcapPlusPlus lib
+*/
+namespace pcpp
+{
+
+ /**
+ * @class WinPcapLiveDevice
+ * A class that wraps a Windows network interface (each of the interfaces listed in ipconfig).
+ * This class is almost similar in its capabilities to PcapLiveDevice (its parent class) with some small changes that mainly result from
+ * differences between libpcap and WinPcap. Please see the reference for PcapLiveDevice for more details
+ */
+ class WinPcapLiveDevice : public PcapLiveDevice
+ {
+ friend class PcapLiveDeviceList;
+ protected:
+ int m_MinAmountOfDataToCopyFromKernelToApplication;
+
+ // c'tor is not public, there should be only one for every interface (created by PcapLiveDeviceList)
+ WinPcapLiveDevice(pcap_if_t* iface, bool calculateMTU, bool calculateMacAddress, bool calculateDefaultGateway);
+ // copy c'tor is not public
+ WinPcapLiveDevice( const WinPcapLiveDevice& other );
+ WinPcapLiveDevice& operator=(const WinPcapLiveDevice& other);
+
+ public:
+ virtual LiveDeviceType getDeviceType() { return WinPcapDevice; }
+
+ bool startCapture(OnPacketArrivesCallback onPacketArrives, void* onPacketArrivesUserCookie, int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void* onStatsUpdateUsrrCookie);
+ bool startCapture(int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void* onStatsUpdateUserCookie);
+ bool startCapture(RawPacketVector& capturedPacketsVector) { return PcapLiveDevice::startCapture(capturedPacketsVector); }
+
+ virtual int sendPackets(RawPacket* rawPacketsArr, int arrLength);
+
+ /**
+ * WinPcap has an ability (that doesn't exist in libpcap) to change the minimum amount of data in the kernel buffer that causes a read
+ * from the application to return (unless the timeout expires). Please see documentation for pcap_setmintocopy for more info. This method
+ * enables the user to change this size. Note the device must be open for this method to work
+ * @param[in] size The size to set in bytes
+ * @return True if set succeeded, false if the device is closed or if pcap_setmintocopy failed
+ */
+ bool setMinAmountOfDataToCopyFromKernelToApplication(int size);
+
+ /**
+ * @return The current amount of data in the kernel buffer that causes a read from the application to return (see also
+ * setMinAmountOfDataToCopyFromKernelToApplication())
+ */
+ int getMinAmountOfDataToCopyFromKernelToApplication() { return m_MinAmountOfDataToCopyFromKernelToApplication; }
+ };
+
+} // namespace pcpp
+
+#endif // WIN32 || WINx64
+
+#endif /* PCAPP_WINPCAP_LIVE_DEVICE */