From e7ca63eaa6986cf77a6e56c67d95cf1c15a18ba6 Mon Sep 17 00:00:00 2001 From: Starnakin Date: Tue, 27 May 2025 13:25:37 +0200 Subject: [PATCH] clean: upgrade readability --- src/scan.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/scan.c b/src/scan.c index 9a67731..fa3ec2a 100644 --- a/src/scan.c +++ b/src/scan.c @@ -19,33 +19,22 @@ static void dispatch_callback(u_char *user, const struct pcap_pkthdr *h, const struct scan *data = (struct scan *)user; const struct iphdr *iphdr = (struct iphdr *)(bytes + sizeof(struct ether_header)); + const void *packet = bytes + sizeof(struct ether_header) + sizeof(struct iphdr); if (iphdr->protocol == IPPROTO_TCP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct tcphdr)) { - tcp_response( - (const struct tcphdr *)(bytes + - sizeof(struct ether_header) + - sizeof(struct iphdr)), - data); + tcp_response(packet, data); } if (iphdr->protocol == IPPROTO_UDP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct udphdr)) { - udp_response( - (const struct udphdr *)(bytes + - sizeof(struct ether_header) + - sizeof(struct iphdr)), - data); + udp_response(packet, data); } if (iphdr->protocol == IPPROTO_ICMP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct icmphdr)) { - icmp_response( - (const struct icmphdr *)(bytes + - sizeof(struct ether_header) + - sizeof(struct iphdr)), - data); + icmp_response(packet, data); } }