@@ -13,9 +13,10 @@ use netlink_packet_core::{
1313
1414use netlink_packet_route:: {
1515 link:: {
16- InfoBond , InfoData , InfoKind , InfoMacVlan , InfoMacVtap , InfoVeth ,
17- InfoVlan , InfoVrf , InfoVxlan , InfoXfrm , LinkAttribute , LinkFlag ,
18- LinkInfo , LinkMessage , VlanQosMapping ,
16+ BondMode , InfoBond , InfoData , InfoKind , InfoMacVlan , InfoMacVtap ,
17+ InfoVeth , InfoVlan , InfoVrf , InfoVxlan , InfoXfrm , LinkAttribute ,
18+ LinkFlags , LinkInfo , LinkMessage , MacVlanMode , MacVtapMode ,
19+ VlanQosMapping ,
1920 } ,
2021 RouteNetlinkMessage ,
2122} ;
@@ -45,7 +46,7 @@ impl BondAddRequest {
4546
4647 /// Adds the `mode` attribute to the bond
4748 /// This is equivalent to `ip link add name NAME type bond mode MODE`.
48- pub fn mode ( mut self , mode : u8 ) -> Self {
49+ pub fn mode ( mut self , mode : BondMode ) -> Self {
4950 self . info_data . push ( InfoBond :: Mode ( mode) ) ;
5051 self
5152 }
@@ -442,7 +443,7 @@ impl VxlanAddRequest {
442443
443444 /// Adds the `learning` attribute to the VXLAN
444445 /// This is equivalent to `ip link add name NAME type vxlan id VNI
445- /// [no]learning`. [no]learning - specifies if unknown source link layer
446+ /// \ [no\ ]learning`. \ [no\ ]learning - specifies if unknown source link layer
446447 /// addresses and IP addresses are entered into the VXLAN
447448 /// device forwarding database.
448449 pub fn learning ( mut self , learning : bool ) -> Self {
@@ -480,23 +481,23 @@ impl VxlanAddRequest {
480481
481482 /// Adds the `proxy` attribute to the VXLAN
482483 /// This is equivalent to `ip link add name NAME type vxlan id VNI
483- /// [no]proxy`. [no]proxy - specifies ARP proxy is turned on.
484+ /// [no]proxy`. \ [no\ ]proxy - specifies ARP proxy is turned on.
484485 pub fn proxy ( mut self , proxy : bool ) -> Self {
485486 self . info_data . push ( InfoVxlan :: Proxy ( proxy) ) ;
486487 self
487488 }
488489
489- /// Adds the `rsc` attribute to the VXLAN
490- /// This is equivalent to `ip link add name NAME type vxlan id VNI [no]rsc`.
491- /// [no]rsc - specifies if route short circuit is turned on.
490+ /// Adds the `rsc` attribute to the VXLAN This is equivalent to
491+ /// `ip link add name NAME type vxlan id VNI [no]rsc`.
492+ /// \ [no\ ]rsc - specifies if route short circuit is turned on.
492493 pub fn rsc ( mut self , rsc : bool ) -> Self {
493494 self . info_data . push ( InfoVxlan :: Rsc ( rsc) ) ;
494495 self
495496 }
496497
497498 // Adds the `l2miss` attribute to the VXLAN
498499 /// This is equivalent to `ip link add name NAME type vxlan id VNI
499- /// [no]l2miss`. [no]l2miss - specifies if netlink LLADDR miss
500+ /// [no]l2miss`. \ [no\ ]l2miss - specifies if netlink LLADDR miss
500501 /// notifications are generated.
501502 pub fn l2miss ( mut self , l2miss : bool ) -> Self {
502503 self . info_data . push ( InfoVxlan :: L2Miss ( l2miss) ) ;
@@ -505,8 +506,8 @@ impl VxlanAddRequest {
505506
506507 // Adds the `l3miss` attribute to the VXLAN
507508 /// This is equivalent to `ip link add name NAME type vxlan id VNI
508- /// [no]l3miss`. [no]l3miss - specifies if netlink IP ADDR miss
509- /// notifications are generated.
509+ /// [no]l3miss`. \ [no\ ]l3miss - specifies if netlink IP ADDR
510+ /// miss notifications are generated.
510511 pub fn l3miss ( mut self , l3miss : bool ) -> Self {
511512 self . info_data . push ( InfoVxlan :: L3Miss ( l3miss) ) ;
512513 self
@@ -520,8 +521,8 @@ impl VxlanAddRequest {
520521
521522 // Adds the `udp_csum` attribute to the VXLAN
522523 /// This is equivalent to `ip link add name NAME type vxlan id VNI
523- /// [no]udp_csum`. [no]udpcsum - specifies if UDP checksum is calculated
524- /// for transmitted packets over IPv4.
524+ /// [no]udp_csum`. \ [no\ ]udpcsum - specifies if UDP checksum is
525+ /// calculated for transmitted packets over IPv4.
525526 pub fn udp_csum ( mut self , udp_csum : bool ) -> Self {
526527 self . info_data . push ( InfoVxlan :: UDPCsum ( udp_csum) ) ;
527528 self
@@ -588,23 +589,22 @@ impl LinkAddRequest {
588589 ///
589590 /// Let's say we want to create a vlan interface on a link with id 6. By
590591 /// default, the [`vlan()`](#method.vlan) method would create a request
591- /// with the `LinkFlag ::Up` link set, so that the interface is up after
592+ /// with the `LinkFlags ::Up` link set, so that the interface is up after
592593 /// creation. If we want to create a interface that is down by default we
593594 /// could do:
594595 ///
595596 /// ```rust,no_run
596597 /// use futures::Future;
597- /// use netlink_packet_route::link::LinkFlag ;
598+ /// use netlink_packet_route::link::LinkFlags ;
598599 /// use rtnetlink::{Handle, new_connection};
599600 ///
600601 /// async fn run(handle: Handle) -> Result<(), String> {
601602 /// let vlan_id = 100;
602603 /// let link_id = 6;
603604 /// let mut request = handle.link().add().vlan("my-vlan-itf".into(),
604605 /// link_id, vlan_id);
605- /// request.message_mut().header.flags.push(LinkFlag::Up);
606- /// request.message_mut().header.change_mask.retain(
607- /// |f| *f != LinkFlag::Up);
606+ /// request.message_mut().header.flags.remove(LinkFlags::Up);
607+ /// request.message_mut().header.change_mask.remove(LinkFlags::Up);
608608 /// // send the request
609609 /// request.execute().await.map_err(|e| format!("{}", e))
610610 /// }
@@ -628,8 +628,8 @@ impl LinkAddRequest {
628628
629629 let mut peer = LinkMessage :: default ( ) ;
630630 // FIXME: we get a -107 (ENOTCONN) (???) when trying to set `name` up.
631- // peer.header.flags.push(LinkFlag ::Up) ;
632- // peer.header.change_mask.push( LinkFlag::Up) ;
631+ // peer.header.flags |= LinkFlags ::Up;
632+ // peer.header.change_mask |= LinkFlag::Up;
633633 peer. attributes . push ( LinkAttribute :: IfName ( name) ) ;
634634 let link_info_data = InfoData :: Veth ( InfoVeth :: Peer ( peer) ) ;
635635 self . name ( peer_name)
@@ -687,7 +687,7 @@ impl LinkAddRequest {
687687 /// flags from MACVLAN_MODE (netlink-packet-route/src/rtnl/constants.rs)
688688 /// being: _PRIVATE, _VEPA, _BRIDGE, _PASSTHRU, _SOURCE, which can be
689689 /// *combined*.
690- pub fn macvlan ( self , name : String , index : u32 , mode : u32 ) -> Self {
690+ pub fn macvlan ( self , name : String , index : u32 , mode : MacVlanMode ) -> Self {
691691 self . name ( name)
692692 . link_info (
693693 InfoKind :: MacVlan ,
@@ -704,7 +704,7 @@ impl LinkAddRequest {
704704 /// flags from MACVTAP_MODE (netlink-packet-route/src/rtnl/constants.rs)
705705 /// being: _PRIVATE, _VEPA, _BRIDGE, _PASSTHRU, _SOURCE, which can be
706706 /// *combined*.
707- pub fn macvtap ( self , name : String , index : u32 , mode : u32 ) -> Self {
707+ pub fn macvtap ( self , name : String , index : u32 , mode : MacVtapMode ) -> Self {
708708 self . name ( name)
709709 . link_info (
710710 InfoKind :: MacVtap ,
@@ -779,11 +779,7 @@ impl LinkAddRequest {
779779 /// This is equivalent to `ip link add NAME type wireguard`.
780780 pub fn wireguard ( self , name : String ) -> Self {
781781 let mut request = self . name ( name) . link_info ( InfoKind :: Wireguard , None ) ;
782- request
783- . message_mut ( )
784- . header
785- . flags
786- . retain ( |f| * f != LinkFlag :: Up ) ;
782+ request. message_mut ( ) . header . flags . remove ( LinkFlags :: Up ) ;
787783 request
788784 }
789785
@@ -805,8 +801,8 @@ impl LinkAddRequest {
805801 }
806802
807803 fn up ( mut self ) -> Self {
808- self . message . header . flags . push ( LinkFlag :: Up ) ;
809- self . message . header . change_mask . push ( LinkFlag :: Up ) ;
804+ self . message . header . flags |= LinkFlags :: Up ;
805+ self . message . header . change_mask |= LinkFlags :: Up ;
810806 self
811807 }
812808
0 commit comments