pub struct Packet { /* private fields */ }Expand description
This struct represents a packet of RADIUS for request and response.
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn new(code: Code, secret: &[u8]) -> Self
pub fn new(code: Code, secret: &[u8]) -> Self
Constructor for a Packet.
By default, this constructor makes an instance with a random identifier value.
If you’d like to set an arbitrary identifier, please use new_with_identifier() constructor instead or set_identifier() method for created instance.
Sourcepub fn new_with_identifier(code: Code, secret: &[u8], identifier: u8) -> Self
pub fn new_with_identifier(code: Code, secret: &[u8], identifier: u8) -> Self
Constructor for a Packet with arbitrary identifier value.
If you want to make an instance with a random identifier value, please consider using new().
pub fn get_code(&self) -> Code
pub fn get_identifier(&self) -> u8
pub fn get_secret(&self) -> &Vec<u8> ⓘ
pub fn get_authenticator(&self) -> &Vec<u8> ⓘ
Sourcepub fn set_identifier(&mut self, identifier: u8)
pub fn set_identifier(&mut self, identifier: u8)
This sets an identifier value to an instance.
Sourcepub fn decode(bs: &[u8], secret: &[u8]) -> Result<Self, PacketError>
pub fn decode(bs: &[u8], secret: &[u8]) -> Result<Self, PacketError>
This decodes bytes into a Packet.
Sourcepub fn make_response_packet(&self, code: Code) -> Self
pub fn make_response_packet(&self, code: Code) -> Self
This method makes a response packet according to self (i.e. request packet).
Sourcepub fn encode(&self) -> Result<Vec<u8>, PacketError>
pub fn encode(&self) -> Result<Vec<u8>, PacketError>
This method encodes the Packet into bytes.
Sourcepub fn is_authentic_response(
response: &[u8],
request: &[u8],
secret: &[u8],
) -> bool
pub fn is_authentic_response( response: &[u8], request: &[u8], secret: &[u8], ) -> bool
Returns whether the Packet is authentic response or not.
Sourcepub fn is_authentic_request(request: &[u8], secret: &[u8]) -> bool
pub fn is_authentic_request(request: &[u8], secret: &[u8]) -> bool
Returns whether the Packet is authentic request or not.
Sourcepub fn delete(&mut self, typ: AVPType)
pub fn delete(&mut self, typ: AVPType)
Delete all of AVPs from the list according to given AVP type.
Sourcepub fn lookup(&self, typ: AVPType) -> Option<&AVP>
pub fn lookup(&self, typ: AVPType) -> Option<&AVP>
Returns an AVP that matches at first with the given AVP type. If there are not any matched ones, this returns None.
Sourcepub fn lookup_all(&self, typ: AVPType) -> Vec<&AVP>
pub fn lookup_all(&self, typ: AVPType) -> Vec<&AVP>
Returns AVPs that match with the given AVP type.