The code below would fail to compile because XDP_UMEM_PGOFF_FILL_RING and XDP_UMEM_PGOFF_COMPLETION_RING are of type c_ulonglong (u64) while XDP_PGOFF_RX_RING and XDP_PGOFF_TX_RING are of type off_t (i64).
enum RingBufferType {
XdpRx,
XdpTx,
XdpFill,
XdpCompletion
}
impl RingBufferType {
fn get_mmap_offset(&self) -> libc::off_t {
match self {
RingBufferType::XdpRx => libc::XDP_PGOFF_RX_RING,
RingBufferType::XdpTx => libc::XDP_PGOFF_TX_RING,
RingBufferType::XdpFill => libc::XDP_UMEM_PGOFF_FILL_RING,
RingBufferType::XdpCompletion => libc::XDP_UMEM_PGOFF_COMPLETION_RING,
}
}
}
Considering that these constants are used for mmap calls in the position of the offset parameter they should all be off type off_t as that is what mmap expects. This can currently be worked around by simple casting the constant with as.