dnsniff

DNS sniffer
git clone https://git.sinitax.com/sinitax/dnsniff
Log | Files | Refs | LICENSE | sfeed.txt

commit c0f18fb9b102ddd67183da5f0e6f16dc1c866ad9
parent 30d8a9904de544ba14e5cc92b41244867e4c848e
Author: Louis Burda <quent.burda@gmail.com>
Date:   Thu, 16 Feb 2023 20:23:13 +0100

Small fixes

Diffstat:
Mdnsniff.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dnsniff.c b/dnsniff.c @@ -18,6 +18,7 @@ #include <stdint.h> #include <stdbool.h> +#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,