1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 04:34:27 +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

@@ -161,9 +161,9 @@ void Tins::ICMP::write_serialization(uint8_t *buffer, uint32_t total_sz, const P
bool Tins::ICMP::matches_response(uint8_t *ptr, uint32_t total_sz) {
if(total_sz < sizeof(icmphdr))
return false;
icmphdr *icmp_ptr = (icmphdr*)ptr;
if(_icmp.type == ECHO_REQUEST) {
return icmp_ptr->type == ECHO_REPLY && icmp_ptr->un.echo.id == _icmp.un.echo.id && icmp_ptr->un.echo.sequence == _icmp.un.echo.sequence;
const icmphdr *icmp_ptr = (const icmphdr*)ptr;
if(_icmp.type == ECHO_REQUEST && icmp_ptr->type == ECHO_REPLY) {
return icmp_ptr->un.echo.id == _icmp.un.echo.id && icmp_ptr->un.echo.sequence == _icmp.un.echo.sequence;
}
return false;
}