changed arp
This commit is contained in:
parent
302300294a
commit
3e4fe82a59
@ -629,7 +629,7 @@ async fn edge_send_packet_to_net(eee: &Node, data: &[u8]) {
|
||||
if do_arp_request {
|
||||
println!(
|
||||
"find ip: {:?} => {:?}",
|
||||
ip.to_be_bytes(),
|
||||
src.to_be_bytes(),
|
||||
dstip.to_be_bytes()
|
||||
);
|
||||
let arp_msg = generate_arp_request(src_mac, ip, eee.device_config.get_ip());
|
||||
@ -648,6 +648,7 @@ async fn edge_send_packet_to_net(eee: &Node, data: &[u8]) {
|
||||
};
|
||||
let data =
|
||||
encode_to_udp_message(Some(data), PacketType::Data as u8).unwrap();
|
||||
debug!("sending arp");
|
||||
// let data = marshal_message(&data);
|
||||
send_packet_to_net(eee, BROADCAST_MAC, &data, arp_msg.len() as u64).await;
|
||||
// edge.sock.send(data).await;
|
||||
@ -697,7 +698,7 @@ async fn edge_send_packet_to_net(eee: &Node, data: &[u8]) {
|
||||
}
|
||||
}
|
||||
|
||||
async fn send_packet_to_net(eee: &Node, dst_mac: Mac, pkt: &[u8], size: u64) {
|
||||
pub async fn send_packet_to_net(eee: &Node, dst_mac: Mac, pkt: &[u8], size: u64) {
|
||||
let (dest_sock, is_p2p) = find_peer_destination(eee, dst_mac).await;
|
||||
if is_p2p {
|
||||
eee.stats.tx_p2p.fetch_add(size, Ordering::Relaxed);
|
||||
|
||||
@ -4,7 +4,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::utils::mac_to_string;
|
||||
use crate::{network::send_packet_to_net, utils::mac_to_string};
|
||||
|
||||
use crate::{
|
||||
config::{NULL_MAC, REGISTER_INTERVAL},
|
||||
@ -781,6 +781,7 @@ async fn handle_tun_packet(
|
||||
match arp.opcode {
|
||||
ARP_REQUEST => {
|
||||
// handle ARP REQUEST
|
||||
debug!("got ARP REQUEST");
|
||||
if arp.ethhdr.dest != [0xff; 6] {
|
||||
println!("ARP REQUEST not broadcast");
|
||||
return;
|
||||
@ -815,7 +816,8 @@ async fn handle_tun_packet(
|
||||
let v =
|
||||
encode_to_udp_message(Some(data), PacketType::Data as u8).unwrap();
|
||||
println!("xxxx send arp reply");
|
||||
send_to_sock(edge, &v, from_sock);
|
||||
send_packet_to_net(edge, BROADCAST_MAC, &v, 0).await;
|
||||
// send_to_sock(edge, &v, from_sock);
|
||||
// edge.sock.send(v).await;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user