]> The Tcpdump Group git mirrors - libpcap/commitdiff
npcap: squelch deprecation warnings for kernel dump mode.
authorGuy Harris <[email protected]>
Thu, 6 Jan 2022 22:42:16 +0000 (14:42 -0800)
committerGuy Harris <[email protected]>
Sun, 20 Feb 2022 23:49:50 +0000 (15:49 -0800)
If we're building with Npcap, just have the dump mode routines return an
error with a message indicating that kernel dump mode isn't supported.

[skip cirrus]

(cherry picked from commit 1a37338725ba1796ed9d986139e304dd64cd8b14)

pcap-npf.c

index e385b2acc8705600292a60632ef004abdcd4a692..0f90b36aa871bed9dcae6eb425fb777ef099b631 100644 (file)
@@ -445,6 +445,31 @@ pcap_setuserbuffer_npf(pcap_t *p, int size)
        return (0);
 }
 
+#ifdef HAVE_NPCAP_PACKET_API
+/*
+ * Kernel dump mode isn't supported in Npcap; calls to PacketSetDumpName(),
+ * PacketSetDumpLimits(), and PacketIsDumpEnded() will get compile-time
+ * deprecation warnings.
+ *
+ * Avoid calling them; just return errors indicating that kernel dump
+ * mode isn't supported in Npcap.
+ */
+static int
+pcap_live_dump_npf(pcap_t *p, char *filename _U_, int maxsize _U_,
+    int maxpacks _U_)
+{
+       snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+           "Npcap doesn't support kernel dump mode");
+       return (-1);
+}
+static int
+pcap_live_dump_ended_npf(pcap_t *p, int sync)
+{
+       snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+           "Npcap doesn't support kernel dump mode");
+       return (-1);
+}
+#else /* HAVE_NPCAP_PACKET_API */
 static int
 pcap_live_dump_npf(pcap_t *p, char *filename, int maxsize, int maxpacks)
 {
@@ -485,6 +510,7 @@ pcap_live_dump_ended_npf(pcap_t *p, int sync)
 
        return (PacketIsDumpEnded(pw->adapter, (BOOLEAN)sync));
 }
+#endif /* HAVE_NPCAP_PACKET_API */
 
 #ifdef HAVE_AIRPCAP_API
 static PAirpcapHandle