diff --git a/src/attributes.rs b/src/attributes.rs index 0faa5a3..34998db 100644 --- a/src/attributes.rs +++ b/src/attributes.rs @@ -14,7 +14,7 @@ pub struct AVP { pub struct Attributes(pub(crate) Vec); impl Attributes { - pub(crate) fn parse_attributes(bs: &[u8]) -> Result { + pub(crate) fn decode(bs: &[u8]) -> Result { let mut i = 0; let mut attrs = Vec::new(); diff --git a/src/client.rs b/src/client.rs index fb48709..c9a17d8 100644 --- a/src/client.rs +++ b/src/client.rs @@ -74,7 +74,7 @@ impl Client { } }; - match Packet::parse(&buf[..len].to_vec(), request_packet.get_secret()) { + match Packet::decode(&buf[..len].to_vec(), request_packet.get_secret()) { Ok(response_packet) => Ok(response_packet), Err(e) => Err(FailedParsingUDPResponse(e)), } diff --git a/src/packet.rs b/src/packet.rs index 0bc979c..62abf2a 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -43,7 +43,7 @@ impl Packet { &self.authenticator } - pub fn parse(bs: &[u8], secret: &[u8]) -> Result { + pub fn decode(bs: &[u8], secret: &[u8]) -> Result { if bs.len() < RADIUS_PACKET_HEADER_LENGTH { return Err(format!("radius packet doesn't have enough length of bytes; that has to be at least {} bytes", RADIUS_PACKET_HEADER_LENGTH)); } @@ -56,11 +56,10 @@ impl Packet { return Err("invalid radius packat lengt".to_owned()); } - let attributes = - match Attributes::parse_attributes(&bs[RADIUS_PACKET_HEADER_LENGTH..len].to_vec()) { - Ok(attributes) => attributes, - Err(e) => return Err(e), - }; + let attributes = match Attributes::decode(&bs[RADIUS_PACKET_HEADER_LENGTH..len].to_vec()) { + Ok(attributes) => attributes, + Err(e) => return Err(e), + }; Ok(Packet { code: Code::from(bs[0]), @@ -242,7 +241,7 @@ mod tests { 0x0a, 0xee, 0x04, 0x06, 0xc0, 0xa8, 0x01, 0x10, 0x05, 0x06, 0x00, 0x00, 0x00, 0x03, ]; - let packet = Packet::parse(&request, &secret)?; + let packet = Packet::decode(&request, &secret)?; assert_eq!(packet.code, Code::AccessRequest); assert_eq!(packet.identifier, 0); diff --git a/src/server.rs b/src/server.rs index 4ad005d..6bcfe57 100644 --- a/src/server.rs +++ b/src/server.rs @@ -121,7 +121,7 @@ impl Server { return; } - let packet = match Packet::parse(request_data, &secret) { + let packet = match Packet::decode(request_data, &secret) { Ok(packet) => packet, Err(e) => { error!(