Packet

Struct Packet 

Source
pub struct Packet {
    pub code: Code,
    pub identifier: u8,
    pub authenticator: [u8; 16],
    pub attributes: Attributes,
    pub secret: Arc<[u8]>,
}
Expand description

Represents a parsed or ready-to-be-sent RADIUS packet.

This struct acts as the primary container for RADIUS data, including the fixed header fields and the variable-length attributes.

Fields§

§code: Code

The RADIUS packet type (e.g., Access-Request, Access-Accept).

§identifier: u8

A sequence number used to match requests with responses. The client should increment this for each new request.

§authenticator: [u8; 16]

A 16-octet value used to authenticate the reply from the RADIUS server and to hide passwords.

§attributes: Attributes

A collection of RADIUS attributes containing the data for the request or response.

§secret: Arc<[u8]>

The shared secret used for packet authentication and attribute encryption.

Implementations§

Source§

impl Packet

Source

pub fn parse_packet( b: Bytes, secret: Arc<[u8]>, ) -> Result<Self, PacketParseError>

Source

pub fn encode(&self) -> Result<Vec<u8>, PacketParseError>

Source

pub fn encode_raw(&self) -> Result<Vec<u8>, PacketParseError>

Source

pub fn verify_request(&self) -> bool

Source

pub fn get_attribute(&self, key: u8) -> Option<&AttributeValue>

Source

pub fn set_attribute(&mut self, key: u8, value: AttributeValue)

Source

pub fn get_vsa_attribute( &self, vendor_id: u32, vendor_type: u8, ) -> Option<&[u8]>

Source

pub fn set_vsa_attribute( &mut self, vendor_id: u32, vendor_type: u8, value: AttributeValue, )

Source

pub fn encrypt_user_password(&self, plaintext: &[u8]) -> Option<Vec<u8>>

Encrypts a plaintext password according to RFC 2865 (User-Password)

Source

pub fn decrypt_user_password(&self, encrypted: &[u8]) -> Option<Vec<u8>>

Decrypts a User-Password attribute according to RFC 2865

Source

pub fn encrypt_tunnel_password(&self, plaintext: &[u8]) -> Option<Vec<u8>>

Encrypts Tunnel-Password according to RFC 2868

Source

pub fn decrypt_tunnel_password(&self, encrypted: &[u8]) -> Option<Vec<u8>>

Decrypts Tunnel-Password according to RFC 2868

Source

pub fn get_attribute_as<T: FromRadiusAttribute>( &self, type_code: u8, ) -> Option<T>

Source

pub fn set_attribute_as<T: ToRadiusAttribute>( &mut self, type_code: u8, value: T, )

Source

pub fn get_vsa_attribute_as<T: FromRadiusAttribute>( &self, v_id: u32, v_type: u8, ) -> Option<T>

Source

pub fn set_vsa_attribute_as<T: ToRadiusAttribute>( &mut self, v_id: u32, v_type: u8, value: T, )

Source

pub fn create_response_packet(&self, code: Code) -> Packet

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Packet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Packet

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Packet

§

impl RefUnwindSafe for Packet

§

impl Send for Packet

§

impl Sync for Packet

§

impl Unpin for Packet

§

impl UnwindSafe for Packet

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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