Packet

Struct Packet 

Source
pub struct Packet<B> { /* private fields */ }
Expand description

A full TACACS+ protocol packet.

Implementations§

Source§

impl<B> Packet<B>

Source

pub fn header(&self) -> &HeaderInfo

Some of the header information associated with a packet.

Source

pub fn body(&self) -> &B

The body of the packet.

Source§

impl<B: PacketBody> Packet<B>

Source

pub fn new(header: HeaderInfo, body: B) -> Self

Assembles a header and body into a full packet.

NOTE: Some fields in the provided header may be updated for consistency. These may include:

  • The protocol minor version, depending on authentication method choice
  • The UNENCRYPTED flag, depending on if a key is specified
Source§

impl<B: PacketBody + Serialize> Packet<B>

Source

pub fn wire_size(&self) -> usize

Calculates the size of this packet as encoded into its binary format.

Source

pub fn serialize<K: AsRef<[u8]>>( self, secret_key: K, buffer: &mut [u8], ) -> Result<usize, SerializeError>

Serializes the packet into a buffer, obfuscating the body using a pseudo-pad generated by iterating the MD5 hash function.

This consumes the packet and also ensures the UNENCRYPTED flag is unset.

Source

pub fn serialize_unobfuscated( self, buffer: &mut [u8], ) -> Result<usize, SerializeError>

Serializes the packet into a buffer, leaving the body as cleartext.

This consumes the packet and sets the UNENCRYPTED flag if necessary.

Note that RFC8907 deprecated the UNENCRYPTED flag and states that it “MUST NOT be used in production” (section 4.5).

Source§

impl<'raw, B: PacketBody + Deserialize<'raw>> Packet<B>

Source

pub fn deserialize<K: AsRef<[u8]>>( secret_key: K, buffer: &'raw mut [u8], ) -> Result<Self, DeserializeError>

Attempts to deserialize an obfuscated packet with the provided secret key.

This function also ensures that the UNENCRYPTED is not set, and returns an error if it is.

Source

pub fn deserialize_unobfuscated( buffer: &'raw [u8], ) -> Result<Self, DeserializeError>

Attempts to deserialize a cleartext packet from a buffer.

This function also ensures that the UNENCRYPTED is set, and returns an error if it is not.

Source

pub fn to_owned<'b, O: FromBorrowedBody<Borrowed<'b> = B>>(&self) -> Packet<O>

Available on crate feature std only.

Converts this packet to one with a body that owns its fields.

Trait Implementations§

Source§

impl<B: Clone> Clone for Packet<B>

Source§

fn clone(&self) -> Packet<B>

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<B: Debug> Debug for Packet<B>

Source§

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

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

impl<B: Hash> Hash for Packet<B>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<B: PartialEq> PartialEq for Packet<B>

Source§

fn eq(&self, other: &Packet<B>) -> 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<B: Eq> Eq for Packet<B>

Source§

impl<B> StructuralPartialEq for Packet<B>

Auto Trait Implementations§

§

impl<B> Freeze for Packet<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for Packet<B>
where B: RefUnwindSafe,

§

impl<B> Send for Packet<B>
where B: Send,

§

impl<B> Sync for Packet<B>
where B: Sync,

§

impl<B> Unpin for Packet<B>
where B: Unpin,

§

impl<B> UnwindSafe for Packet<B>
where B: UnwindSafe,

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.