net: implement Udp_packet::checksum_error

For checking the checksum of a UDP packet.

Issue #2775
This commit is contained in:
Martin Stein 2018-04-18 15:29:58 +02:00 committed by Christian Helmuth
parent 6b55790e73
commit 841d583678
2 changed files with 11 additions and 0 deletions

View File

@ -79,6 +79,9 @@ class Net::Udp_packet
void update_checksum(Ipv4_address ip_src,
Ipv4_address ip_dst);
bool checksum_error(Ipv4_address ip_src,
Ipv4_address ip_dst) const;
/***************
** Accessors **

View File

@ -39,3 +39,11 @@ void Net::Udp_packet::update_checksum(Ipv4_address ip_src,
_checksum = internet_checksum_pseudo_ip((uint16_t*)this, length(), _length,
Ipv4_packet::Protocol::UDP, ip_src, ip_dst);
}
bool Net::Udp_packet::checksum_error(Ipv4_address ip_src,
Ipv4_address ip_dst) const
{
return internet_checksum_pseudo_ip((uint16_t*)this, length(), _length,
Ipv4_packet::Protocol::UDP, ip_src, ip_dst);
}