diff options
author | Thomas Markwalder <tmark@isc.org> | 2024-02-20 15:28:00 +0100 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2024-02-20 17:38:29 +0100 |
commit | 6fec7cf6dae4877bf8380cfaa12c063dbd3f6b9d (patch) | |
tree | 7fe32f5898dc7abf119958567bf4bd3c3b3a0691 /src/lib | |
parent | [#3231] Addressed review comments (diff) | |
download | kea-6fec7cf6dae4877bf8380cfaa12c063dbd3f6b9d.tar.xz kea-6fec7cf6dae4877bf8380cfaa12c063dbd3f6b9d.zip |
[#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()
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dhcp/pkt_filter_bpf.cc | 11 |
1 files changed, 11 insertions, 0 deletions
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); |