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>
impl LinkMessageBuilder<LinkBond>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for bond
pub fn append_info_data(self, info: InfoBond) -> Self
Sourcepub fn mode(self, mode: BondMode) -> Self
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.
Sourcepub fn active_port(self, active_port: u32) -> Self
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.
Sourcepub fn miimon(self, miimon: u32) -> Self
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.
Sourcepub fn updelay(self, updelay: u32) -> Self
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.
Sourcepub fn downdelay(self, downdelay: u32) -> Self
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.
Sourcepub fn use_carrier(self, use_carrier: u8) -> Self
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.
Sourcepub fn arp_interval(self, arp_interval: u32) -> Self
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.
Sourcepub fn arp_validate(self, arp_validate: BondArpValidate) -> Self
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.
Sourcepub fn arp_all_targets(self, arp_all_targets: BondArpAllTargets) -> Self
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
Sourcepub fn primary(self, primary: u32) -> Self
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
Sourcepub fn primary_reselect(self, primary_reselect: BondPrimaryReselect) -> Self
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.
Sourcepub fn fail_over_mac(self, fail_over_mac: BondFailOverMac) -> Self
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.
Sourcepub fn xmit_hash_policy(self, xmit_hash_policy: BondXmitHashPolicy) -> Self
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.
Sourcepub fn resend_igmp(self, resend_igmp: u32) -> Self
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.
Sourcepub fn num_peer_notif(self, num_peer_notif: u8) -> Self
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.
Sourcepub fn all_ports_active(self, all_ports_active: u8) -> Self
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.
Sourcepub fn min_links(self, min_links: u32) -> Self
pub fn min_links(self, min_links: u32) -> Self
Adds the min_links attribute to the bond
This is equivalent to ip link add name NAME type bond min_links MIN_LINKS.
Sourcepub fn lp_interval(self, lp_interval: u32) -> Self
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.
Sourcepub fn packets_per_port(self, packets_per_port: u32) -> Self
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.
Sourcepub fn ad_lacp_rate(self, ad_lacp_rate: u8) -> Self
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.
Sourcepub fn ad_select(self, ad_select: u8) -> Self
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.
Sourcepub fn ad_actor_sys_prio(self, ad_actor_sys_prio: u16) -> Self
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.
Sourcepub fn ad_user_port_key(self, ad_user_port_key: u16) -> Self
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.
Sourcepub fn ad_actor_system(self, ad_actor_system: [u8; 6]) -> Self
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.
Sourcepub fn tlb_dynamic_lb(self, tlb_dynamic_lb: u8) -> Self
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.
Sourcepub fn peer_notif_delay(self, peer_notif_delay: u32) -> Self
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.
Sourcepub fn ad_lacp_active(self, ad_lacp_active: u8) -> Self
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.
Sourcepub fn missed_max(self, missed_max: u8) -> Self
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.
Sourcepub fn arp_ip_target(self, arp_ip_target: Vec<Ipv4Addr>) -> Self
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.
Sourcepub fn ns_ip6_target(self, ns_ip6_target: Vec<Ipv6Addr>) -> Self
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>
impl LinkMessageBuilder<LinkBondPort>
Sourcepub fn append_info_data(self, info: InfoBondPort) -> Self
pub fn append_info_data(self, info: InfoBondPort) -> Self
Append arbitrary InfoBondPort
Source§impl LinkMessageBuilder<LinkBridge>
impl LinkMessageBuilder<LinkBridge>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for linux bridge
Source§impl<T> LinkMessageBuilder<T>
impl<T> LinkMessageBuilder<T>
pub fn new_with_info_kind(info_kind: InfoKind) -> Self
Sourcepub fn set_header(self, header: LinkHeader) -> Self
pub fn set_header(self, header: LinkHeader) -> Self
Set arbitrary LinkHeader
Sourcepub fn append_extra_attribute(self, link_attr: LinkAttribute) -> Self
pub fn append_extra_attribute(self, link_attr: LinkAttribute) -> Self
Append arbitrary LinkAttribute
Sourcepub fn set_info_data(self, info_data: InfoData) -> Self
pub fn set_info_data(self, info_data: InfoData) -> Self
Set arbitrary InfoData
Sourcepub fn promiscuous(self, enable: bool) -> Self
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)
Sourcepub fn arp(self, enable: bool) -> Self
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)
pub fn name(self, name: String) -> Self
Sourcepub fn mtu(self, mtu: u32) -> Self
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)
Sourcepub fn index(self, index: u32) -> Self
pub fn index(self, index: u32) -> Self
Kernel index number of interface, used for querying, modifying or deleting existing interface.
Sourcepub fn address(self, address: Vec<u8>) -> Self
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)
Sourcepub fn setns_by_pid(self, pid: u32) -> Self
pub fn setns_by_pid(self, pid: u32) -> Self
Move this network device into the network namespace of the process with
the given pid.
Sourcepub fn setns_by_fd(self, fd: RawFd) -> Self
pub fn setns_by_fd(self, fd: RawFd) -> Self
Move this network device into the network namespace corresponding to the given file descriptor.
Sourcepub fn link(self, index: u32) -> Self
pub fn link(self, index: u32) -> Self
The physical device to act operate on. (e.g. the parent interface of VLAN/VxLAN)
Sourcepub fn controller(self, ctrl_index: u32) -> Self
pub fn controller(self, ctrl_index: u32) -> Self
Define controller interface index (similar to ip link set NAME master CONTROLLER_NAME)
Sourcepub fn nocontroller(self) -> Self
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.
pub fn set_port_kind(self, port_kind: InfoPortKind) -> Self
Sourcepub fn set_port_data(self, port_data: InfoPortData) -> Self
pub fn set_port_data(self, port_data: InfoPortData) -> Self
Include port settings. The [LinkBondPort] and [LinkBridgePort] are the helper
pub fn build(self) -> LinkMessage
Source§impl LinkMessageBuilder<LinkDummy>
impl LinkMessageBuilder<LinkDummy>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for dummy interface type
Source§impl LinkMessageBuilder<LinkMacVlan>
impl LinkMessageBuilder<LinkMacVlan>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for MAC VLAN
pub fn append_info_data(self, info: InfoMacVlan) -> Self
pub fn mode(self, mode: MacVlanMode) -> Self
Source§impl LinkMessageBuilder<LinkMacVtap>
impl LinkMessageBuilder<LinkMacVtap>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for Mac VTAP interface
pub fn append_info_data(self, info: InfoMacVtap) -> Self
pub fn mode(self, mode: MacVtapMode) -> Self
Source§impl LinkMessageBuilder<LinkMacSec>
impl LinkMessageBuilder<LinkMacSec>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for MACSEC
pub fn append_info_data(self, info: InfoMacSec) -> Self
pub fn sci(self, sci: u64) -> Self
pub fn port(self, port: u16) -> Self
pub fn icv_len(self, icv_len: u8) -> Self
pub fn cipher_suite(self, cipher_suite: MacSecCipherId) -> Self
pub fn window(self, window: u32) -> Self
pub fn encoding_sa(self, encoding_sa: u8) -> Self
pub fn encrypt(self, encrypt: bool) -> Self
pub fn protect(self, protect: bool) -> Self
pub fn inc_sci(self, inc_sci: bool) -> Self
pub fn es(self, es: bool) -> Self
pub fn scb(self, scb: bool) -> Self
pub fn replay_protect(self, replay_protect: bool) -> Self
pub fn validation(self, validation: MacSecValidate) -> Self
pub fn offload(self, offload: MacSecOffload) -> Self
pub fn other(self, other: DefaultNla) -> Self
Source§impl LinkMessageBuilder<LinkVlan>
impl LinkMessageBuilder<LinkVlan>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for VLAN
pub fn append_info_data(self, info: InfoVlan) -> Self
Source§impl LinkMessageBuilder<LinkVrf>
impl LinkMessageBuilder<LinkVrf>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for VRF
pub fn append_info_data(self, info: InfoVrf) -> Self
Source§impl LinkMessageBuilder<LinkVxlan>
impl LinkMessageBuilder<LinkVxlan>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for VLAN
pub fn append_info_data(self, info: InfoVxlan) -> Self
Sourcepub fn dev(self, index: u32) -> Self
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.
Sourcepub fn port(self, port: u16) -> Self
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.
Sourcepub fn group(self, addr: Ipv4Addr) -> Self
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.
Sourcepub fn group6(self, addr: Ipv6Addr) -> Self
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.
Sourcepub fn remote(self, addr: Ipv4Addr) -> Self
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.
Sourcepub fn remote6(self, addr: Ipv6Addr) -> Self
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.
Sourcepub fn local(self, addr: Ipv4Addr) -> Self
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.
Sourcepub fn local6(self, addr: Ipv6Addr) -> Self
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.
Sourcepub fn tos(self, tos: u8) -> Self
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.
Sourcepub fn ttl(self, ttl: u8) -> Self
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.
Sourcepub fn label(self, label: u32) -> Self
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.
Sourcepub fn learning(self, learning: bool) -> Self
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.
Sourcepub fn ageing(self, seconds: u32) -> Self
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.
Sourcepub fn limit(self, limit: u32) -> Self
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.
Sourcepub fn port_range(self, min: u16, max: u16) -> Self
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.
Sourcepub fn proxy(self, proxy: bool) -> Self
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.
Sourcepub fn rsc(self, rsc: bool) -> Self
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.
Sourcepub fn l2miss(self, l2miss: bool) -> Self
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.
Sourcepub fn l3miss(self, l3miss: bool) -> Self
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.
pub fn collect_metadata(self, collect_metadata: bool) -> Self
Source§impl LinkMessageBuilder<LinkWireguard>
impl LinkMessageBuilder<LinkWireguard>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for wireguard
Source§impl LinkMessageBuilder<LinkXfrm>
impl LinkMessageBuilder<LinkXfrm>
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create LinkMessageBuilder for XFRM