aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Mingrone <jrm@FreeBSD.org>2024-10-03 19:49:51 +0000
committerJoseph Mingrone <jrm@FreeBSD.org>2024-10-04 13:41:53 +0000
commit34aa6f2c2db5cc9655f201a1ef01adbb9fb484d5 (patch)
tree2e76615d567fd653cac54b6d09b0190095de3506
parent75734c4360fcd5c70ab9650683ae47ca11aea15f (diff)
pflogd: Move struct definitions out of header file
In libpcap 1.10.5, two structures that we relied on, pcap_timeval and pcap_sf_pkthdr, were made private. As a workaround, we initially defined the structures in pflogd.h. After further investigation, mostly by kp@, we concluded that it is reasonable to define these structures ourselves since they represent a file format and thus are unlikely to change from under us. We will stick with this solution but move the definitions out of the header file to prevent others from using pflogd.h to access them. Another solution that was considered was using libpcap's pcap_dump() function to write packets, but there are blockers. For example, pflogd writes to a memory buffer, and libpcap lacks support for this. Reviewed by: kp MFC after: 3 days Event: EuroBSDCon 2024 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46894
-rw-r--r--contrib/pf/pflogd/pflogd.c11
-rw-r--r--contrib/pf/pflogd/pflogd.h13
2 files changed, 11 insertions, 13 deletions
diff --git a/contrib/pf/pflogd/pflogd.c b/contrib/pf/pflogd/pflogd.c
index 6df97f8b84f4..e24553dfc37b 100644
--- a/contrib/pf/pflogd/pflogd.c
+++ b/contrib/pf/pflogd/pflogd.c
@@ -74,6 +74,17 @@ char errbuf[PCAP_ERRBUF_SIZE];
int log_debug = 0;
unsigned int delay = FLUSH_DELAY;
+struct pcap_timeval {
+ bpf_u_int32 tv_sec; /* seconds */
+ bpf_u_int32 tv_usec; /* microseconds */
+};
+
+struct pcap_sf_pkthdr {
+ struct pcap_timeval ts; /* time stamp */
+ bpf_u_int32 caplen; /* length of portion present */
+ bpf_u_int32 len; /* length of this packet (off wire) */
+};
+
char *copy_argv(char * const *);
void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
void dump_packet_nobuf(u_char *, const struct pcap_pkthdr *, const u_char *);
diff --git a/contrib/pf/pflogd/pflogd.h b/contrib/pf/pflogd/pflogd.h
index 6e6b588d24bf..596e69692614 100644
--- a/contrib/pf/pflogd/pflogd.h
+++ b/contrib/pf/pflogd/pflogd.h
@@ -40,19 +40,6 @@ int priv_open_log(void);
int priv_move_log(void);
pcap_t *pcap_open_live_fd(int fd, int snaplen, char *ebuf);
-/* XXX TODO: Investigate a permanent solution, rather than defining these two
- structures here. */
-struct pcap_timeval {
- bpf_u_int32 tv_sec; /* seconds */
- bpf_u_int32 tv_usec; /* microseconds */
-};
-
-struct pcap_sf_pkthdr {
- struct pcap_timeval ts; /* time stamp */
- bpf_u_int32 caplen; /* length of portion present */
- bpf_u_int32 len; /* length of this packet (off wire) */
-};
-
void set_pcap_filter(void);
/* File descriptor send/recv */
void send_fd(int, int);