Helper class for dealing with libpcap handles. More...
#include <daemon/face/pcap-helper.hpp>
Inheritance diagram for nfd::face::PcapHelper:
Collaboration diagram for nfd::face::PcapHelper:Classes | |
| class | Error |
Public Member Functions | |
| PcapHelper (const std::string &interfaceName) | |
| Create a libpcap context for live packet capture on a network interface. More... | |
| ~PcapHelper () | |
| void | activate (int dlt) |
| Start capturing packets. More... | |
| void | close () |
| Stop capturing and close the handle. More... | |
| int | getFd () const |
| Obtain a file descriptor that can be used in calls such as select(2) and poll(2). More... | |
| std::string | getLastError () const |
| Get last error message. More... | |
| size_t | getNDropped () const |
| Get the number of packets dropped by the kernel, as reported by libpcap. More... | |
| operator pcap_t * () const | |
| std::tuple< const uint8_t *, size_t, std::string > | readNextPacket () const |
| Read the next packet captured on the interface. More... | |
| void | setPacketFilter (const char *filter) const |
| Install a BPF filter on the receiving socket. More... | |
Helper class for dealing with libpcap handles.
Definition at line 45 of file pcap-helper.hpp.
|
explicit |
Create a libpcap context for live packet capture on a network interface.
| Error | on any error |
Definition at line 38 of file pcap-helper.cpp.
| nfd::face::PcapHelper::~PcapHelper | ( | ) |
Definition at line 54 of file pcap-helper.cpp.
| void nfd::face::PcapHelper::activate | ( | int | dlt | ) |
Start capturing packets.
| dlt | The link-layer header type to be used. |
| Error | on any error |
Definition at line 60 of file pcap-helper.cpp.
| void nfd::face::PcapHelper::close | ( | ) |
Stop capturing and close the handle.
Definition at line 74 of file pcap-helper.cpp.
| int nfd::face::PcapHelper::getFd | ( | ) | const |
Obtain a file descriptor that can be used in calls such as select(2) and poll(2).
| Error | on any error |
Definition at line 83 of file pcap-helper.cpp.
| std::string nfd::face::PcapHelper::getLastError | ( | ) | const |
Get last error message.
Definition at line 95 of file pcap-helper.cpp.
| size_t nfd::face::PcapHelper::getNDropped | ( | ) | const |
Get the number of packets dropped by the kernel, as reported by libpcap.
| Error | on any error |
Definition at line 101 of file pcap-helper.cpp.
|
inline |
Definition at line 134 of file pcap-helper.hpp.
| std::tuple< const uint8_t *, size_t, std::string > nfd::face::PcapHelper::readNextPacket | ( | ) | const |
Read the next packet captured on the interface.
Definition at line 124 of file pcap-helper.cpp.
| void nfd::face::PcapHelper::setPacketFilter | ( | const char * | filter | ) | const |
Install a BPF filter on the receiving socket.
| filter | Null-terminated string containing the BPF program source. |
| Error | on any error |
Definition at line 111 of file pcap-helper.cpp.