From 1cec099c0e3c38e5d030cb00f4137914151d23c3 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Tue, 26 Mar 2013 00:25:47 -0300 Subject: [PATCH] Dot3::matches_response now works as expected. --- src/dot3.cpp | 6 ++++-- src/ethernetII.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dot3.cpp b/src/dot3.cpp index 3315f51..0a71451 100644 --- a/src/dot3.cpp +++ b/src/dot3.cpp @@ -118,9 +118,11 @@ void Dot3::send(PacketSender &sender) { bool Dot3::matches_response(uint8_t *ptr, uint32_t total_sz) { if(total_sz < sizeof(ethhdr)) return false; - ethhdr *eth_ptr = (ethhdr*)ptr; + const ethhdr *eth_ptr = (const ethhdr*)ptr; if(!memcmp(eth_ptr->dst_mac, _eth.src_mac, sizeof(_eth.src_mac))) { - return true; + ptr += sizeof(ethhdr); + total_sz -= sizeof(ethhdr); + return inner_pdu() ? inner_pdu()->matches_response(ptr, total_sz) : true; } return false; } diff --git a/src/ethernetII.cpp b/src/ethernetII.cpp index 6d879dc..c422e75 100644 --- a/src/ethernetII.cpp +++ b/src/ethernetII.cpp @@ -130,7 +130,7 @@ void EthernetII::send(PacketSender &sender) { bool EthernetII::matches_response(uint8_t *ptr, uint32_t total_sz) { if(total_sz < sizeof(ethhdr)) return false; - ethhdr *eth_ptr = (ethhdr*)ptr; + const ethhdr *eth_ptr = (const ethhdr*)ptr; if(!memcmp(eth_ptr->dst_mac, _eth.src_mac, address_type::address_size)) { // chequear broadcast en destino original... return (inner_pdu()) ? inner_pdu()->matches_response(ptr + sizeof(_eth), total_sz - sizeof(_eth)) : true;