1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Use pcap_sendpacket to send packets if this mode is enabled.

This commit is contained in:
Matias Fontanini
2015-04-18 17:46:14 -07:00
parent f2ed64293b
commit 96fc1a3749
6 changed files with 93 additions and 26 deletions

View File

@@ -10,4 +10,7 @@
/* Have WPA2 decryption library */
#cmakedefine HAVE_WPA2_DECRYPTION
/* Use pcap_sendpacket to send l2 packets */
#cmakedefine HAVE_PACKET_SENDER_PCAP_SENDPACKET
#endif // TINS_CONFIG_H

View File

@@ -145,13 +145,10 @@ namespace Tins {
*/
uint32_t trailer_size() const;
// Windows does not support sending L2 PDUs.
#ifndef WIN32
/**
* \sa PDU::send()
*/
void send(PacketSender &sender, const NetworkInterface &iface);
#endif // WIN32
/**
* \brief Check wether ptr points to a valid response for this PDU.

View File

@@ -36,6 +36,10 @@
#include <vector>
#include <stdint.h>
#include <map>
#include "config.h"
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
#include <pcap.h>
#endif // HAVE_PACKET_SENDER_PCAP_SENDPACKET
#include "network_interface.h"
#include "macros.h"
#include "cxxstd.h"
@@ -378,6 +382,9 @@ namespace Tins {
void send(PDU &pdu, const NetworkInterface &iface) {
static_cast<T&>(pdu).send(*this, iface);
}
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
pcap_t* make_pcap_handle(const NetworkInterface& iface) const;
#endif // HAVE_PACKET_SENDER_PCAP_SENDPACKET
PDU *recv_match_loop(const std::vector<int>& sockets, PDU &pdu, struct sockaddr* link_addr,
uint32_t addrlen);
@@ -397,7 +404,11 @@ namespace Tins {
// In BSD we need to store the buffer size, retrieved using BIOCGBLEN
#if defined(BSD) || defined(__FreeBSD_kernel__)
int buffer_size;
#endif
#endif // BSD
#ifdef HAVE_PACKET_SENDER_PCAP_SENDPACKET
typedef std::map<NetworkInterface, pcap_t*> PcapHandleMap;
PcapHandleMap pcap_handles;
#endif // HAVE_PACKET_SENDER_PCAP_SENDPACKET
};
}