@@ -4,8 +4,8 @@ use netlink_packet_utils::{Emitable, Parseable};
44
55use crate :: link:: link_flag:: LinkFlags ;
66use crate :: link:: {
7- InfoData , InfoIpVlan , InfoKind , IpVlanMode , LinkAttribute , LinkHeader ,
8- LinkInfo , LinkLayerType , LinkMessage , LinkMessageBuffer ,
7+ InfoData , InfoIpVlan , InfoKind , IpVlanFlags , IpVlanMode , LinkAttribute ,
8+ LinkHeader , LinkInfo , LinkLayerType , LinkMessage , LinkMessageBuffer ,
99} ;
1010use crate :: AddressFamily ;
1111
@@ -31,7 +31,46 @@ fn test_ipvlan_link_info() {
3131 LinkInfo :: Kind ( InfoKind :: IpVlan ) ,
3232 LinkInfo :: Data ( InfoData :: IpVlan ( vec![
3333 InfoIpVlan :: Mode ( IpVlanMode :: L2 ) ,
34- InfoIpVlan :: Flags ( 2 ) ,
34+ InfoIpVlan :: Flags ( IpVlanFlags :: VEPA ) ,
35+ ] ) ) ,
36+ ] ) ] ,
37+ } ;
38+
39+ assert_eq ! (
40+ expected,
41+ LinkMessage :: parse( & LinkMessageBuffer :: new( & raw) ) . unwrap( )
42+ ) ;
43+
44+ let mut buf = vec ! [ 0 ; expected. buffer_len( ) ] ;
45+
46+ expected. emit ( & mut buf) ;
47+
48+ assert_eq ! ( buf, raw) ;
49+ }
50+
51+ #[ test]
52+ fn test_ipvlan_bridge_link_info ( ) {
53+ let raw: Vec < u8 > = vec ! [
54+ 0x00 , 0x00 , 0x01 , 0x00 , 0x12 , 0x00 , 0x00 , 0x00 , 0x02 , 0x10 , 0x00 , 0x00 ,
55+ 0x00 , 0x00 , 0x00 , 0x00 , 0x24 , 0x00 , 0x12 , 0x00 , 0x0b , 0x00 , 0x01 , 0x00 ,
56+ 0x69 , 0x70 , 0x76 , 0x6c , 0x61 , 0x6e , 0x00 , 0x00 , 0x14 , 0x00 , 0x02 , 0x00 ,
57+ 0x06 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x06 , 0x00 , 0x02 , 0x00 ,
58+ 0x00 , 0x00 , 0x00 , 0x00 ,
59+ ] ;
60+
61+ let expected = LinkMessage {
62+ header : LinkHeader {
63+ interface_family : AddressFamily :: Unspec ,
64+ index : 18 ,
65+ link_layer_type : LinkLayerType :: Ether ,
66+ flags : LinkFlags :: Broadcast | LinkFlags :: Multicast ,
67+ change_mask : LinkFlags :: empty ( ) ,
68+ } ,
69+ attributes : vec ! [ LinkAttribute :: LinkInfo ( vec![
70+ LinkInfo :: Kind ( InfoKind :: IpVlan ) ,
71+ LinkInfo :: Data ( InfoData :: IpVlan ( vec![
72+ InfoIpVlan :: Mode ( IpVlanMode :: L2 ) ,
73+ InfoIpVlan :: Flags ( IpVlanFlags :: default ( ) ) ,
3574 ] ) ) ,
3675 ] ) ] ,
3776 } ;
0 commit comments