Struct netlink_sys::rtnl::LinkHeader [−][src]
pub struct LinkHeader { /* fields omitted */ }High level representation of RTM_GETLINK, RTM_SETLINK, RTM_NEWLINK and RTM_DELLING
messages headers.
These headers have the following structure:
0 8 16 24 32
+----------------+----------------+----------------+----------------+
| address family | reserved | link layer type |
+----------------+----------------+----------------+----------------+
| link index |
+----------------+----------------+----------------+----------------+
| flags |
+----------------+----------------+----------------+----------------+
| change mask |
+----------------+----------------+----------------+----------------+
LinkHeader exposes all these fields except for the "reserved" one.
Example
extern crate netlink_sys; use netlink_sys::rtnl::{LinkHeader, LinkFlags, LinkLayerType}; use netlink_sys::constants; fn main() { let mut hdr = LinkHeader::new(); assert_eq!(hdr.address_family(), 0u8); assert_eq!(hdr.link_layer_type(), LinkLayerType::Ether); assert_eq!(hdr.flags(), LinkFlags::new()); assert_eq!(hdr.change_mask(), LinkFlags::new()); let flags = LinkFlags::from(constants::IFF_UP); hdr.set_flags(flags) .set_change_mask(flags) .set_link_layer_type(LinkLayerType::IpGre); assert_eq!(hdr.address_family(), 0u8); assert_eq!(hdr.link_layer_type(), LinkLayerType::IpGre); assert!(hdr.flags().is_up()); assert!(hdr.change_mask().is_up()); }
Methods
impl LinkHeader[src]
impl LinkHeaderpub fn new() -> Self[src]
pub fn new() -> SelfCreate a new LinkHeader:
- address family defaults to
AF_UNSPEC(0) - the link layer type defaults to
ARPHRD_ETHER(LinkLayerType::Ether) - the linx index defaults to 0
- the flags default to 0 (
LinkFlags::new()) - the change master default to 0 (
LinkFlags::new())
pub fn address_family(&self) -> u8[src]
pub fn address_family(&self) -> u8Get the address family
pub fn address_family_mut(&mut self) -> &mut u8[src]
pub fn address_family_mut(&mut self) -> &mut u8Get a mutable reference to the address family value
pub fn set_address_family(&mut self, value: u8) -> &mut Self[src]
pub fn set_address_family(&mut self, value: u8) -> &mut SelfSet the address family value, and return a mutable reference to this LinkHeader, so that
other set_ methods can be called on it.
pub fn index(&self) -> u32[src]
pub fn index(&self) -> u32Get the link index
pub fn index_mut(&mut self) -> &mut u32[src]
pub fn index_mut(&mut self) -> &mut u32Get a mutable reference to the link index value
pub fn set_index(&mut self, value: u32) -> &mut Self[src]
pub fn set_index(&mut self, value: u32) -> &mut SelfSet the link index value, and return a mutable reference to this LinkHeader, so that
other set_ methods can be called on it.
pub fn link_layer_type(&self) -> LinkLayerType[src]
pub fn link_layer_type(&self) -> LinkLayerTypeGet the link layer type
pub fn link_layer_type_mut(&mut self) -> &mut LinkLayerType[src]
pub fn link_layer_type_mut(&mut self) -> &mut LinkLayerTypeGet a mutable reference to the link layer type value
pub fn set_link_layer_type(&mut self, value: LinkLayerType) -> &mut Self[src]
pub fn set_link_layer_type(&mut self, value: LinkLayerType) -> &mut SelfSet the link layer type value, and return a mutable reference to this LinkHeader, so that
other set_ methods can be called on it.
pub fn flags(&self) -> LinkFlags[src]
pub fn flags(&self) -> LinkFlagsGet the flags
pub fn flags_mut(&mut self) -> &mut LinkFlags[src]
pub fn flags_mut(&mut self) -> &mut LinkFlagsGet a mutable reference to the flags value
pub fn set_flags(&mut self, value: LinkFlags) -> &mut Self[src]
pub fn set_flags(&mut self, value: LinkFlags) -> &mut SelfSet the flags value, and return a mutable reference to this LinkHeader, so that
other set_ methods can be called on it.
pub fn change_mask(&self) -> LinkFlags[src]
pub fn change_mask(&self) -> LinkFlagsGet the change mask
pub fn change_mask_mut(&mut self) -> &mut LinkFlags[src]
pub fn change_mask_mut(&mut self) -> &mut LinkFlagsGet a mutable reference to the change mask value
pub fn set_change_mask(&mut self, value: LinkFlags) -> &mut Self[src]
pub fn set_change_mask(&mut self, value: LinkFlags) -> &mut SelfSet the change mask value, and return a mutable reference to this LinkHeader, so that
other set_ methods can be called on it.
Trait Implementations
impl Debug for LinkHeader[src]
impl Debug for LinkHeaderfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for LinkHeader[src]
impl PartialEq for LinkHeaderfn eq(&self, other: &LinkHeader) -> bool[src]
fn eq(&self, other: &LinkHeader) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &LinkHeader) -> bool[src]
fn ne(&self, other: &LinkHeader) -> boolThis method tests for !=.
impl Eq for LinkHeader[src]
impl Eq for LinkHeaderimpl Clone for LinkHeader[src]
impl Clone for LinkHeaderfn clone(&self) -> LinkHeader[src]
fn clone(&self) -> LinkHeaderReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Default for LinkHeader[src]
impl Default for LinkHeaderimpl Emitable for LinkHeader[src]
impl Emitable for LinkHeaderfn buffer_len(&self) -> usize[src]
fn buffer_len(&self) -> usizeReturn the length of the serialized data.
fn emit(&self, buffer: &mut [u8])[src]
fn emit(&self, buffer: &mut [u8])Serialize this types and write the serialized data into the given buffer. Read more
impl<T: AsRef<[u8]>> Parseable<LinkHeader> for LinkBuffer<T>[src]
impl<T: AsRef<[u8]>> Parseable<LinkHeader> for LinkBuffer<T>fn parse(&self) -> Result<LinkHeader>[src]
fn parse(&self) -> Result<LinkHeader>Deserialize the current type.
Auto Trait Implementations
impl Send for LinkHeader
impl Send for LinkHeaderimpl Sync for LinkHeader
impl Sync for LinkHeader