pub struct Packet<B> { /* private fields */ }Expand description
A full TACACS+ protocol packet.
Implementations§
Source§impl<B: PacketBody> Packet<B>
impl<B: PacketBody> Packet<B>
Sourcepub fn new(header: HeaderInfo, body: B) -> Self
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
UNENCRYPTEDflag, depending on if a key is specified
Source§impl<B: PacketBody + Serialize> Packet<B>
impl<B: PacketBody + Serialize> Packet<B>
Sourcepub fn wire_size(&self) -> usize
pub fn wire_size(&self) -> usize
Calculates the size of this packet as encoded into its binary format.
Sourcepub fn serialize<K: AsRef<[u8]>>(
self,
secret_key: K,
buffer: &mut [u8],
) -> Result<usize, SerializeError>
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.
Sourcepub fn serialize_unobfuscated(
self,
buffer: &mut [u8],
) -> Result<usize, SerializeError>
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>
impl<'raw, B: PacketBody + Deserialize<'raw>> Packet<B>
Sourcepub fn deserialize<K: AsRef<[u8]>>(
secret_key: K,
buffer: &'raw mut [u8],
) -> Result<Self, DeserializeError>
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.
Sourcepub fn deserialize_unobfuscated(
buffer: &'raw [u8],
) -> Result<Self, DeserializeError>
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.