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> 147 uint32_t recv_timeout = DEFAULT_TIMEOUT,
156 *
this = std::move(rhs);
164 sockets_ = std::move(rhs.sockets_);
165 rhs.sockets_ = std::vector<int>(SOCKETS_END, INVALID_RAW_SOCKET);
167 #if defined(BSD) || defined(__FreeBSD_kernel__) 168 ether_socket_ = std::move(rhs.ether_socket_);
170 ether_socket_ = rhs.ether_socket_;
171 rhs.ether_socket_ = INVALID_RAW_SOCKET;
175 _timeout = rhs._timeout;
176 timeout_usec_ = rhs.timeout_usec_;
177 default_iface_ = rhs.default_iface_;
189 #if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) 196 #endif // !_WIN32 || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) 209 void open_l3_socket(SocketType type);
324 PDU* recv_l2(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr,
329 #if !defined(_WIN32) || defined(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET) 345 void send_l2(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr,
347 #endif // !_WIN32 || TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 363 PDU* recv_l3(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr, SocketType type);
380 void send_l3(
PDU& pdu,
struct sockaddr* link_addr, uint32_t len_addr, SocketType type);
382 static const int INVALID_RAW_SOCKET;
384 typedef std::map<SocketType, int> SocketTypeMap;
388 int find_type(SocketType type);
395 static_cast<T&
>(pdu).send(*
this, iface);
397 #ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 398 pcap_t* make_pcap_handle(
const NetworkInterface& iface)
const;
399 #endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 401 PDU* recv_match_loop(
const std::vector<int>& sockets,
403 struct sockaddr* link_addr,
407 std::vector<int> sockets_;
409 #if defined(BSD) || defined(__FreeBSD_kernel__) 410 typedef std::map<uint32_t, int> BSDEtherSockets;
411 BSDEtherSockets ether_socket_;
416 SocketTypeMap types_;
417 uint32_t _timeout, timeout_usec_;
418 NetworkInterface default_iface_;
420 #if defined(BSD) || defined(__FreeBSD_kernel__) 423 #ifdef TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 424 typedef std::map<NetworkInterface, pcap_t*> PcapHandleMap;
425 PcapHandleMap pcap_handles_;
426 #endif // TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET 431 #endif // TINS_PACKET_SENDER_H SocketType
Definition: packet_sender.h:128
PacketSender & operator=(PacketSender &&rhs) TINS_NOEXCEPT
Move assignment operator.
Definition: packet_sender.h:163
Sends packets through a network interface.
Definition: packet_sender.h:118
static const uint32_t DEFAULT_TIMEOUT
Definition: packet_sender.h:123
The Tins namespace.
Definition: address_range.h:38
PacketSender(PacketSender &&rhs) TINS_NOEXCEPT
Move constructor.
Definition: packet_sender.h:155
Abstraction of a network interface.
Definition: network_interface.h:47
Base class for protocol data units.
Definition: pdu.h:107