packet
This commit is contained in:
parent
32bbdc4f78
commit
893eef5871
@ -100,6 +100,7 @@ pub async fn handle_packet(eee: &Node, addr: SocketAddr, buf: &[u8]) -> Result<(
|
|||||||
};
|
};
|
||||||
match pkt_type {
|
match pkt_type {
|
||||||
PacketType::Data => {
|
PacketType::Data => {
|
||||||
|
debug!("got data");
|
||||||
let from_sock = get_sdlan_sock_from_socketaddr(addr).unwrap();
|
let from_sock = get_sdlan_sock_from_socketaddr(addr).unwrap();
|
||||||
debug!("[PPP]Rx data from {}", from_sock.to_string());
|
debug!("[PPP]Rx data from {}", from_sock.to_string());
|
||||||
if !eee.is_authorized() {
|
if !eee.is_authorized() {
|
||||||
@ -131,6 +132,7 @@ pub async fn handle_packet(eee: &Node, addr: SocketAddr, buf: &[u8]) -> Result<(
|
|||||||
handle_tun_packet(eee, &from_sock, !data.is_p2p, data).await;
|
handle_tun_packet(eee, &from_sock, !data.is_p2p, data).await;
|
||||||
}
|
}
|
||||||
PacketType::StunProbeReply => {
|
PacketType::StunProbeReply => {
|
||||||
|
debug!("got StunProbeReply");
|
||||||
let Ok(reply) = SdlStunProbeReply::decode(&buf[1..]) else {
|
let Ok(reply) = SdlStunProbeReply::decode(&buf[1..]) else {
|
||||||
error!("failed to decode SdlStunReply");
|
error!("failed to decode SdlStunReply");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -138,9 +140,11 @@ pub async fn handle_packet(eee: &Node, addr: SocketAddr, buf: &[u8]) -> Result<(
|
|||||||
eee.send_nat_probe_reply(reply.cookie, reply).await;
|
eee.send_nat_probe_reply(reply.cookie, reply).await;
|
||||||
}
|
}
|
||||||
PacketType::StunReply => {
|
PacketType::StunReply => {
|
||||||
|
debug!("got stun reply");
|
||||||
// stun reply, like pong
|
// stun reply, like pong
|
||||||
}
|
}
|
||||||
PacketType::Register => {
|
PacketType::Register => {
|
||||||
|
debug!("got Register");
|
||||||
if !eee.is_authorized() {
|
if !eee.is_authorized() {
|
||||||
error!("dropping REGISTER received before authorized");
|
error!("dropping REGISTER received before authorized");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -149,6 +153,7 @@ pub async fn handle_packet(eee: &Node, addr: SocketAddr, buf: &[u8]) -> Result<(
|
|||||||
let _ = handle_packet_register(eee, &buf[1..], false, &from_sock).await;
|
let _ = handle_packet_register(eee, &buf[1..], false, &from_sock).await;
|
||||||
}
|
}
|
||||||
PacketType::RegisterACK => {
|
PacketType::RegisterACK => {
|
||||||
|
debug!("got RegisterACK");
|
||||||
if !eee.is_authorized() {
|
if !eee.is_authorized() {
|
||||||
error!("dropping REGISTER received before authorized");
|
error!("dropping REGISTER received before authorized");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -763,10 +768,15 @@ async fn handle_tun_packet(
|
|||||||
Ok((hdr, rest)) => {
|
Ok((hdr, rest)) => {
|
||||||
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!("packet not direct to us");
|
error!(
|
||||||
|
"packet to [{:?}] not direct to us",
|
||||||
|
mac_to_string(&hdr.destination)
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if hdr.ether_type == ARP {
|
if hdr.ether_type == ARP {
|
||||||
let mut arp = ArpHdr::from_slice(&data);
|
let mut arp = ArpHdr::from_slice(&data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user