Struct RadiusPacket

Source
pub struct RadiusPacket { /* private fields */ }
Expand description

Represents RADIUS packet

Implementations§

Source§

impl RadiusPacket

Source

pub fn initialise_packet(code: TypeCode) -> RadiusPacket

Initialises RADIUS packet with random ID and authenticator

Source

pub fn initialise_packet_from_bytes( dictionary: &Dictionary, bytes: &[u8], ) -> Result<RadiusPacket, RadiusError>

Initialises RADIUS packet from raw bytes

Source

pub fn set_attributes(&mut self, attributes: Vec<RadiusAttribute>)

Sets attrbiutes

Source

pub fn override_id(&mut self, new_id: u8)

Overrides RadiusPacket id

Source

pub fn override_authenticator(&mut self, new_authenticator: Vec<u8>)

Overrides RadiusPacket authenticator

Source

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

Source

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

Source

pub fn message_authenticator(&self) -> Result<&[u8], RadiusError>

Returns Message-Authenticator value, if exists in RadiusPacket

Source

pub fn id(&self) -> u8

Returns RadiusPacket id

Source

pub fn authenticator(&self) -> &[u8]

Returns RadiusPacket authenticator

Source

pub fn code(&self) -> &TypeCode

Returns RadiusPacket code

Source

pub fn attributes(&self) -> &[RadiusAttribute]

Returns RadiusPacket attributes

Source

pub fn attribute_by_name(&self, name: &str) -> Option<&RadiusAttribute>

Returns RadiusAttribute with given name

Source

pub fn attribute_by_id(&self, id: u8) -> Option<&RadiusAttribute>

Returns RadiusAttribute with given id

Source

pub fn to_bytes(&mut self) -> Vec<u8>

Converts RadiusPacket into ready-to-be-sent bytes vector

Trait Implementations§

Source§

impl Debug for RadiusPacket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RadiusPacket

Source§

fn eq(&self, other: &RadiusPacket) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RadiusPacket

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V