1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 20:24:26 +01:00

Implemented matches_response on several PDUs. Added some test cases.

This commit is contained in:
Matias Fontanini
2013-04-02 21:05:53 -03:00
parent 97049140af
commit f2a5f73337
16 changed files with 352 additions and 12 deletions

View File

@@ -446,8 +446,10 @@ void IP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU* pare
bool IP::matches_response(uint8_t *ptr, uint32_t total_sz) {
if(total_sz < sizeof(iphdr))
return false;
iphdr *ip_ptr = (iphdr*)ptr;
if(_ip.daddr == ip_ptr->saddr && _ip.saddr == ip_ptr->daddr) {
const iphdr *ip_ptr = (const iphdr*)ptr;
// checks for broadcast addr
if((_ip.saddr == ip_ptr->daddr && (_ip.daddr == ip_ptr->saddr || _ip.daddr == 0xffffffff)) ||
(_ip.daddr == 0xffffffff && _ip.saddr == 0)) {
uint32_t sz = std::min<uint32_t>(_ip.ihl * sizeof(uint32_t), total_sz);
return inner_pdu() ? inner_pdu()->matches_response(ptr + sz, total_sz - sz) : true;
}