tap is ok

This commit is contained in:
asxalex 2024-10-22 21:05:46 +08:00
parent c130dcc83e
commit 1a5e1d8be3
3 changed files with 12 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
.client .client
.output .output
sdlan sdlan
sdlan.exe

View File

@ -742,6 +742,7 @@ async fn handle_tun_packet(
return; return;
} }
let data = origin.unwrap(); let data = origin.unwrap();
debug!("ether size is {}", data.len());
let msg_size = data.len() as u64; let msg_size = data.len() as u64;
let Ok(dst_mac) = pkt.dst_mac.try_into() else { let Ok(dst_mac) = pkt.dst_mac.try_into() else {
@ -766,8 +767,10 @@ async fn handle_tun_packet(
debug!("got packet from sock, will send to tun"); debug!("got packet from sock, will send to tun");
match Ethernet2Header::from_slice(&data) { match Ethernet2Header::from_slice(&data) {
Ok((hdr, rest)) => { Ok((hdr, rest)) => {
debug!("ip size is {}", rest.len());
let edge = get_edge(); let edge = get_edge();
let self_mac = edge.device_config.get_mac(); let self_mac = edge.device_config.get_mac();
/* /*
if hdr.destination != self_mac && hdr.destination != BROADCAST_MAC { if hdr.destination != self_mac && hdr.destination != BROADCAST_MAC {
error!( error!(
@ -860,7 +863,14 @@ async fn handle_tun_packet(
} else { } else {
println!("got ip packet"); println!("got ip packet");
println!("got data: {:?}", rest); println!("got data: {:?}", rest);
edge.device.send(rest); match edge.device.send(rest) {
Ok(size) => {
debug!("send to tun {} bytes", size);
}
Err(e) => {
error!("failed to send to device");
}
}
// edge.tun.send_data_to_tun(Vec::from(hdr.1)).await; // edge.tun.send_data_to_tun(Vec::from(hdr.1)).await;
} }
} }

BIN
wintun.dll Normal file

Binary file not shown.