PcapPlusPlus
21.05
|
#include <PcapFilter.h>
Public Member Functions | |
IPFilter (const std::string &ipAddress, Direction dir) | |
IPFilter (const std::string &ipAddress, Direction dir, const std::string &ipv4Mask) | |
IPFilter (const std::string &ipAddress, Direction dir, int len) | |
void | parseToString (std::string &result) |
void | setAddr (const std::string &ipAddress) |
void | setMask (const std::string &ipv4Mask) |
void | setLen (int len) |
Public Member Functions inherited from pcpp::IFilterWithDirection | |
void | setDirection (Direction dir) |
Public Member Functions inherited from pcpp::GeneralFilter | |
bool | matchPacketWithFilter (RawPacket *rawPacket) |
virtual | ~GeneralFilter () |
A class for representing IPv4 address filter, equivalent to "net src x.x.x.x" or "net dst x.x.x.x"
For deeper understanding of the filter concept please refer to PcapFilter.h
|
inline |
The basic constructor that creates the filter from an IPv4 address and direction (source or destination)
[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 |
[in] | dir | The address direction to filter (source or destination) |
|
inline |
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"
[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 |
[in] | dir | The address direction to filter (source or destination) |
[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 |
|
inline |
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"
[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 |
[in] | dir | The address direction to filter (source or destination) |
[in] | len | The subnet to use (e.g "/24") |
|
virtual |
A method that parses the class instance into BPF string format
[out] | result | An empty string that the parsing will be written into. If the string isn't empty, its content will be overridden |
Implements pcpp::GeneralFilter.
|
inline |
Set the IPv4 address
[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 |
|
inline |
Set the subnet
[in] | len | The subnet to use (e.g "/24") |
|
inline |
Set the IPv4 mask
[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 |