From 214abd7ddda7e7a8ac6593a04c193c80f928a602 Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 19 Nov 2025 09:15:34 -0600 Subject: [PATCH] clean: move packet header (type and code) verifications from packet_compare to packet_check --- src/packet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packet.c b/src/packet.c index c221146..bc2701d 100644 --- a/src/packet.c +++ b/src/packet.c @@ -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);