From 206c543e8c495a4e358bea917f2cd3a3468126b5 Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Sun, 15 Jan 2023 19:19:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- switch/src/handle/udp_recv_handler.rs | 5 ++++- switch/src/protocol/error_packet.rs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/switch/src/handle/udp_recv_handler.rs b/switch/src/handle/udp_recv_handler.rs index 10f2db2..ec2d506 100644 --- a/switch/src/handle/udp_recv_handler.rs +++ b/switch/src/handle/udp_recv_handler.rs @@ -268,8 +268,11 @@ fn other_handle( fast_registration(&udp, server_addr)?; } } + InErrorPacket::AddressExhausted => { + return Err(Error::Stop("IP address has been exhausted".to_string())); + } InErrorPacket::OtherError(e) => { - log::warn!("OtherError {:?}", e.message()); + log::error!("OtherError {:?}", e.message()); } } } diff --git a/switch/src/protocol/error_packet.rs b/switch/src/protocol/error_packet.rs index d677f5d..c6b8405 100644 --- a/switch/src/protocol/error_packet.rs +++ b/switch/src/protocol/error_packet.rs @@ -4,6 +4,7 @@ use crate::error::*; pub enum Protocol { TokenError, Disconnect, + AddressExhausted, Other(u8), } @@ -12,6 +13,7 @@ impl From for Protocol { match value { 1 => Self::TokenError, 2 => Self::Disconnect, + 3 => Self::AddressExhausted, val => Self::Other(val), } } @@ -22,6 +24,7 @@ impl Into for Protocol { match self { Protocol::TokenError => 1, Protocol::Disconnect => 2, + Protocol::AddressExhausted => 3, Protocol::Other(val) => val, } } @@ -30,6 +33,7 @@ impl Into for Protocol { pub enum InErrorPacket { TokenError, Disconnect, + AddressExhausted, OtherError(ErrorPacket), } @@ -38,6 +42,7 @@ impl> InErrorPacket { match Protocol::from(protocol) { Protocol::TokenError => Ok(InErrorPacket::TokenError), Protocol::Disconnect => Ok(InErrorPacket::Disconnect), + Protocol::AddressExhausted => Ok(InErrorPacket::AddressExhausted), Protocol::Other(_) => Ok(InErrorPacket::OtherError(ErrorPacket::new(buffer)?)), } }