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)?)), } }