mirror of
https://github.com/cubixle/radius-rs.git
synced 2026-04-24 22:34:42 +01:00
Rename
This commit is contained in:
@@ -14,7 +14,7 @@ pub struct AVP {
|
||||
pub struct Attributes(pub(crate) Vec<AVP>);
|
||||
|
||||
impl Attributes {
|
||||
pub(crate) fn parse_attributes(bs: &[u8]) -> Result<Attributes, String> {
|
||||
pub(crate) fn decode(bs: &[u8]) -> Result<Attributes, String> {
|
||||
let mut i = 0;
|
||||
let mut attrs = Vec::new();
|
||||
|
||||
|
||||
@@ -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)),
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ impl Packet {
|
||||
&self.authenticator
|
||||
}
|
||||
|
||||
pub fn parse(bs: &[u8], secret: &[u8]) -> Result<Self, String> {
|
||||
pub fn decode(bs: &[u8], secret: &[u8]) -> Result<Self, String> {
|
||||
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);
|
||||
|
||||
|
||||
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user