]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3231] Fixed build issue under MacOS Sonoma
authorThomas Markwalder <tmark@isc.org>
Tue, 20 Feb 2024 14:28:00 +0000 (09:28 -0500)
committerThomas Markwalder <tmark@isc.org>
Tue, 20 Feb 2024 16:38:29 +0000 (11:38 -0500)
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

index 340f0883f55eb655bc1dbff011cbb921887b36b5..6cc979e774e67f7a2ecb177fef962ccd4b79b631 100644 (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);