LinkMessageBuilder

Struct LinkMessageBuilder 

Source
pub struct LinkMessageBuilder<T> { /* private fields */ }
Expand description

Helper struct for building LinkMessage. The LinkMessageBuilder is designed for advanced user, wrapper structs/functions are created

Implementations§

Source§

impl LinkMessageBuilder<LinkBond>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for bond

Source

pub fn append_info_data(self, info: InfoBond) -> Self

Source

pub fn mode(self, mode: BondMode) -> Self

Adds the mode attribute to the bond This is equivalent to ip link add name NAME type bond mode MODE.

Source

pub fn active_port(self, active_port: u32) -> Self

Adds the active_port attribute to the bond, where active_port is the ifindex of an interface attached to the bond. This is equivalent to ip link add name NAME type bond active_slave ACTIVE_PORT_NAME.

Source

pub fn miimon(self, miimon: u32) -> Self

Adds the miimon attribute to the bond This is equivalent to ip link add name NAME type bond miimon MIIMON.

Source

pub fn updelay(self, updelay: u32) -> Self

Adds the updelay attribute to the bond This is equivalent to ip link add name NAME type bond updelay UPDELAY.

Source

pub fn downdelay(self, downdelay: u32) -> Self

Adds the downdelay attribute to the bond This is equivalent to ip link add name NAME type bond downdelay DOWNDELAY.

Source

pub fn use_carrier(self, use_carrier: u8) -> Self

Adds the use_carrier attribute to the bond This is equivalent to ip link add name NAME type bond use_carrier USE_CARRIER.

Source

pub fn arp_interval(self, arp_interval: u32) -> Self

Adds the arp_interval attribute to the bond This is equivalent to ip link add name NAME type bond arp_interval ARP_INTERVAL.

Source

pub fn arp_validate(self, arp_validate: BondArpValidate) -> Self

Adds the arp_validate attribute to the bond This is equivalent to ip link add name NAME type bond arp_validate ARP_VALIDATE.

Source

pub fn arp_all_targets(self, arp_all_targets: BondArpAllTargets) -> Self

Adds the arp_all_targets attribute to the bond This is equivalent to ip link add name NAME type bond arp_all_targets ARP_ALL_TARGETS

Source

pub fn primary(self, primary: u32) -> Self

Adds the primary attribute to the bond, where primary is the ifindex of an interface. This is equivalent to ip link add name NAME type bond primary PRIMARY_NAME

Source

pub fn primary_reselect(self, primary_reselect: BondPrimaryReselect) -> Self

Adds the primary_reselect attribute to the bond This is equivalent to ip link add name NAME type bond primary_reselect PRIMARY_RESELECT.

Source

pub fn fail_over_mac(self, fail_over_mac: BondFailOverMac) -> Self

Adds the fail_over_mac attribute to the bond This is equivalent to ip link add name NAME type bond fail_over_mac FAIL_OVER_MAC.

Source

pub fn xmit_hash_policy(self, xmit_hash_policy: BondXmitHashPolicy) -> Self

Adds the xmit_hash_policy attribute to the bond This is equivalent to ip link add name NAME type bond xmit_hash_policy XMIT_HASH_POLICY.

Source

pub fn resend_igmp(self, resend_igmp: u32) -> Self

Adds the resend_igmp attribute to the bond This is equivalent to ip link add name NAME type bond resend_igmp RESEND_IGMP.

Source

pub fn num_peer_notif(self, num_peer_notif: u8) -> Self

Adds the num_peer_notif attribute to the bond This is equivalent to ip link add name NAME type bond num_peer_notif NUM_PEER_NOTIF.

Source

pub fn all_ports_active(self, all_ports_active: u8) -> Self

Adds the all_ports_active attribute to the bond This is equivalent to ip link add name NAME type bond all_slaves_active ALL_PORTS_ACTIVE.

Adds the min_links attribute to the bond This is equivalent to ip link add name NAME type bond min_links MIN_LINKS.

Source

pub fn lp_interval(self, lp_interval: u32) -> Self

Adds the lp_interval attribute to the bond This is equivalent to ip link add name NAME type bond lp_interval LP_INTERVAL.

Source

pub fn packets_per_port(self, packets_per_port: u32) -> Self

Adds the packets_per_port attribute to the bond This is equivalent to ip link add name NAME type bond packets_per_slave PACKETS_PER_PORT.

Source

pub fn ad_lacp_rate(self, ad_lacp_rate: u8) -> Self

Adds the ad_lacp_rate attribute to the bond This is equivalent to ip link add name NAME type bond ad_lacp_rate AD_LACP_RATE.

Source

pub fn ad_select(self, ad_select: u8) -> Self

Adds the ad_select attribute to the bond This is equivalent to ip link add name NAME type bond ad_select AD_SELECT.

Source

pub fn ad_actor_sys_prio(self, ad_actor_sys_prio: u16) -> Self

Adds the ad_actor_sys_prio attribute to the bond This is equivalent to ip link add name NAME type bond ad_actor_sys_prio AD_ACTOR_SYS_PRIO.

Source

pub fn ad_user_port_key(self, ad_user_port_key: u16) -> Self

Adds the ad_user_port_key attribute to the bond This is equivalent to ip link add name NAME type bond ad_user_port_key AD_USER_PORT_KEY.

Source

pub fn ad_actor_system(self, ad_actor_system: [u8; 6]) -> Self

Adds the ad_actor_system attribute to the bond This is equivalent to ip link add name NAME type bond ad_actor_system AD_ACTOR_SYSTEM.

Source

pub fn tlb_dynamic_lb(self, tlb_dynamic_lb: u8) -> Self

Adds the tlb_dynamic_lb attribute to the bond This is equivalent to ip link add name NAME type bond tlb_dynamic_lb TLB_DYNAMIC_LB.

Source

pub fn peer_notif_delay(self, peer_notif_delay: u32) -> Self

Adds the peer_notif_delay attribute to the bond This is equivalent to ip link add name NAME type bond peer_notif_delay PEER_NOTIF_DELAY.

Source

pub fn ad_lacp_active(self, ad_lacp_active: u8) -> Self

Adds the ad_lacp_active attribute to the bond This is equivalent to ip link add name NAME type bond ad_lacp_active AD_LACP_ACTIVE.

Source

pub fn missed_max(self, missed_max: u8) -> Self

Adds the missed_max attribute to the bond This is equivalent to ip link add name NAME type bond missed_max MISSED_MAX.

Source

pub fn arp_ip_target(self, arp_ip_target: Vec<Ipv4Addr>) -> Self

Adds the arp_ip_target attribute to the bond This is equivalent to ip link add name NAME type bond arp_ip_target LIST.

Source

pub fn ns_ip6_target(self, ns_ip6_target: Vec<Ipv6Addr>) -> Self

Adds the ns_ip6_target attribute to the bond This is equivalent to ip link add name NAME type bond ns_ip6_target LIST.

Source§

impl LinkMessageBuilder<LinkBondPort>

Source

pub fn append_info_data(self, info: InfoBondPort) -> Self

Append arbitrary InfoBondPort

Source

pub fn queue_id(self, queue_id: u16) -> Self

Adds the queue_id attribute to the bond port This is equivalent to ip link set name NAME type bond_slave queue_id QUEUE_ID.

Source

pub fn prio(self, prio: i32) -> Self

Adds the prio attribute to the bond port This is equivalent to ip link set name NAME type bond_slave prio PRIO.

Source§

impl LinkMessageBuilder<LinkBridge>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for linux bridge

Source§

impl<T> LinkMessageBuilder<T>

Source

pub fn new_with_info_kind(info_kind: InfoKind) -> Self

Source

pub fn set_header(self, header: LinkHeader) -> Self

Set arbitrary LinkHeader

Source

pub fn append_extra_attribute(self, link_attr: LinkAttribute) -> Self

Append arbitrary LinkAttribute

Source

pub fn set_info_data(self, info_data: InfoData) -> Self

Set arbitrary InfoData

Source

pub fn up(self) -> Self

Set the link up (equivalent to ip link set dev DEV up)

Source

pub fn down(self) -> Self

Set the link down (equivalent to ip link set dev DEV down)

Source

pub fn promiscuous(self, enable: bool) -> Self

Enable or disable promiscious mode of the link with the given index (equivalent to ip link set dev DEV promisc on/off)

Source

pub fn arp(self, enable: bool) -> Self

Enable or disable the ARP protocol of the link with the given index (equivalent to ip link set dev DEV arp on/off)

Source

pub fn name(self, name: String) -> Self

Source

pub fn mtu(self, mtu: u32) -> Self

Set the mtu of the link with the given index (equivalent to ip link set DEV mtu MTU)

Source

pub fn index(self, index: u32) -> Self

Kernel index number of interface, used for querying, modifying or deleting existing interface.

Source

pub fn address(self, address: Vec<u8>) -> Self

Define the hardware address of the link when creating it (equivalent to ip link add NAME address ADDRESS)

Source

pub fn setns_by_pid(self, pid: u32) -> Self

Move this network device into the network namespace of the process with the given pid.

Source

pub fn setns_by_fd(self, fd: RawFd) -> Self

Move this network device into the network namespace corresponding to the given file descriptor.

The physical device to act operate on. (e.g. the parent interface of VLAN/VxLAN)

Source

pub fn controller(self, ctrl_index: u32) -> Self

Define controller interface index (similar to ip link set NAME master CONTROLLER_NAME)

Source

pub fn nocontroller(self) -> Self

Detach the link from its controller. This is equivalent to ip link set LINK nomaster. To succeed, the link that is being detached must be UP.

Source

pub fn set_port_kind(self, port_kind: InfoPortKind) -> Self

Source

pub fn set_port_data(self, port_data: InfoPortData) -> Self

Include port settings. The [LinkBondPort] and [LinkBridgePort] are the helper

Source

pub fn build(self) -> LinkMessage

Source§

impl LinkMessageBuilder<LinkUnspec>

Source

pub fn new() -> Self

Source§

impl LinkMessageBuilder<LinkDummy>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for dummy interface type

Source§

impl LinkMessageBuilder<LinkMacVlan>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for MAC VLAN

Source

pub fn append_info_data(self, info: InfoMacVlan) -> Self

Source

pub fn mode(self, mode: MacVlanMode) -> Self

Source§

impl LinkMessageBuilder<LinkMacVtap>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for Mac VTAP interface

Source

pub fn append_info_data(self, info: InfoMacVtap) -> Self

Source

pub fn mode(self, mode: MacVtapMode) -> Self

Source§

impl LinkMessageBuilder<LinkMacSec>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for MACSEC

Source

pub fn append_info_data(self, info: InfoMacSec) -> Self

Source

pub fn sci(self, sci: u64) -> Self

Source

pub fn port(self, port: u16) -> Self

Source

pub fn icv_len(self, icv_len: u8) -> Self

Source

pub fn cipher_suite(self, cipher_suite: MacSecCipherId) -> Self

Source

pub fn window(self, window: u32) -> Self

Source

pub fn encoding_sa(self, encoding_sa: u8) -> Self

Source

pub fn encrypt(self, encrypt: bool) -> Self

Source

pub fn protect(self, protect: bool) -> Self

Source

pub fn inc_sci(self, inc_sci: bool) -> Self

Source

pub fn es(self, es: bool) -> Self

Source

pub fn scb(self, scb: bool) -> Self

Source

pub fn replay_protect(self, replay_protect: bool) -> Self

Source

pub fn validation(self, validation: MacSecValidate) -> Self

Source

pub fn offload(self, offload: MacSecOffload) -> Self

Source

pub fn other(self, other: DefaultNla) -> Self

Source§

impl LinkMessageBuilder<LinkVeth>

Source

pub fn new(name: &str, peer: &str) -> Self

Create LinkMessageBuilder for VETH

Source

pub fn peer(self, peer: &str) -> Self

Source§

impl LinkMessageBuilder<LinkVlan>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for VLAN

Source

pub fn append_info_data(self, info: InfoVlan) -> Self

Source

pub fn id(self, vlan_id: u16) -> Self

VLAN ID

Source

pub fn qos<I, E>(self, ingress_qos: I, egress_qos: E) -> Self
where I: IntoIterator<Item = QosMapping>, E: IntoIterator<Item = QosMapping>,

ingress QoS and egress QoS

Source§

impl LinkMessageBuilder<LinkVrf>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for VRF

Source

pub fn append_info_data(self, info: InfoVrf) -> Self

Source

pub fn table_id(self, table_id: u32) -> Self

VRF table ID

Source§

impl LinkMessageBuilder<LinkVxlan>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for VLAN

Source

pub fn append_info_data(self, info: InfoVxlan) -> Self

Source

pub fn id(self, id: u32) -> Self

VNI

Source

pub fn dev(self, index: u32) -> Self

This is equivalent to devPHYS_DEV for ip link vxlan. Adds the dev attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI dev LINK, dev LINK - specifies the physical device to use for tunnel endpoint communication. But instead of specifing a link name (LINK), we specify a link index. Please be aware the LinkMessageBuilder::link() will not works for VxLAN.

Source

pub fn port(self, port: u16) -> Self

Adds the dstport attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI dstport PORT. dstport PORT - specifies the UDP destination port to communicate to the remote VXLAN tunnel endpoint.

Source

pub fn group(self, addr: Ipv4Addr) -> Self

Adds the group attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI group IPADDR, group IPADDR - specifies the multicast IP address to join. This function takes an IPv4 address WARNING: only one between remote and group can be present.

Source

pub fn group6(self, addr: Ipv6Addr) -> Self

Adds the group attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI group IPADDR, group IPADDR - specifies the multicast IP address to join. This function takes an IPv6 address WARNING: only one between remote and group can be present.

Source

pub fn remote(self, addr: Ipv4Addr) -> Self

Adds the remote attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI remote IPADDR, remote IPADDR - specifies the unicast destination IP address to use in outgoing packets when the destination link layer address is not known in the VXLAN device forwarding database. This function takes an IPv4 address. WARNING: only one between remote and group can be present.

Source

pub fn remote6(self, addr: Ipv6Addr) -> Self

Adds the remote attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI remote IPADDR, remote IPADDR - specifies the unicast destination IP address to use in outgoing packets when the destination link layer address is not known in the VXLAN device forwarding database. This function takes an IPv6 address. WARNING: only one between remote and group can be present.

Source

pub fn local(self, addr: Ipv4Addr) -> Self

Adds the local attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI local IPADDR, local IPADDR - specifies the source IP address to use in outgoing packets. This function takes an IPv4 address.

Source

pub fn local6(self, addr: Ipv6Addr) -> Self

Adds the local attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI local IPADDR, local IPADDR - specifies the source IP address to use in outgoing packets. This function takes an IPv6 address.

Source

pub fn tos(self, tos: u8) -> Self

Adds the tos attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI tos TOS. tos TOS - specifies the TOS value to use in outgoing packets.

Source

pub fn ttl(self, ttl: u8) -> Self

Adds the ttl attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI ttl TTL. ttl TTL - specifies the TTL value to use in outgoing packets.

Source

pub fn label(self, label: u32) -> Self

Adds the flowlabel attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI flowlabel LABEL. flowlabel LABEL - specifies the flow label to use in outgoing packets.

Source

pub fn learning(self, learning: bool) -> Self

Adds the learning attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI \[no\]learning. [no]learning - specifies if unknown source link layer addresses and IP addresses are entered into the VXLAN device forwarding database.

Source

pub fn ageing(self, seconds: u32) -> Self

Adds the ageing attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI ageing SECONDS. ageing SECONDS - specifies the lifetime in seconds of FDB entries learnt by the kernel.

Source

pub fn limit(self, limit: u32) -> Self

Adds the maxaddress attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI maxaddress LIMIT. maxaddress LIMIT - specifies the maximum number of FDB entries.

Source

pub fn port_range(self, min: u16, max: u16) -> Self

Adds the srcport attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI srcport MIN MAX. srcport MIN MAX - specifies the range of port numbers to use as UDP source ports to communicate to the remote VXLAN tunnel endpoint.

Source

pub fn proxy(self, proxy: bool) -> Self

Adds the proxy attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI [no]proxy. [no]proxy - specifies ARP proxy is turned on.

Source

pub fn rsc(self, rsc: bool) -> Self

Adds the rsc attribute to the VXLAN This is equivalent to ip link add name NAME type vxlan id VNI [no]rsc. [no]rsc - specifies if route short circuit is turned on.

Source

pub fn l2miss(self, l2miss: bool) -> Self

This is equivalent to ip link add name NAME type vxlan id VNI [no]l2miss. [no]l2miss - specifies if netlink LLADDR miss notifications are generated.

Source

pub fn l3miss(self, l3miss: bool) -> Self

This is equivalent to ip link add name NAME type vxlan id VNI [no]l3miss. [no]l3miss - specifies if netlink IP ADDR miss notifications are generated.

Source

pub fn collect_metadata(self, collect_metadata: bool) -> Self

Source

pub fn udp_csum(self, udp_csum: bool) -> Self

This is equivalent to ip link add name NAME type vxlan id VNI [no]udp_csum. [no]udpcsum - specifies if UDP checksum is calculated for transmitted packets over IPv4.

Source§

impl LinkMessageBuilder<LinkWireguard>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for wireguard

Source§

impl LinkMessageBuilder<LinkXfrm>

Source

pub fn new(name: &str) -> Self

Create LinkMessageBuilder for XFRM

Source

pub fn append_info_data(self, info: InfoXfrm) -> Self

Source

pub fn if_id(self, if_id: u32) -> Self

This is equivalent to the if_id IF_ID in command ip link add name NAME type xfrm if_id IF_ID.

Source

pub fn dev(self, iface_index: u32) -> Self

This is equivalent to the dev PHYS_DEV in command ip link add name NAME type xfm dev PHYS_DEV, only take the interface index.

Trait Implementations§

Source§

impl<T: Debug> Debug for LinkMessageBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for LinkMessageBuilder<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for LinkMessageBuilder<T>

§

impl<T> RefUnwindSafe for LinkMessageBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for LinkMessageBuilder<T>
where T: Send,

§

impl<T> Sync for LinkMessageBuilder<T>
where T: Sync,

§

impl<T> Unpin for LinkMessageBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for LinkMessageBuilder<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.