Module neli::nlattr [] [src]

Netlink attribute handler Due to netlink's loose treatment of types, parsing attributes can be hard to model in Rust. neli's current solution is the following:

// This was received from the socket
let nlmsg = neli::nlhdr::NlHdr::new(None, neli::ffi::GenlId::Ctrl, Vec::new(), None, None,
        neli::genlhdr::GenlHdr::new::<u16>(0u8, 2, Vec::new()).unwrap());

// Get parsing handler for the attributes in this message where the next call
// to either get_nested_attributes() or get_payload_with() will expect a u16 type
// to be provided
let mut handle = nlmsg.nl_payload.get_attr_handle::<u16>();

// Get the nested attribute where the NlAttrHdr field of nla_type is equal to 1 and return
// a handler containing only this nested attribute internally
let mut next = handle.get_nested_attributes::<u16>(1).unwrap();

// Get the nested attribute where the NlAttrHdr field of nla_type is equal to 1 and return
// the payload of this attribute as a u32
let thirty_two_bit_integer = next.get_payload_with::<u32>(1, None).unwrap();

Structs

NlAttrHdr

Struct representing netlink attributes and payloads

Enums

AttrHandle

Handle returned by GenlHdr for traversing nested attribute structures