Skip to content

Commit

Permalink
socket: Support NETLINK_GET_STRICT_CHK
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cathay4t committed Apr 3, 2024
1 parent aab4c93 commit 9ef231c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down

0 comments on commit 9ef231c

Please sign in to comment.