netlink_bindings/
traits.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum Protocol {
3 Raw {
5 protonum: u16,
7 request_type: u16,
9 },
10 Generic(&'static [u8]),
12}
13
14pub trait NetlinkRequest {
17 fn protocol(&self) -> Protocol;
19 fn flags(&self) -> u16;
21
22 fn payload(&self) -> &[u8];
24
25 type ReplyType<'buf>;
26 fn decode_reply(buf: &[u8]) -> Self::ReplyType<'_>;
27
28 fn lookup(
30 buf: &[u8],
31 offset: usize,
32 missing_type: Option<u16>,
33 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
34 let _ = buf;
35 let _ = offset;
36 let _ = missing_type;
37 (Vec::new(), None)
38 }
39}
40
41pub type LookupFn =
43 fn(&[u8], usize, Option<u16>) -> (Vec<(&'static str, usize)>, Option<&'static str>);
44
45pub trait NetlinkChained {
47 fn protonum(&self) -> u16;
48
49 fn payload(&self) -> &[u8];
51
52 fn chain_len(&self) -> usize;
54
55 fn get_index(&self, seq: u32) -> Option<usize>;
56
57 fn name(&self, index: usize) -> &'static str;
58
59 fn lookup(&self, index: usize) -> LookupFn {
60 let _ = index;
61 |_, _, _| Default::default()
62 }
63}