pub struct RadiusPacket { /* private fields */ }
Expand description
Represents RADIUS packet
Implementations§
Source§impl RadiusPacket
impl RadiusPacket
Sourcepub fn initialise_packet(code: TypeCode) -> RadiusPacket
pub fn initialise_packet(code: TypeCode) -> RadiusPacket
Initialises RADIUS packet with random ID and authenticator
Sourcepub fn initialise_packet_from_bytes(
dictionary: &Dictionary,
bytes: &[u8],
) -> Result<RadiusPacket, RadiusError>
pub fn initialise_packet_from_bytes( dictionary: &Dictionary, bytes: &[u8], ) -> Result<RadiusPacket, RadiusError>
Initialises RADIUS packet from raw bytes
Sourcepub fn set_attributes(&mut self, attributes: Vec<RadiusAttribute>)
pub fn set_attributes(&mut self, attributes: Vec<RadiusAttribute>)
Sets attrbiutes
Sourcepub fn override_id(&mut self, new_id: u8)
pub fn override_id(&mut self, new_id: u8)
Overrides RadiusPacket id
Sourcepub fn override_authenticator(&mut self, new_authenticator: Vec<u8>)
pub fn override_authenticator(&mut self, new_authenticator: Vec<u8>)
Overrides RadiusPacket authenticator
Sourcepub fn override_message_authenticator(
&mut self,
new_message_authenticator: Vec<u8>,
) -> Result<(), RadiusError>
pub fn override_message_authenticator( &mut self, new_message_authenticator: Vec<u8>, ) -> Result<(), RadiusError>
Overrides RadiusPacket Message-Authenticator
Note: would fail if RadiusPacket has no Message-Authenticator attribute defined
Sourcepub fn generate_message_authenticator(
&mut self,
secret: &str,
) -> Result<(), RadiusError>
pub fn generate_message_authenticator( &mut self, secret: &str, ) -> Result<(), RadiusError>
Generates HMAC-MD5 hash for Message-Authenticator attribute
Note 1: this function assumes that RadiusAttribute Message-Authenticator already exists in RadiusPacket Note 2: Message-Authenticator in RadiusPacket would be overwritten when this function is called
Sourcepub fn message_authenticator(&self) -> Result<&[u8], RadiusError>
pub fn message_authenticator(&self) -> Result<&[u8], RadiusError>
Returns Message-Authenticator value, if exists in RadiusPacket
Sourcepub fn authenticator(&self) -> &[u8] ⓘ
pub fn authenticator(&self) -> &[u8] ⓘ
Returns RadiusPacket authenticator
Sourcepub fn attributes(&self) -> &[RadiusAttribute]
pub fn attributes(&self) -> &[RadiusAttribute]
Returns RadiusPacket attributes
Sourcepub fn attribute_by_name(&self, name: &str) -> Option<&RadiusAttribute>
pub fn attribute_by_name(&self, name: &str) -> Option<&RadiusAttribute>
Returns RadiusAttribute with given name
Sourcepub fn attribute_by_id(&self, id: u8) -> Option<&RadiusAttribute>
pub fn attribute_by_id(&self, id: u8) -> Option<&RadiusAttribute>
Returns RadiusAttribute with given id