clean: move packet header (type and code) verifications from packet_compare to packet_check
This commit is contained in:
@ -45,9 +45,6 @@ int packet_compare(const char *sent, const char *received, size_t packet_size)
|
||||
{
|
||||
const struct icmphdr *sent_hdr = (const struct icmphdr*) sent;
|
||||
const struct icmphdr *received_hdr = (const struct icmphdr*) received;
|
||||
|
||||
if (received_hdr->type != 0 || received_hdr->code != 8)
|
||||
return 1;
|
||||
|
||||
if (received_hdr->un.echo.sequence == sent_hdr->un.echo.sequence)
|
||||
return 2;
|
||||
@ -62,6 +59,9 @@ int packet_check(char *packet, size_t packet_size)
|
||||
{
|
||||
struct icmphdr *hdr = (struct icmphdr *) packet;
|
||||
|
||||
if (hdr->type != 0 || hdr->code != 8)
|
||||
return 1;
|
||||
|
||||
const uint16_t checksum_bak = hdr->checksum;
|
||||
hdr->checksum = 0;
|
||||
int tmp = checksum(packet, packet_size);
|
||||
|
||||
Reference in New Issue
Block a user