Skip to content

Commit 3670ede

Browse files
committed
Address the pcap_lookupdev() deprecation warning.
sniffit.c:1777:5: warning: 'pcap_lookupdev' is deprecated: use 'pcap_findalldevs' and use the first device [-Wdeprecated-declarations]
1 parent f4ff8a4 commit 3670ede

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sniffit.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,8 +1774,14 @@ int main (int argc, char *argv[])
17741774
}
17751775
else
17761776
{
1777-
if((dev = pcap_lookupdev (ebuf)) == NULL)
1777+
pcap_if_t *alldevsp;
1778+
if (pcap_findalldevs (&alldevsp, ebuf) == PCAP_ERROR)
17781779
fprintf (stderr,"%s\n",ebuf), exit (1);
1780+
if (alldevsp == NULL)
1781+
fprintf (stderr, "No network devices available.\n"), exit (1);
1782+
if ((dev = strdup (alldevsp[0].name)) == NULL)
1783+
perror ("strdup"), exit (1);
1784+
pcap_freealldevs (alldevsp);
17791785
}
17801786

17811787
for (i = 0; i < NETDEV_NR; i++)

0 commit comments

Comments
 (0)