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]

Create a new LinkHeader:

Get the address family

Get a mutable reference to the address family value

Set the address family value, and return a mutable reference to this LinkHeader, so that other set_ methods can be called on it.

Get the link index

Get a mutable reference to the link index value

Set the link index value, and return a mutable reference to this LinkHeader, so that other set_ methods can be called on it.

Get the link layer type

Get a mutable reference to the link layer type value

Set the link layer type value, and return a mutable reference to this LinkHeader, so that other set_ methods can be called on it.

Get the flags

Get a mutable reference to the flags value

Set the flags value, and return a mutable reference to this LinkHeader, so that other set_ methods can be called on it.

Get the change mask

Get a mutable reference to the change mask value

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]

Formats the value using the given formatter. Read more

impl PartialEq for LinkHeader
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for LinkHeader
[src]

impl Clone for LinkHeader
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for LinkHeader
[src]

Returns the "default value" for a type. Read more

impl Emitable for LinkHeader
[src]

Return the length of the serialized data.

Serialize this types and write the serialized data into the given buffer. Read more

impl<T: AsRef<[u8]>> Parseable<LinkHeader> for LinkBuffer<T>
[src]

Deserialize the current type.

Auto Trait Implementations

impl Send for LinkHeader

impl Sync for LinkHeader