fping
fping copied to clipboard
fix ICMPv6 error message handling and reporting
Handling of received ICMPv6 messages different from Echo Reply was based on IPv4 code. It would thus use a too small minimum size, and interpret the wrong data as ICMPv6 fields. Thus received ICMPv6 error messages were either not reported at all, or were reported incorrectly.
This commit introduces the following changes to fix this and thus address GitHub issue #390:
- Filter out irrelevant ICMPv6 messages: fping needs to receive ICMPv6 Echo Reply and ICMPv6 error messages, nothing else (only relevant for raw sockets).
- Fix offset calculation to look at the included packet that caused this ICMPv6 error message.
- Ignore invoking packets that do not have ICMPv6 as the first IPv6 Next Header in the packet (there could be, e.g., IPv6 Extension Headers).
- Fix ICMPv6 message type determination, and print respective warning messages.