80 std::string m_FilterStr;
82 bpf_program* m_Program;
128 bool matchPacketWithFilter(
const uint8_t* packetData, uint32_t packetDataLength, timespec packetTimestamp, uint16_t linkType);
146 virtual void parseToString(std::string& result) = 0;
170 const std::string m_FilterStr;
173 explicit BPFStringFilter(
const std::string& filterStr) : m_FilterStr(filterStr) {}
182 virtual void parseToString(std::string& result);
202 void parseDirection(std::string& directionAsString);
203 Direction getDir()
const {
return m_Dir; }
223 FilterOperator m_Operator;
225 std::string parseOperator();
226 FilterOperator getOperator()
const {
return m_Operator; }
247 std::string m_Address;
248 std::string m_IPv4Mask;
250 void convertToIPAddressWithMask(std::string& ipAddrmodified, std::string& mask)
const;
251 void convertToIPAddressWithLen(std::string& ipAddrmodified)
const;
270 IPFilter(
const std::string& ipAddress, Direction dir,
const std::string& ipv4Mask) :
IFilterWithDirection(dir), m_Address(ipAddress), m_IPv4Mask(ipv4Mask), m_Len(0) {}
283 void parseToString(std::string& result);
290 void setAddr(
const std::string& ipAddress) { m_Address = ipAddress; }
296 void setMask(
const std::string& ipv4Mask) { m_IPv4Mask = ipv4Mask; m_Len = 0; }
302 void setLen(
int len) { m_IPv4Mask =
""; m_Len = len; }
325 void parseToString(std::string& result);
331 void setIpID(uint16_t ipID) { m_IpID = ipID; }
345 uint16_t m_TotalLength;
354 void parseToString(std::string& result);
374 void portToString(uint16_t portAsInt);
383 void parseToString(std::string& result);
389 void setPort(uint16_t port) { portToString(port); }
414 void parseToString(std::string& result);
448 void parseToString(std::string& result);
468 uint16_t m_EtherType;
476 void parseToString(std::string& result);
498 std::vector<GeneralFilter*> m_FilterList;
510 explicit AndFilter(std::vector<GeneralFilter*>& filters);
522 void setFilters(std::vector<GeneralFilter*>& filters);
524 void parseToString(std::string& result);
540 std::vector<GeneralFilter*> m_FilterList;
552 explicit OrFilter(std::vector<GeneralFilter*>& filters);
560 void parseToString(std::string& result);
581 void parseToString(std::string& result);
611 void parseToString(std::string& result);
640 void parseToString(std::string& result);
668 void parseToString(std::string& result);
718 uint8_t m_TcpFlagsBitMask;
738 void parseToString(std::string& result);
751 uint16_t m_WindowSize;
761 void parseToString(std::string& result);
790 void parseToString(std::string& result);
The main namespace for the PcapPlusPlus lib.
MacAddressFilter(MacAddress address, Direction dir)
Definition: PcapFilter.h:446
Definition: PcapFilter.h:48
TcpFlags
Definition: PcapFilter.h:690
Definition: PcapFilter.h:629
Definition: PcapFilter.h:599
void setMask(const std::string &ipv4Mask)
Definition: PcapFilter.h:296
void setToPort(uint16_t toPort)
Definition: PcapFilter.h:426
void setMacAddress(MacAddress address)
Definition: PcapFilter.h:454
void setVlanID(uint16_t vlanId)
Definition: PcapFilter.h:674
Definition: PcapFilter.h:400
Definition: RawPacket.h:30
Definition: PcapFilter.h:342
AndFilter()
Definition: PcapFilter.h:504
void setAddr(const std::string &ipAddress)
Definition: PcapFilter.h:290
void setEtherType(uint16_t etherType)
Definition: PcapFilter.h:482
MatchOptions
Definition: PcapFilter.h:710
Definition: PcapFilter.h:136
void setFromPort(uint16_t fromPort)
Definition: PcapFilter.h:420
Definition: RawPacket.h:254
IPFilter(const std::string &ipAddress, Direction dir, int len)
Definition: PcapFilter.h:281
Definition: PcapFilter.h:50
TcpFlagsFilter(uint8_t tcpFlagBitMask, MatchOptions matchOption)
Definition: PcapFilter.h:728
void setOperator(FilterOperator op)
Definition: PcapFilter.h:233
virtual ~GeneralFilter()
Definition: PcapFilter.h:160
ArpOpcode
Definition: ArpLayer.h:48
void setProto(ProtocolType proto)
Definition: PcapFilter.h:618
ProtoFilter(ProtocolType proto)
Definition: PcapFilter.h:609
Definition: PcapFilter.h:465
UdpLengthFilter(uint16_t length, FilterOperator op)
Definition: PcapFilter.h:788
Definition: PcapFilter.h:64
void setIpID(uint16_t ipID)
Definition: PcapFilter.h:331
Definition: PcapFilter.h:197
FilterOperator
Definition: PcapFilter.h:57
Definition: PcapFilter.h:436
uint64_t ProtocolType
Definition: ProtocolType.h:18
void setFilter(GeneralFilter *filterToInverse)
Definition: PcapFilter.h:587
Definition: PcapFilter.h:684
VlanFilter(uint16_t vlanId)
Definition: PcapFilter.h:666
NotFilter(GeneralFilter *filterToInverse)
Definition: PcapFilter.h:579
bool matchPacketWithFilter(const RawPacket *rawPacket)
Direction
Definition: PcapFilter.h:43
Definition: PcapFilter.h:77
Definition: PcapFilter.h:570
IPv4IDFilter(uint16_t ipID, FilterOperator op)
Definition: PcapFilter.h:323
Definition: PcapFilter.h:748
IPv4TotalLengthFilter(uint16_t totalLength, FilterOperator op)
Definition: PcapFilter.h:352
void setDirection(Direction dir)
Definition: PcapFilter.h:210
LinkLayerType
Definition: RawPacket.h:25
Definition: PcapFilter.h:220
void setTcpFlagsBitMask(uint8_t tcpFlagBitMask, MatchOptions matchOption)
Definition: PcapFilter.h:736
void setLength(uint16_t length)
Definition: PcapFilter.h:796
TcpWindowSizeFilter(uint16_t windowSize, FilterOperator op)
Definition: PcapFilter.h:759
void setTotalLength(uint16_t totalLength)
Definition: PcapFilter.h:360
Definition: PcapFilter.h:68
OrFilter()
Definition: PcapFilter.h:546
Definition: PcapFilter.h:370
ArpFilter(ArpOpcode opCode)
Definition: PcapFilter.h:638
void setWindowSize(uint16_t windowSize)
Definition: PcapFilter.h:767
Definition: PcapFilter.h:46
void setOpCode(ArpOpcode opCode)
Definition: PcapFilter.h:646
EtherTypeFilter(uint16_t etherType)
Definition: PcapFilter.h:474
void addFilter(GeneralFilter *filter)
Definition: PcapFilter.h:558
IPFilter(const std::string &ipAddress, Direction dir, const std::string &ipv4Mask)
Definition: PcapFilter.h:270
void addFilter(GeneralFilter *filter)
Definition: PcapFilter.h:516
Definition: PcapFilter.h:657
Definition: PcapFilter.h:60
PortRangeFilter(uint16_t fromPort, uint16_t toPort, Direction dir)
Definition: PcapFilter.h:412
Definition: PcapFilter.h:167
void setLen(int len)
Definition: PcapFilter.h:302
Definition: PcapFilter.h:713
Definition: PcapFilter.h:313
Definition: PcapFilter.h:62
IPFilter(const std::string &ipAddress, Direction dir)
Definition: PcapFilter.h:259
Definition: PcapFilter.h:244
Definition: PcapFilter.h:537
Definition: PcapFilter.h:66
Definition: PcapFilter.h:777
void setPort(uint16_t port)
Definition: PcapFilter.h:389
Definition: PcapFilter.h:495
Definition: MacAddress.h:28
Definition: PcapFilter.h:70
bool setFilter(const std::string &filter, LinkLayerType linkType=LINKTYPE_ETHERNET)