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: CodeThe RADIUS packet type (e.g., Access-Request, Access-Accept).
identifier: u8A 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: AttributesA 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
impl Packet
pub fn parse_packet( b: Bytes, secret: Arc<[u8]>, ) -> Result<Self, PacketParseError>
pub fn encode(&self) -> Result<Vec<u8>, PacketParseError>
pub fn encode_raw(&self) -> Result<Vec<u8>, PacketParseError>
pub fn verify_request(&self) -> bool
pub fn get_attribute(&self, key: u8) -> Option<&AttributeValue>
pub fn set_attribute(&mut self, key: u8, value: AttributeValue)
pub fn get_vsa_attribute( &self, vendor_id: u32, vendor_type: u8, ) -> Option<&[u8]>
pub fn set_vsa_attribute( &mut self, vendor_id: u32, vendor_type: u8, value: AttributeValue, )
Sourcepub fn encrypt_user_password(&self, plaintext: &[u8]) -> Option<Vec<u8>>
pub fn encrypt_user_password(&self, plaintext: &[u8]) -> Option<Vec<u8>>
Encrypts a plaintext password according to RFC 2865 (User-Password)
Sourcepub fn decrypt_user_password(&self, encrypted: &[u8]) -> Option<Vec<u8>>
pub fn decrypt_user_password(&self, encrypted: &[u8]) -> Option<Vec<u8>>
Decrypts a User-Password attribute according to RFC 2865
Sourcepub fn encrypt_tunnel_password(&self, plaintext: &[u8]) -> Option<Vec<u8>>
pub fn encrypt_tunnel_password(&self, plaintext: &[u8]) -> Option<Vec<u8>>
Encrypts Tunnel-Password according to RFC 2868
Sourcepub fn decrypt_tunnel_password(&self, encrypted: &[u8]) -> Option<Vec<u8>>
pub fn decrypt_tunnel_password(&self, encrypted: &[u8]) -> Option<Vec<u8>>
Decrypts Tunnel-Password according to RFC 2868