Struct iproute2::LinkAddRequest [−][src]
pub struct LinkAddRequest { /* fields omitted */ }
A request to create a new link. This is equivalent to the ip link add
commands.
A few methods for common actions (creating a veth pair, creating a vlan interface, etc.) are
provided, but custom requests can be made using the message_mut()
accessor.
Methods
impl LinkAddRequest
[src]
impl LinkAddRequest
pub fn execute(
self
) -> impl Future<Item = (), Error = NetlinkIpError>
[src]
pub fn execute(
self
) -> impl Future<Item = (), Error = NetlinkIpError>
Execute the request.
pub fn message_mut(&mut self) -> &mut LinkMessage
[src]
pub fn message_mut(&mut self) -> &mut LinkMessage
Return a mutable reference to the request message.
Example
Let's say we want to create a vlan interface on a link with id 6. By default, the
vlan()
method would create a request with the IFF_UP
link set, so that the
interface is up after creation. If we want to create a interface tha tis down by default we
could do:
extern crate futures; extern crate iproute2; extern crate tokio_core; use std::thread::spawn; use futures::Future; use tokio_core::reactor::Core; use iproute2::new_connection; fn main() { let (connection, handle) = new_connection().unwrap(); spawn(move || Core::new().unwrap().run(connection)); let vlan_id = 100; let link_id = 6; let mut request = handle.link().add().vlan("my-vlan-itf".into(), link_id, vlan_id); // unset the IFF_UP flag before sending the request request.message_mut().header_mut().flags_mut().unset_up(); request.message_mut().header_mut().change_mask_mut().unset_up(); // send the request request.execute().wait().unwrap(); }
pub fn dummy(self, name: String) -> Self
[src]
pub fn dummy(self, name: String) -> Self
Create a dummy link.
This is equivalent to ip link add NAME type dummy
.
pub fn veth(self, name: String, peer_name: String) -> Self
[src]
pub fn veth(self, name: String, peer_name: String) -> Self
Create a veth pair.
kThis is equivalent to ip link add NAME1 type veth peer name NAME2
.
pub fn vlan(self, name: String, index: u32, vlan_id: u16) -> Self
[src]
pub fn vlan(self, name: String, index: u32, vlan_id: u16) -> Self
Create VLAN on a link.
This is equivalent to ip link add link LINK name NAME type vlan id VLAN_ID
,
but instead of specifying a link name (LINK
), we specify a link index.
Auto Trait Implementations
impl Send for LinkAddRequest
impl Send for LinkAddRequest
impl Sync for LinkAddRequest
impl Sync for LinkAddRequest