30 #ifndef TINS_PACKET_SENDER_H 31 #define TINS_PACKET_SENDER_H 38 #include <tins/config.h> 39 #ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 41 #endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 42 #include <tins/network_interface.h> 43 #include <tins/macros.h> 44 #include <tins/cxxstd.h> 145 uint32_t recv_timeout = DEFAULT_TIMEOUT,
154 *
this = std::move(rhs);
162 sockets_ = std::move(rhs.sockets_);
163 rhs.sockets_ = std::vector<int>(SOCKETS_END, INVALID_RAW_SOCKET);
165 #if defined(BSD) || defined(__FreeBSD_kernel__) 166 ether_socket_ = std::move(rhs.ether_socket_);
168 ether_socket_ = rhs.ether_socket_;
169 rhs.ether_socket_ = INVALID_RAW_SOCKET;
173 _timeout = rhs._timeout;
174 timeout_usec_ = rhs.timeout_usec_;
175 default_iface_ = rhs.default_iface_;
187 #if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) 194 #endif // !_WIN32 || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) 322 PDU* recv_l2(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr,
327 #if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) 343 void send_l2(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr,
345 #endif // !_WIN32 || TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 361 PDU* recv_l3(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr,
SocketType type);
378 void send_l3(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr,
SocketType type);
380 static const int INVALID_RAW_SOCKET;
382 typedef std::map<SocketType, int> SocketTypeMap;
393 static_cast<T&
>(pdu).send(*
this, iface);
395 #ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 397 #endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 399 PDU* recv_match_loop(
const std::vector<int>& sockets,
401 struct sockaddr* link_addr,
405 std::vector<int> sockets_;
407 #if defined(BSD) || defined(__FreeBSD_kernel__) 408 typedef std::map<uint32_t, int> BSDEtherSockets;
409 BSDEtherSockets ether_socket_;
414 SocketTypeMap types_;
415 uint32_t _timeout, timeout_usec_;
418 #if defined(BSD) || defined(__FreeBSD_kernel__) 421 #ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 422 typedef std::map<NetworkInterface, pcap_t*> PcapHandleMap;
423 PcapHandleMap pcap_handles_;
424 #endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 429 #endif // TINS_PACKET_SENDER_H SocketType
Definition: packet_sender.h:126
PacketSender & operator=(PacketSender &&rhs) TINS_NOEXCEPT
Move assignment operator.
Definition: packet_sender.h:161
Sends packets through a network interface.
Definition: packet_sender.h:116
static const uint32_t DEFAULT_TIMEOUT
Definition: packet_sender.h:121
The Tins namespace.
Definition: address_range.h:38
PacketSender(PacketSender &&rhs) TINS_NOEXCEPT
Move constructor.
Definition: packet_sender.h:153
Abstraction of a network interface.
Definition: network_interface.h:47
Base class for protocol data units.
Definition: pdu.h:107