Struct MutableDnsPacket

Source
pub struct MutableDnsPacket<'p> { /* private fields */ }
Expand description

A structure enabling manipulation of on the wire packets

Implementations§

Source§

impl<'a> MutableDnsPacket<'a>

Source

pub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableDnsPacket<'p>>

Constructs a new MutableDnsPacket. If the provided buffer is less than the minimum required packet size, this will return None.

Source

pub fn owned(packet: Vec<u8>) -> Option<MutableDnsPacket<'static>>

Constructs a new MutableDnsPacket. If the provided buffer is less than the minimum required packet size, this will return None. With this constructor the MutableDnsPacket will own its own data and the underlying buffer will be dropped when the MutableDnsPacket is.

Source

pub fn to_immutable<'p>(&'p self) -> DnsPacket<'p>

Maps from a MutableDnsPacket to a DnsPacket

Source

pub fn consume_to_immutable(self) -> DnsPacket<'a>

Maps from a MutableDnsPacket to a DnsPacket while consuming the source

Source

pub const fn minimum_packet_size() -> usize

The minimum size (in bytes) a packet of this type can be. It’s based on the total size of the fixed-size fields.

Source

pub fn packet_size(_packet: &Dns) -> usize

The size (in bytes) of a Dns instance when converted into a byte-array

Source

pub fn populate(&mut self, packet: &Dns)

Populates a DnsPacket using a Dns structure

Source

pub fn get_id(&self) -> u16

Get the id field. This field is always stored big-endian within the struct, but this accessor returns host order.

Source

pub fn get_is_response(&self) -> u8

Get the is_response field.

Source

pub fn get_opcode(&self) -> Opcode

Get the value of the opcode field

Source

pub fn get_is_authoriative(&self) -> u8

Get the is_authoriative field.

Source

pub fn get_is_truncated(&self) -> u8

Get the is_truncated field.

Source

pub fn get_is_recursion_desirable(&self) -> u8

Get the is_recursion_desirable field.

Source

pub fn get_is_recursion_available(&self) -> u8

Get the is_recursion_available field.

Source

pub fn get_zero_reserved(&self) -> u8

Get the zero_reserved field.

Source

pub fn get_is_answer_authenticated(&self) -> u8

Get the is_answer_authenticated field.

Source

pub fn get_is_non_authenticated_data(&self) -> u8

Get the is_non_authenticated_data field.

Source

pub fn get_rcode(&self) -> Retcode

Get the value of the rcode field

Source

pub fn get_query_count(&self) -> u16

Get the query_count field. This field is always stored big-endian within the struct, but this accessor returns host order.

Source

pub fn get_response_count(&self) -> u16

Get the response_count field. This field is always stored big-endian within the struct, but this accessor returns host order.

Source

pub fn get_authority_rr_count(&self) -> u16

Get the authority_rr_count field. This field is always stored big-endian within the struct, but this accessor returns host order.

Source

pub fn get_additional_rr_count(&self) -> u16

Get the additional_rr_count field. This field is always stored big-endian within the struct, but this accessor returns host order.

Source

pub fn get_queries_raw(&self) -> &[u8]

Get the raw &u8 value of the queries field, without copying

Source

pub fn get_queries(&self) -> Vec<DnsQuery>

Get the value of the queries field (copies contents)

Source

pub fn get_queries_iter(&self) -> DnsQueryIterable<'_>

Get the value of the queries field as iterator

Source

pub fn get_responses_raw(&self) -> &[u8]

Get the raw &u8 value of the responses field, without copying

Source

pub fn get_responses(&self) -> Vec<DnsResponse>

Get the value of the responses field (copies contents)

Source

pub fn get_responses_iter(&self) -> DnsResponseIterable<'_>

Get the value of the responses field as iterator

Source

pub fn get_authorities_raw(&self) -> &[u8]

Get the raw &u8 value of the authorities field, without copying

Source

pub fn get_authorities(&self) -> Vec<DnsResponse>

Get the value of the authorities field (copies contents)

Source

pub fn get_authorities_iter(&self) -> DnsResponseIterable<'_>

Get the value of the authorities field as iterator

Source

pub fn get_additional_raw(&self) -> &[u8]

Get the raw &u8 value of the additional field, without copying

Source

pub fn get_additional(&self) -> Vec<DnsResponse>

Get the value of the additional field (copies contents)

Source

pub fn get_additional_iter(&self) -> DnsResponseIterable<'_>

Get the value of the additional field as iterator

Source

pub fn set_id(&mut self, val: u16)

Set the id field. This field is always stored big-endian within the struct, but this mutator wants host order.

Source

pub fn set_is_response(&mut self, val: u8)

Set the is_response field.

Source

pub fn set_opcode(&mut self, val: Opcode)

Set the value of the opcode field.

Source

pub fn set_is_authoriative(&mut self, val: u8)

Set the is_authoriative field.

Source

pub fn set_is_truncated(&mut self, val: u8)

Set the is_truncated field.

Source

pub fn set_is_recursion_desirable(&mut self, val: u8)

Set the is_recursion_desirable field.

Source

pub fn set_is_recursion_available(&mut self, val: u8)

Set the is_recursion_available field.

Source

pub fn set_zero_reserved(&mut self, val: u8)

Set the zero_reserved field.

Source

pub fn set_is_answer_authenticated(&mut self, val: u8)

Set the is_answer_authenticated field.

Source

pub fn set_is_non_authenticated_data(&mut self, val: u8)

Set the is_non_authenticated_data field.

Source

pub fn set_rcode(&mut self, val: Retcode)

Set the value of the rcode field.

Source

pub fn set_query_count(&mut self, val: u16)

Set the query_count field. This field is always stored big-endian within the struct, but this mutator wants host order.

Source

pub fn set_response_count(&mut self, val: u16)

Set the response_count field. This field is always stored big-endian within the struct, but this mutator wants host order.

Source

pub fn set_authority_rr_count(&mut self, val: u16)

Set the authority_rr_count field. This field is always stored big-endian within the struct, but this mutator wants host order.

Source

pub fn set_additional_rr_count(&mut self, val: u16)

Set the additional_rr_count field. This field is always stored big-endian within the struct, but this mutator wants host order.

Source

pub fn get_queries_raw_mut(&mut self) -> &mut [u8]

Get the raw &mut u8 value of the queries field, without copying

Source

pub fn set_queries(&mut self, vals: &[DnsQuery])

Set the value of the queries field (copies contents)

Source

pub fn get_responses_raw_mut(&mut self) -> &mut [u8]

Get the raw &mut u8 value of the responses field, without copying

Source

pub fn set_responses(&mut self, vals: &[DnsResponse])

Set the value of the responses field (copies contents)

Source

pub fn get_authorities_raw_mut(&mut self) -> &mut [u8]

Get the raw &mut u8 value of the authorities field, without copying

Source

pub fn set_authorities(&mut self, vals: &[DnsResponse])

Set the value of the authorities field (copies contents)

Source

pub fn get_additional_raw_mut(&mut self) -> &mut [u8]

Get the raw &mut u8 value of the additional field, without copying

Source

pub fn set_additional(&mut self, vals: &[DnsResponse])

Set the value of the additional field (copies contents)

Source

pub fn set_payload(&mut self, vals: &[u8])

Set the value of the payload field (copies contents)

Trait Implementations§

Source§

impl<'p> Debug for MutableDnsPacket<'p>

Source§

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

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

impl<'p> FromPacket for MutableDnsPacket<'p>

Source§

type T = Dns

The type of the packet to convert from.
Source§

fn from_packet(&self) -> Dns

Converts a wire-format packet to #[packet] struct format.
Source§

impl<'a> MutablePacket for MutableDnsPacket<'a>

Source§

fn packet_mut<'p>(&'p mut self) -> &'p mut [u8]

Retrieve the underlying, mutable, buffer for the packet.
Source§

fn payload_mut<'p>(&'p mut self) -> &'p mut [u8]

Retrieve the mutable payload for the packet.
Source§

fn clone_from<T>(&mut self, other: &T)
where T: Packet,

Initialize this packet by cloning another.
Source§

impl<'a> Packet for MutableDnsPacket<'a>

Source§

fn packet<'p>(&'p self) -> &'p [u8]

Retrieve the underlying buffer for the packet.
Source§

fn payload<'p>(&'p self) -> &'p [u8]

Retrieve the payload for the packet.
Source§

impl<'a> PacketSize for MutableDnsPacket<'a>

Source§

fn packet_size(&self) -> usize

Get the calculated size of the packet.
Source§

impl<'p> PartialEq for MutableDnsPacket<'p>

Source§

fn eq(&self, other: &MutableDnsPacket<'p>) -> 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<'p> StructuralPartialEq for MutableDnsPacket<'p>

Auto Trait Implementations§

§

impl<'p> Freeze for MutableDnsPacket<'p>

§

impl<'p> RefUnwindSafe for MutableDnsPacket<'p>

§

impl<'p> Send for MutableDnsPacket<'p>

§

impl<'p> Sync for MutableDnsPacket<'p>

§

impl<'p> Unpin for MutableDnsPacket<'p>

§

impl<'p> !UnwindSafe for MutableDnsPacket<'p>

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> 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, 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.