Struct radius_rust::protocol::radius_packet::RadiusPacket
source · 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
Trait Implementations§
source§impl Debug for RadiusPacket
impl Debug for RadiusPacket
source§impl PartialEq<RadiusPacket> for RadiusPacket
impl PartialEq<RadiusPacket> for RadiusPacket
source§fn eq(&self, other: &RadiusPacket) -> bool
fn eq(&self, other: &RadiusPacket) -> bool
self
and other
values to be equal, and is used
by ==
.