Struct rtnetlink::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 rtnetlink; use rtnetlink::{LinkHeader, LinkFlags, LinkLayerType}; use rtnetlink::constants::IFF_UP; 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(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 LinkHeader
pub fn new() -> Self
[src]
pub fn new() -> Self
Create 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) -> u8
Get the address family
pub fn address_family_mut(&mut self) -> &mut u8
[src]
pub fn address_family_mut(&mut self) -> &mut u8
Get 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 Self
Set 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) -> u32
Get the link index
pub fn index_mut(&mut self) -> &mut u32
[src]
pub fn index_mut(&mut self) -> &mut u32
Get 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 Self
Set 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) -> LinkLayerType
Get the link layer type
pub fn link_layer_type_mut(&mut self) -> &mut LinkLayerType
[src]
pub fn link_layer_type_mut(&mut self) -> &mut LinkLayerType
Get 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 Self
Set 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) -> LinkFlags
Get the flags
pub fn flags_mut(&mut self) -> &mut LinkFlags
[src]
pub fn flags_mut(&mut self) -> &mut LinkFlags
Get 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 Self
Set 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) -> LinkFlags
Get the change mask
pub fn change_mask_mut(&mut self) -> &mut LinkFlags
[src]
pub fn change_mask_mut(&mut self) -> &mut LinkFlags
Get 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 Self
Set 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 LinkHeader
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for LinkHeader
[src]
impl PartialEq for LinkHeader
fn eq(&self, other: &LinkHeader) -> bool
[src]
fn eq(&self, other: &LinkHeader) -> bool
This 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) -> bool
This method tests for !=
.
impl Eq for LinkHeader
[src]
impl Eq for LinkHeader
impl Clone for LinkHeader
[src]
impl Clone for LinkHeader
fn clone(&self) -> LinkHeader
[src]
fn clone(&self) -> LinkHeader
Returns 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 LinkHeader
impl Emitable for LinkHeader
[src]
impl Emitable for LinkHeader
fn buffer_len(&self) -> usize
[src]
fn buffer_len(&self) -> usize
Return 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 LinkHeader
impl Sync for LinkHeader
impl Sync for LinkHeader