Page MenuHomeFreeBSD

D46676.id143347.diff
No OneTemporary

D46676.id143347.diff

diff --git a/contrib/pf/pflogd/pflogd.h b/contrib/pf/pflogd/pflogd.h
--- a/contrib/pf/pflogd/pflogd.h
+++ b/contrib/pf/pflogd/pflogd.h
@@ -40,6 +40,19 @@
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);
diff --git a/contrib/pf/pflogd/pflogd.c b/contrib/pf/pflogd/pflogd.c
--- a/contrib/pf/pflogd/pflogd.c
+++ b/contrib/pf/pflogd/pflogd.c
@@ -403,11 +403,7 @@
scan_dump(FILE *fp, off_t size)
{
struct pcap_file_header hdr;
-#ifdef __FreeBSD__
- struct pcap_sf_pkthdr ph;
-#else
struct pcap_pkthdr ph;
-#endif
off_t pos;
/*
@@ -476,35 +472,18 @@
dump_packet_nobuf(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
FILE *f = (FILE *)user;
-#ifdef __FreeBSD__
- struct pcap_sf_pkthdr sh;
-#endif
if (suspended) {
packets_dropped++;
return;
}
-#ifdef __FreeBSD__
- sh.ts.tv_sec = (bpf_int32)h->ts.tv_sec;
- sh.ts.tv_usec = (bpf_int32)h->ts.tv_usec;
- sh.caplen = h->caplen;
- sh.len = h->len;
-
- if (fwrite((char *)&sh, sizeof(sh), 1, f) != 1) {
-#else
if (fwrite((char *)h, sizeof(*h), 1, f) != 1) {
-#endif
off_t pos = ftello(f);
/* try to undo header to prevent corruption */
-#ifdef __FreeBSD__
- if (pos < sizeof(sh) ||
- ftruncate(fileno(f), pos - sizeof(sh))) {
-#else
if (pos < sizeof(*h) ||
ftruncate(fileno(f), pos - sizeof(*h))) {
-#endif
logmsg(LOG_ERR, "Write failed, corrupted logfile!");
set_suspended(1);
gotsig_close = 1;
@@ -573,12 +552,7 @@
dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
FILE *f = (FILE *)user;
-#ifdef __FreeBSD__
- struct pcap_sf_pkthdr sh;
- size_t len = sizeof(sh) + h->caplen;
-#else
size_t len = sizeof(*h) + h->caplen;
-#endif
if (len < sizeof(*h) || h->caplen > (size_t)cur_snaplen) {
logmsg(LOG_NOTICE, "invalid size %u (%u/%u), packet dropped",
@@ -606,18 +580,8 @@
}
append:
-#ifdef __FreeBSD__
- sh.ts.tv_sec = (bpf_int32)h->ts.tv_sec;
- sh.ts.tv_usec = (bpf_int32)h->ts.tv_usec;
- sh.caplen = h->caplen;
- sh.len = h->len;
-
- memcpy(bufpos, &sh, sizeof(sh));
- memcpy(bufpos + sizeof(sh), sp, h->caplen);
-#else
memcpy(bufpos, h, sizeof(*h));
memcpy(bufpos + sizeof(*h), sp, h->caplen);
-#endif
bufpos += len;
bufleft -= len;

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 2, 4:44 AM (13 h, 34 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37908757
Default Alt Text
D46676.id143347.diff (2 KB)

Event Timeline