mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Use the interface MAC to transmit
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
|
static const uint8_t BROADCAST_MAC[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
|
||||||
std::vector<PCAP::NetworkInterface> PCAP::knownInterfaces;
|
std::vector<PCAP::NetworkInterface> PCAP::knownInterfaces;
|
||||||
|
|
||||||
@@ -272,6 +273,10 @@ void PCAP::readTask() {
|
|||||||
if(packet.etherType != 0xCAB2)
|
if(packet.etherType != 0xCAB2)
|
||||||
continue; // Not a packet to host
|
continue; // Not a packet to host
|
||||||
|
|
||||||
|
if(memcmp(packet.destMAC, interface.macAddress, sizeof(packet.destMAC)) != 0 &&
|
||||||
|
memcmp(packet.destMAC, BROADCAST_MAC, sizeof(packet.destMAC)) != 0)
|
||||||
|
continue; // Packet is not addressed to us or broadcast
|
||||||
|
|
||||||
if(memcmp(packet.srcMAC, deviceMAC, sizeof(deviceMAC)) != 0)
|
if(memcmp(packet.srcMAC, deviceMAC, sizeof(deviceMAC)) != 0)
|
||||||
continue; // Not a packet from the device we're concerned with
|
continue; // Not a packet from the device we're concerned with
|
||||||
|
|
||||||
@@ -285,6 +290,7 @@ void PCAP::writeTask() {
|
|||||||
EthernetPacket sendPacket;
|
EthernetPacket sendPacket;
|
||||||
|
|
||||||
// Set MAC address of packet
|
// Set MAC address of packet
|
||||||
|
memcpy(sendPacket.srcMAC, interface.macAddress, sizeof(sendPacket.srcMAC));
|
||||||
memcpy(sendPacket.destMAC, deviceMAC, sizeof(deviceMAC));
|
memcpy(sendPacket.destMAC, deviceMAC, sizeof(deviceMAC));
|
||||||
|
|
||||||
while(!closing) {
|
while(!closing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user