-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
link: ipvtap: support ipvtap mod. ipvtap is alias to ipvlan mode.
Signed-off-by: xujunjie-cover <[email protected]>
- Loading branch information
1 parent
396d4b0
commit a8d125c
Showing
7 changed files
with
138 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
use netlink_packet_utils::{Emitable, Parseable}; | ||
|
||
use crate::link::link_flag::LinkFlags; | ||
use crate::link::{ | ||
InfoData, InfoIpVtap, InfoKind, IpVtapMode, LinkAttribute, LinkHeader, | ||
LinkInfo, LinkLayerType, LinkMessage, LinkMessageBuffer, | ||
}; | ||
use crate::AddressFamily; | ||
|
||
#[test] | ||
fn test_ipvtap_link_info() { | ||
let raw: Vec<u8> = vec![ | ||
0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x12, 0x00, 0x0b, 0x00, 0x01, 0x00, | ||
0x69, 0x70, 0x76, 0x74, 0x61, 0x70, 0x00, 0x00, 0x14, 0x00, 0x02, 0x00, | ||
0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, | ||
0x02, 0x00, 0x00, 0x00, | ||
]; | ||
|
||
let expected = LinkMessage { | ||
header: LinkHeader { | ||
interface_family: AddressFamily::Unspec, | ||
index: 18, | ||
link_layer_type: LinkLayerType::Ether, | ||
flags: LinkFlags::Broadcast | LinkFlags::Multicast, | ||
change_mask: LinkFlags::empty(), | ||
}, | ||
attributes: vec![LinkAttribute::LinkInfo(vec![ | ||
LinkInfo::Kind(InfoKind::IpVtap), | ||
LinkInfo::Data(InfoData::IpVtap(vec![ | ||
InfoIpVtap::Mode(IpVtapMode::L2), | ||
InfoIpVtap::Flags(2), | ||
])), | ||
])], | ||
}; | ||
|
||
assert_eq!( | ||
expected, | ||
LinkMessage::parse(&LinkMessageBuffer::new(&raw)).unwrap() | ||
); | ||
|
||
let mut buf = vec![0; expected.buffer_len()]; | ||
|
||
expected.emit(&mut buf); | ||
|
||
assert_eq!(buf, raw); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters