From: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
Date: Wed, 2 Oct 2025 10:00:00 +0500
Subject: [PATCH] Replace deprecated function.
Forwarded: https://github.com/dleonard0/pktstat/pull/8

diff --git a/main.c b/main.c
index c19cd73..08fc415 100644
--- a/main.c
+++ b/main.c
@@ -151,6 +151,7 @@ main(argc, argv)
 	extern int optind;
 	extern char *optarg;
 	pcap_t *p;
+	pcap_if_t *all_devs;
 	char errbuf[PCAP_ERRBUF_SIZE];
 	char *interface = NULL;
 	int error = 0;
@@ -252,10 +253,14 @@ main(argc, argv)
 	}
 
 	/* Open the interface */
-	if (interface == NULL)
-		interface = pcap_lookupdev(errbuf);
-	if (!interface) 
-		errx(1, "pcap_lookupdev: %s", errbuf);
+	if (interface == NULL) {
+		if (pcap_findalldevs(&all_devs, errbuf) == -1) {
+			errx(1, "pcap_findalldevs: %s", errbuf);
+		}
+		else {
+			interface = all_devs->name;
+		}
+	}
 	p = pcap_open_live(interface, snaplen, Pflag ? 0 : 1, 10, errbuf);
 	if (!p) 
 		errx(1, "%s", errbuf);
