From c0f18fb9b102ddd67183da5f0e6f16dc1c866ad9 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Thu, 16 Feb 2023 20:23:13 +0100 Subject: Small fixes --- dnsniff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dnsniff.c b/dnsniff.c index 4a1e3f2..319bd83 100644 --- a/dnsniff.c +++ b/dnsniff.c @@ -18,6 +18,7 @@ #include #include +#define PACKETBUFLEN (1024 * 1024) #define HDRLEN (sizeof(struct ethhdr) + sizeof(struct iphdr) + sizeof(struct udphdr)) struct dnshdr { @@ -74,7 +75,7 @@ static int sock, ifid; void usage(void) { - printf("Usage: dnsniff INTERFACE\n"); + printf("Usage: dnsniff IFACE\n"); exit(0); } @@ -238,7 +239,7 @@ main(int argc, const char **argv) if (argc != 2) usage(); ifname = argv[1]; - buf = malloc(1024 * 1024); + buf = malloc(PACKETBUFLEN); if (!buf) err(1, "malloc"); sniff_init(ifname); @@ -246,7 +247,7 @@ main(int argc, const char **argv) flt.dst_ip = 0; flt.src_ip = 0; flt.dst_port = htons(53); - while (sniff(&pkt, &flt, buf, 1024 * 1024)) { + while (sniff(&pkt, &flt, buf, PACKETBUFLEN)) { inet_ntop(AF_INET, (struct in_addr *) &pkt.ip->saddr, src_ip, INET_ADDRSTRLEN); inet_ntop(AF_INET, (struct in_addr *) &pkt.ip->daddr, -- cgit v1.2.3-71-gd317