From 6fec7cf6dae4877bf8380cfaa12c063dbd3f6b9d Mon Sep 17 00:00:00 2001 From: Thomas Markwalder Date: Tue, 20 Feb 2024 09:28:00 -0500 Subject: [#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() --- src/lib/dhcp/pkt_filter_bpf.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib') diff --git a/src/lib/dhcp/pkt_filter_bpf.cc b/src/lib/dhcp/pkt_filter_bpf.cc index 340f0883f5..6cc979e774 100644 --- a/src/lib/dhcp/pkt_filter_bpf.cc +++ b/src/lib/dhcp/pkt_filter_bpf.cc @@ -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); -- cgit v1.2.3