dnsbase
Copyright(c) Viktor Dukhovni 2026
LicenseBSD-3-Clause
Maintainerietf-dane@dukhovni.org
Stabilityunstable
Safe HaskellNone
LanguageGHC2024

Net.DNSBase.NsecTypes

Description

The packed bitmap used to list which RR types are present at (or relevant to) the owner name. NsecTypes is the window-based encoding from RFC 4034 section 4.1.2, used by T_nsec, T_nsec3, and T_csync to carry an arbitrary set of RRTYPE codepoints in a compact form. NxtTypes is the legacy single-window encoding used by the obsolete NXT record, which restricts types to the first 128 codepoints.

NsecTypes is an instance of IsList with Item NsecTypes = RRTYPE, so construction is via fromList xs from GHC.IsList (or [A, AAAA, ...] under OverloadedLists, via the associated RRTYPE pattern synonyms) and enumeration is via toList. The input list is deduplicated and reordered into wire-form canonical order; an empty input produces the empty bitmap. hasRRtype is the efficient membership predicate used by DNSSEC validators.

Example

Expand
ghci> import qualified GHC.IsList as IL (fromList, toList)
ghci> tys = IL.fromList @NsecTypes [MX, A, AAAA, A]
ghci> tys
fromList @NsecTypes [1,15,28]
ghci> IL.toList tys
[1,15,28]
ghci> hasRRtype AAAA tys
True
ghci> hasRRtype NS tys
False
Synopsis

NSECNSEC3CSYNC Type Bitmap structure

data NsecTypes Source #

Abstract representation of a set of RRTYPE codepoints, stored as the window-based wire-format bitmap from RFC 4034 section 4.1.2. Used by T_nsec, T_nsec3, and T_csync to carry the set of types present at the owner name.

An NsecTypes may legitimately be empty -- this is the expected encoding for an NSEC3 empty-non-terminal. With NSEC, the type bitmap is expected to include at least the NSEC type itself; that invariant is not enforced by the type.

Construction and enumeration go through IsList:

  • fromList tys :: NsecTypes builds the bitmap from a list of RRTYPE values; duplicates are merged and the wire-form ordering is canonical regardless of input order. Under OverloadedLists the same input shape is just [A, AAAA, MX].
  • toList bm :: [RRTYPE] enumerates the contained types in ascending wire-form order.
  • (<>) unions two bitmaps; mempty is the empty bitmap.

For membership without enumerating the whole set, use hasRRtype, which goes directly to the relevant window, block and bit offset.

Instances

Instances details
Presentable NsecTypes Source #

Presentation form: contained types in canonical wire-form order, space-separated, with no leading separator. The empty bitmap renders as the empty string. When the bitmap follows another field in an RR's presentation form, compose with presentSp or presentLn to prefix the appropriate separator.

Instance details

Defined in Net.DNSBase.NsecTypes

Semigroup NsecTypes Source #

The (<>) operator unions the two bitmaps; duplicate types are merged.

Instance details

Defined in Net.DNSBase.NsecTypes

IsList NsecTypes Source #

Construction is via fromList (from any list of RRTYPEs, order and duplicates immaterial), and enumeration is via toList (yielding types in canonical wire-form order).

Instance details

Defined in Net.DNSBase.NsecTypes

Associated Types

type Item NsecTypes 
Instance details

Defined in Net.DNSBase.NsecTypes

Show NsecTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

Eq NsecTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

Ord NsecTypes Source #

The Ord instance matches wire-form canonical order.

Instance details

Defined in Net.DNSBase.NsecTypes

type Item NsecTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

nsecTypesFromList :: [RRTYPE] -> NsecTypes Source #

Construct the per-window bitmaps from a list of types.

nsecTypesToList :: NsecTypes -> [RRTYPE] Source #

Convert NsecTypes bitmap to an RRTYPE list

putNsecTypes :: NsecTypes -> SPut s RData Source #

Output the bitmaps.

hasRRtype :: RRTYPE -> NsecTypes -> Bool Source #

Efficient NSEC/NSEC3 type bitmap membership predicate.

Legacy type bitmap in NXT records

newtype NxtTypes Source #

Instances

Instances details
Presentable NxtTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

IsNonEmptyList NxtTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

Associated Types

type Item1 NxtTypes 
Instance details

Defined in Net.DNSBase.NsecTypes

Semigroup NxtTypes Source #

Concatentation va (<>) operator merges the two bitmaps.

Instance details

Defined in Net.DNSBase.NsecTypes

Show NxtTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

Eq NxtTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

Ord NxtTypes Source #

The Ord instance matches wire-form canonical order.

Instance details

Defined in Net.DNSBase.NsecTypes

type Item1 NxtTypes Source # 
Instance details

Defined in Net.DNSBase.NsecTypes

data NxtRRtype Source #

An RRtype representable in an NXT RR bitmap.

toNxtTypes :: NonEmpty RRTYPE -> NxtTypes Source #

An error if any of input RRtypes are above 127.

nxtTypesFromNE :: NonEmpty NxtRRtype -> NxtTypes Source #

Construct the bitmap from a non-empty list of types.

nxtTypesToNE :: NxtTypes -> NonEmpty NxtRRtype Source #

Reconstruct RRTYPE list from bitmap.

hasNxtRRtype :: RRTYPE -> NxtTypes -> Bool Source #

Efficient NXT type bitmap membership predicate.