Struct radius_rust::client::mutex_client::Client[][src]

pub struct Client { /* fields omitted */ }

Represents RADIUS client instance

The key difference between this client and the one from radius_rust::client::client::Client is that this client's socket poll is wrapped into Mutex (there are cases when we cannot use mut reference to Client and socket_poll is the only thing which blocks the Client usage in such cases)

Implementations

impl Client[src]

pub fn initialise_client(
    auth_port: u16,
    acct_port: u16,
    coa_port: u16,
    dictionary: Dictionary,
    server: String,
    secret: String,
    retries: u16,
    timeout: u16
) -> Result<Client, RadiusError>
[src]

Initialise RADIUS client instance

pub fn create_packet(
    &self,
    code: TypeCode,
    attributes: Vec<RadiusAttribute>
) -> RadiusPacket
[src]

Creates RADIUS packet with any TypeCode

pub fn create_auth_packet(
    &self,
    attributes: Vec<RadiusAttribute>
) -> RadiusPacket
[src]

Creates RADIUS Access Request packet

pub fn create_acct_packet(
    &self,
    attributes: Vec<RadiusAttribute>
) -> RadiusPacket
[src]

Creates RADIUS Accounting Request packet

pub fn create_coa_packet(
    &self,
    attributes: Vec<RadiusAttribute>
) -> RadiusPacket
[src]

Creates RADIUS CoA Request packet

pub fn create_attribute_by_name(
    &self,
    attribute_name: &str,
    value: Vec<u8>
) -> Result<RadiusAttribute, RadiusError>
[src]

Creates RADIUS packet attribute by name, that is defined in dictionary file

Examples

use radius_rust::client::mutex_client::Client;
use radius_rust::protocol::dictionary::Dictionary;
use radius_rust::protocol::radius_packet::TypeCode;

fn main() {
    let dictionary = Dictionary::from_file("./dict_examples/integration_dict").unwrap();
    let client     = Client::initialise_client(1812, 1813, 3799, dictionary, String::from("127.0.0.1"), String::from("secret"), 1, 2).unwrap();

    client.create_attribute_by_name("User-Name", String::from("testing").into_bytes());
}

pub fn create_attribute_by_id(
    &self,
    attribute_id: u8,
    value: Vec<u8>
) -> Result<RadiusAttribute, RadiusError>
[src]

Creates RADIUS packet attribute by ID, that is defined in dictionary file

Examples

use radius_rust::client::mutex_client::Client;
use radius_rust::protocol::dictionary::Dictionary;
use radius_rust::protocol::radius_packet::TypeCode;

fn main() {
    let dictionary = Dictionary::from_file("./dict_examples/integration_dict").unwrap();
    let client     = Client::initialise_client(1812, 1813, 3799, dictionary, String::from("127.0.0.1"), String::from("secret"), 1, 2).unwrap();

    client.create_attribute_by_id(1, String::from("testing").into_bytes());
}

pub fn generate_message_hash(&self, packet: &mut RadiusPacket) -> Vec<u8>[src]

Generates HMAC-MD5 hash for Message-Authenticator attribute

Note: this function assumes that RadiusAttribute Message-Authenticator already exists in RadiusPacket

pub fn get_radius_attr_original_string_value(
    &self,
    attribute: &RadiusAttribute
) -> Result<String, RadiusError>
[src]

Gets the original value as a String if the RadiusAttribute respresents dictionary attribute that has type: string, ipaddr, ipv6addr or ipv6prefix

pub fn get_radius_attr_original_integer_value(
    &self,
    attribute: &RadiusAttribute
) -> Result<u64, RadiusError>
[src]

Gets the original value as a String if the RadiusAttribute respresents dictionary attribute that has type:integer or date

pub fn initialise_packet_from_bytes(
    &self,
    reply: &[u8]
) -> Result<RadiusPacket, RadiusError>
[src]

Initialises RadiusPacket from bytes

pub fn send_packet(&self, packet: &mut RadiusPacket) -> Result<(), RadiusError>[src]

Sends packet to RADIUS server but does not return a response

pub fn send_and_receive_packet(
    &self,
    packet: &mut RadiusPacket
) -> Result<Vec<u8>, RadiusError>
[src]

Sends packet to RADIUS server and returns a response

pub fn verify_reply(
    &self,
    request: &RadiusPacket,
    reply: &[u8]
) -> Result<(), RadiusError>
[src]

Verifies that reply packet's ID and authenticator are a match

pub fn verify_message_authenticator(
    &self,
    packet: &[u8]
) -> Result<(), RadiusError>
[src]

Verifies that reply packet's Message-Authenticator attribute is valid

pub fn verify_packet_attributes(&self, packet: &[u8]) -> Result<(), RadiusError>[src]

Verifies that reply packet's attributes have valid values

Trait Implementations

impl Debug for Client[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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