NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
pcap-helper.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#ifndef NFD_DAEMON_FACE_PCAP_HELPER_HPP
27
#define NFD_DAEMON_FACE_PCAP_HELPER_HPP
28
29
#include "
core/common.hpp
"
30
31
#ifndef HAVE_LIBPCAP
32
#error "Cannot include this file when libpcap is not available"
33
#endif
34
35
// forward declarations
36
struct
pcap;
37
typedef
pcap
pcap_t
;
38
39
namespace
nfd
{
40
namespace
face
{
41
45
class
PcapHelper
: noncopyable
46
{
47
public
:
48
class
Error
:
public
std::runtime_error
49
{
50
public
:
51
explicit
52
Error
(
const
std::string& what)
53
:
std
::runtime_error(what)
54
{
55
}
56
};
57
63
explicit
64
PcapHelper
(
const
std::string& interfaceName);
65
66
~PcapHelper
();
67
74
void
75
activate
(
int
dlt);
76
81
void
82
close
();
83
91
int
92
getFd
()
const
;
93
100
std::string
101
getLastError
()
const
;
102
108
size_t
109
getNDropped
()
const
;
110
118
void
119
setPacketFilter
(
const
char
* filter)
const
;
120
131
std::tuple<const uint8_t*, size_t, std::string>
132
readNextPacket
()
const
;
133
134
operator
pcap_t
*()
const
135
{
136
return
m_pcap;
137
}
138
139
private
:
140
pcap_t
* m_pcap;
141
};
142
143
}
// namespace face
144
}
// namespace nfd
145
146
#endif // NFD_DAEMON_FACE_PCAP_HELPER_HPP
nfd::face::PcapHelper::setPacketFilter
void setPacketFilter(const char *filter) const
Install a BPF filter on the receiving socket.
Definition:
pcap-helper.cpp:113
nfd::face::PcapHelper::activate
void activate(int dlt)
Start capturing packets.
Definition:
pcap-helper.cpp:62
nfd::face::PcapHelper::~PcapHelper
~PcapHelper()
Definition:
pcap-helper.cpp:56
nfd::face::PcapHelper
Helper class for dealing with libpcap handles.
Definition:
pcap-helper.hpp:45
std
STL namespace.
common.hpp
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
face
pcap_t
pcap pcap_t
Definition:
pcap-helper.hpp:36
nfd::face::PcapHelper::close
void close()
Stop capturing and close the handle.
Definition:
pcap-helper.cpp:76
nfd::face::PcapHelper::readNextPacket
std::tuple< const uint8_t *, size_t, std::string > readNextPacket() const
Read the next packet captured on the interface.
Definition:
pcap-helper.cpp:126
nfd::face::PcapHelper::Error::Error
Error(const std::string &what)
Definition:
pcap-helper.hpp:52
nfd::face::PcapHelper::PcapHelper
PcapHelper(const std::string &interfaceName)
Create a libpcap context for live packet capture on a network interface.
Definition:
pcap-helper.cpp:38
nfd::face::PcapHelper::Error
Definition:
pcap-helper.hpp:48
nfd::face::PcapHelper::getLastError
std::string getLastError() const
Get last error message.
Definition:
pcap-helper.cpp:97
nfd::face::PcapHelper::getFd
int getFd() const
Obtain a file descriptor that can be used in calls such as select(2) and poll(2). ...
Definition:
pcap-helper.cpp:85
nfd::face::PcapHelper::getNDropped
size_t getNDropped() const
Get the number of packets dropped by the kernel, as reported by libpcap.
Definition:
pcap-helper.cpp:103
ndnSIM
NFD
daemon
face
pcap-helper.hpp
Generated on Thu Nov 2 2017 03:30:29 for ndnSIM by
1.8.11