2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#3231] Fixed build issue under MacOS Sonoma

Added conditional compilation to address MacOS adding
the macro BPF_TIMEVAL to define the structure used
in the bpf header as either "struct timeval" or
"struct timeval32" (64 bit vs 32 bit).  CMSG uses
timeval, BPF uses timeval32.

src/lib/dhcp/pkt_filter_bpf.cc
    PktFilterBPF::receive()
This commit is contained in:
Thomas Markwalder
2024-02-20 09:28:00 -05:00
parent 332fa26923
commit 6fec7cf6da

View File

@@ -18,6 +18,7 @@
namespace {
using namespace isc::dhcp;
using namespace boost::posix_time;
/// @brief Maximum number of attempts to open BPF device.
const unsigned int MAX_BPF_OPEN_ATTEMPTS = 100;
@@ -538,7 +539,17 @@ PktFilterBPF::receive(Iface& iface, const SocketInfo& socket_info) {
pkt->setRemoteHWAddr(dummy_pkt->getRemoteHWAddr());
// Set time the packet was stored in the buffer.
#ifdef BPF_TIMEVAL
// Convert to ptime directly to avoid timeval vs
// timeval32 definitons under MacOS.
time_t time_t_secs = bpfh.bh_tstamp.tv_sec;
ptime timestamp = from_time_t(time_t_secs);
time_duration usecs(0, 0, 0, bpfh.bh_tstamp.tv_usec);
timestamp += usecs;
pkt->addPktEvent(PktEvent::SOCKET_RECEIVED, timestamp);
#else
pkt->addPktEvent(PktEvent::SOCKET_RECEIVED, bpfh.bh_tstamp);
#endif
// Set time packet was read from the buffer.
pkt->addPktEvent(PktEvent::BUFFER_READ);