From 9ef231c53bdea690b5ca9ddb5801e518309326fe Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Wed, 3 Apr 2024 19:46:44 +0800 Subject: [PATCH] socket: Support `NETLINK_GET_STRICT_CHK` Introduce `Socket::set_netlink_get_strict_chk()` wrapping: ```rust libc::setsockopt( fd, libc::SOL_NETLINK, libc::NETLINK_GET_STRICT_CHK, 1u32.to_ne_bytes().as_ptr() as *const _, 4, ) ``` Signed-off-by: Gris Ge --- src/socket.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/socket.rs b/src/socket.rs index 50e738a..a374227 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -546,6 +546,18 @@ impl Socket { )?; Ok(res as usize) } + + /// Enable strict input checking(`NETLINK_GET_STRICT_CHK`) in netlink route + /// protocol. + pub fn set_netlink_get_strict_chk(&self, value: bool) -> Result<()> { + let value: u32 = value.into(); + setsockopt( + self.0, + libc::SOL_NETLINK, + libc::NETLINK_GET_STRICT_CHK, + value, + ) + } } /// Wrapper around `getsockopt`: