#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Protocol {
Raw {
protonum: u16,
request_type: u16,
},
Generic(&'static [u8]),
}
pub trait NetlinkRequest {
fn protocol(&self) -> Protocol;
fn flags(&self) -> u16;
fn payload(&self) -> &[u8];
type ReplyType<'buf>;
fn decode_reply(buf: &[u8]) -> Self::ReplyType<'_>;
fn lookup(
buf: &[u8],
offset: usize,
missing_type: Option<u16>,
) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
let _ = buf;
let _ = offset;
let _ = missing_type;
(Vec::new(), None)
}
}
pub type LookupFn =
fn(&[u8], usize, Option<u16>) -> (Vec<(&'static str, usize)>, Option<&'static str>);
pub trait NetlinkChained {
fn protonum(&self) -> u16;
fn payload(&self) -> &[u8];
fn chain_len(&self) -> usize;
fn get_index(&self, seq: u32) -> Option<usize>;
fn name(&self, index: usize) -> &'static str;
fn lookup(&self, index: usize) -> LookupFn {
let _ = index;
|_, _, _| Default::default()
}
}