mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Allow sending Dot3 on Windows using pcap_sendpacket.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <stdint.h>
|
||||
#include "macros.h"
|
||||
#include "pdu.h"
|
||||
#include "config.h"
|
||||
#include "endianness.h"
|
||||
#include "hw_address.h"
|
||||
|
||||
@@ -137,12 +138,12 @@ namespace Tins {
|
||||
*/
|
||||
uint32_t header_size() const;
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined(WIN32) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
|
||||
/**
|
||||
* \sa PDU::send()
|
||||
*/
|
||||
void send(PacketSender &sender, const NetworkInterface &iface);
|
||||
#endif // WIN32
|
||||
#endif // !WIN32 || HAVE_PACKET_SENDER_PCAP_SENDPACKET
|
||||
|
||||
/**
|
||||
* \brief Check wether ptr points to a valid response for this PDU.
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <stdint.h>
|
||||
#include "macros.h"
|
||||
#include "pdu.h"
|
||||
#include "config.h"
|
||||
#include "endianness.h"
|
||||
#include "hw_address.h"
|
||||
|
||||
|
||||
10
src/dot3.cpp
10
src/dot3.cpp
@@ -87,12 +87,14 @@ uint32_t Dot3::header_size() const {
|
||||
return sizeof(ethhdr);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined(WIN32) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
|
||||
void Dot3::send(PacketSender &sender, const NetworkInterface &iface) {
|
||||
if(!iface)
|
||||
throw invalid_interface();
|
||||
|
||||
#if !defined(BSD) && !defined(__FreeBSD_kernel__)
|
||||
#if defined(BSD) || defined(__FreeBSD_kernel__) || defined(HAVE_PACKET_SENDER_PCAP_SENDPACKET)
|
||||
sender.send_l2(*this, 0, 0, iface);
|
||||
#else
|
||||
struct sockaddr_ll addr;
|
||||
|
||||
memset(&addr, 0, sizeof(struct sockaddr_ll));
|
||||
@@ -104,11 +106,9 @@ void Dot3::send(PacketSender &sender, const NetworkInterface &iface) {
|
||||
memcpy(&(addr.sll_addr), _eth.dst_mac, sizeof(_eth.dst_mac));
|
||||
|
||||
sender.send_l2(*this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr));
|
||||
#else
|
||||
sender.send_l2(*this, 0, 0, iface);
|
||||
#endif
|
||||
}
|
||||
#endif // WIN32
|
||||
#endif // !WIN32 || HAVE_PACKET_SENDER_PCAP_SENDPACKET
|
||||
|
||||
bool Dot3::matches_response(const uint8_t *ptr, uint32_t total_sz) const {
|
||||
if(total_sz < sizeof(ethhdr))
|
||||
|
||||
Reference in New Issue
Block a user