pub struct OptRcode(/* private fields */);
Expand description
Extended DNS Response Codes for OPT records.
Originally, the response code embedded in the header of each DNS message was four bits long. This code, defined in [RFC 1035], is represented by the Rcode type. The extension mechanism for DNS initially defined in RFC 2671 and updated by RFC 6891 added eight more bits to be stored in the OPT pseudo-resource record. This type represents the complete 12 bit extended response code.
There is a third, 16 bit wide response code for transaction
authentication (TSIG) defined in RFC 2845 and represented by the
TsigRcode
type. The code mostly shares the same name space except
for an unfortunate collision in between the BADVERS and BADSIG values.
Because of this, we decided to have separate types.
The values for all three response code types are defined in the IANA DNS RCODEs registry. This type is complete as of 2019-01-28.
The 12-bit extended RCODE defined by RFC 6891 stores the lowest 4-bits of the extended RCODE in the main DNS header RCODE field and stores the remaining 8-bits (right shifted by 4-bits) in the OPT record header RCODE field, like so:
NoError: 0 = 0b0000_0000_0000
^^^^ Stored in DNS header RCODE field
^^^^_^^^^ Stored in OPT header RCODE field
FormErr: 1 = 0b0000_0000_0001
^^^^ Stored in DNS header RCODE field
^^^^_^^^^ Stored in OPT header RCODE field
BadVers: 16 = 0b0000_0001_0000
^^^^ Stored in DNS header RCODE field
^^^^_^^^^ Stored in OPT header RCODE field
BadCookie: 23 = 0b0000_0001_0111
^^^^ Stored in DNS header RCODE field
^^^^_^^^^ Stored in OPT header RCODE field
This type offers several functions to ease working with the separate parts and the combined value of an extended RCODE:
OptRcode::rcode
: the RFC 1035 header RCODE part.OptRcode::ext
`: the RFC 6891 ENDS OPT extended RCODE part.OptRcode::to_parts
`: to access both parts at once.OptRcode::to_int
`: the IANA number for the RCODE combining both parts.
Implementations§
source§impl OptRcode
impl OptRcode
sourcepub const SERVFAIL: Self = _
pub const SERVFAIL: Self = _
Server failure.
The name server was unable to process this query due to a problem with the name server.
Defined in RFC 1035.
sourcepub const NXDOMAIN: Self = _
pub const NXDOMAIN: Self = _
Name error.
The domain name given in the query does not exist at the name server.
Defined in RFC 1035.
sourcepub const REFUSED: Self = _
pub const REFUSED: Self = _
Query refused.
The name server refused to perform the operation requested by the query for policy reasons.
Defined in RFC 1035.
sourcepub const YXRRSET: Self = _
pub const YXRRSET: Self = _
RR set exists when it should not.
Returned for an UPDATE query when an RRset requested to not exist does in fact exist.
Defined in RFC 2136.
sourcepub const NXRRSET: Self = _
pub const NXRRSET: Self = _
RR set that should exist does not.
Returned for an UPDATE query when an RRset requested to exist does not.
Defined in RFC 2136.
sourcepub const NOTZONE: Self = _
pub const NOTZONE: Self = _
Name not contained in zone.
A name used in the prerequisite or update section is not within the zone given in the zone section.
Defined in RFC 2136.
source§impl OptRcode
impl OptRcode
sourcepub const fn checked_from_int(value: u16) -> Option<OptRcode>
pub const fn checked_from_int(value: u16) -> Option<OptRcode>
Creates an rcode from an integer, returning None
if invalid.
The rcode is valid if the upper four bits of value
are all zero.
sourcepub const fn masked_from_int(value: u16) -> OptRcode
pub const fn masked_from_int(value: u16) -> OptRcode
Creates an rcode from an integer, only considering the lower four bits.
This function will ignore the upper four bit of value
.
sourcepub const fn from_rcode(rcode: Rcode) -> Self
pub const fn from_rcode(rcode: Rcode) -> Self
Creates an OPT rcode from a plain rcode.
sourcepub const fn to_int(self) -> u16
pub const fn to_int(self) -> u16
Returns the integer value for this rcode.
Only the lower 12 bits of the returned octet are used by the rcode. The upper four bits are always zero.
sourcepub fn from_parts(rcode: Rcode, ext: u8) -> OptRcode
pub fn from_parts(rcode: Rcode, ext: u8) -> OptRcode
Creates an extended rcode value from its parts.
sourcepub const fn to_mnemonic(self) -> Option<&'static [u8]>
pub const fn to_mnemonic(self) -> Option<&'static [u8]>
Returns the mnemonic for this value if there is one.
Trait Implementations§
source§impl Ord for OptRcode
impl Ord for OptRcode
source§impl PartialOrd for OptRcode
impl PartialOrd for OptRcode
impl Copy for OptRcode
impl Eq for OptRcode
impl StructuralPartialEq for OptRcode
Auto Trait Implementations§
impl Freeze for OptRcode
impl RefUnwindSafe for OptRcode
impl Send for OptRcode
impl Sync for OptRcode
impl Unpin for OptRcode
impl UnwindSafe for OptRcode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)