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

Net.DNSBase.EDNS.Option

Description

The KnownEdnsOption typeclass binds a concrete option type to its 16-bit code; the existential EdnsOption wrapper lets an option list hold a heterogeneous mix. Unknown option codes decode as OpaqueOption from Net.DNSBase.EDNS.Option.Opaque, preserving the raw bytes for inspection or pass-through. Applications register new typed options at runtime via registerEdnsOption; options whose codec admits typed or value-driven extensions (e.g. O_ede) also accept extendEdnsOptionWithType / extendEdnsOptionWithValue. See Net.DNSBase.Extensible for the full guide.

The OptionCtl machinery, with optCtlSet / optCtlAdd, is the building block QueryControls uses for per-call EDNS option list tweaks — see EdnsOptionCtl.

Synopsis

Generic EDNS option class

class (Typeable a, Eq a, Show a, Presentable a) => KnownEdnsOption a where Source #

EDNS option class with conversion to/from opaque EdnsOption form.

Minimal complete definition

optNum, optEncode, optDecode

Associated Types

type OptionExtensionVal a Source #

The codec-consumed extension value for option type a. Defaults to (). Options with a non-trivial extension (currently only O_ede, whose extension carries the info-code name registry) supply their own associated-type definition.

type OptionExtensionVal a = ()

Methods

optionExtensionVal :: forall b -> b ~ a => OptionExtensionVal a Source #

The library's built-in starting OptionExtensionVal for option type a. Used as the baseline when the library installs its built-in registration for a, and as the starting point when the user extends the codec for a. For OptionExtensionVal a ~ () options the class default applies.

default optionExtensionVal :: OptionExtensionVal a ~ () => forall b -> b ~ a => OptionExtensionVal a Source #

optNum :: forall b -> b ~ a => OptNum Source #

The EDNS option number

optPres :: forall b -> b ~ a => Builder -> Builder Source #

CPS option number presentation form builder. Most useful for new option values not yet known to the library.

optEncode Source #

Arguments

:: forall s r. (Typeable r, Eq r, Show r) 
=> a

The value to encode

-> SPut s r 

Encoder of option data to wire form

optDecode Source #

Arguments

:: forall b -> b ~ a 
=> OptionExtensionVal b

Its extension value

-> Int

The encoded data length

-> SGet EdnsOption 

Decoder from wire form

Instances

Instances details
KnownEdnsOption O_ecs Source # 
Instance details

Defined in Net.DNSBase.EDNS.Option.ECS

Associated Types

type OptionExtensionVal O_ecs 
Instance details

Defined in Net.DNSBase.EDNS.Option.ECS

Methods

optionExtensionVal :: forall b -> b ~ O_ecs => OptionExtensionVal O_ecs Source #

optNum :: forall b -> b ~ O_ecs => OptNum Source #

optPres :: forall b -> b ~ O_ecs => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_ecs -> SPut s r Source #

optDecode :: forall b -> b ~ O_ecs => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

KnownEdnsOption O_ede Source # 
Instance details

Defined in Net.DNSBase.EDNS.Option.EDE

Associated Types

type OptionExtensionVal O_ede 
Instance details

Defined in Net.DNSBase.EDNS.Option.EDE

Methods

optionExtensionVal :: forall b -> b ~ O_ede => OptionExtensionVal O_ede Source #

optNum :: forall b -> b ~ O_ede => OptNum Source #

optPres :: forall b -> b ~ O_ede => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_ede -> SPut s r Source #

optDecode :: forall b -> b ~ O_ede => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

KnownEdnsOption O_nsid Source # 
Instance details

Defined in Net.DNSBase.EDNS.Option.NSID

Associated Types

type OptionExtensionVal O_nsid 
Instance details

Defined in Net.DNSBase.EDNS.Option.NSID

Methods

optionExtensionVal :: forall b -> b ~ O_nsid => OptionExtensionVal O_nsid Source #

optNum :: forall b -> b ~ O_nsid => OptNum Source #

optPres :: forall b -> b ~ O_nsid => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_nsid -> SPut s r Source #

optDecode :: forall b -> b ~ O_nsid => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

KnownEdnsOption O_dau Source # 
Instance details

Defined in Net.DNSBase.EDNS.Option.Secalgs

Associated Types

type OptionExtensionVal O_dau 
Instance details

Defined in Net.DNSBase.EDNS.Option.Secalgs

Methods

optionExtensionVal :: forall b -> b ~ O_dau => OptionExtensionVal O_dau Source #

optNum :: forall b -> b ~ O_dau => OptNum Source #

optPres :: forall b -> b ~ O_dau => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_dau -> SPut s r Source #

optDecode :: forall b -> b ~ O_dau => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

KnownEdnsOption O_dhu Source # 
Instance details

Defined in Net.DNSBase.EDNS.Option.Secalgs

Associated Types

type OptionExtensionVal O_dhu 
Instance details

Defined in Net.DNSBase.EDNS.Option.Secalgs

Methods

optionExtensionVal :: forall b -> b ~ O_dhu => OptionExtensionVal O_dhu Source #

optNum :: forall b -> b ~ O_dhu => OptNum Source #

optPres :: forall b -> b ~ O_dhu => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_dhu -> SPut s r Source #

optDecode :: forall b -> b ~ O_dhu => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

KnownEdnsOption O_n3u Source # 
Instance details

Defined in Net.DNSBase.EDNS.Option.Secalgs

Associated Types

type OptionExtensionVal O_n3u 
Instance details

Defined in Net.DNSBase.EDNS.Option.Secalgs

Methods

optionExtensionVal :: forall b -> b ~ O_n3u => OptionExtensionVal O_n3u Source #

optNum :: forall b -> b ~ O_n3u => OptNum Source #

optPres :: forall b -> b ~ O_n3u => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_n3u -> SPut s r Source #

optDecode :: forall b -> b ~ O_n3u => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

Nat16 n => KnownEdnsOption (OpaqueOption n) Source # 
Instance details

Defined in Net.DNSBase.EDNS.Internal.Option.Opaque

Associated Types

type OptionExtensionVal (OpaqueOption n) 
Instance details

Defined in Net.DNSBase.EDNS.Internal.Option.Opaque

Methods

optionExtensionVal :: forall b -> b ~ OpaqueOption n => OptionExtensionVal (OpaqueOption n) Source #

optNum :: forall b -> b ~ OpaqueOption n => OptNum Source #

optPres :: forall b -> b ~ OpaqueOption n => Builder -> Builder Source #

optEncode :: forall s r. (Typeable r, Eq r, Show r) => OpaqueOption n -> SPut s r Source #

optDecode :: forall b -> b ~ OpaqueOption n => OptionExtensionVal b -> Int -> SGet EdnsOption Source #

data EdnsOption Source #

Existentially quantified type-opaque KnownEdnsOption, with heterogeneous equality.

Constructors

KnownEdnsOption a => EdnsOption a 

fromOption :: KnownEdnsOption a => EdnsOption -> Maybe a Source #

Extract specific KnownEdnsOption from existential wrapping

monoOption :: (KnownEdnsOption a, Foldable t) => t EdnsOption -> [a] Source #

Filter a Foldable of EdnsOption down to the values of a single type a, dropping any entries whose option-code does not match (or whose value is held under an OpaqueOption even though a is registered for that code). Use a type application to select the target type, e.g. monoOption @O_ede ednsOptions.

optionCode :: EdnsOption -> OptNum Source #

The 16-bit OptNum codepoint of the option wrapped inside a EdnsOption. Useful for filtering or grouping a heterogeneous option list without unpacking each value.

putOption :: forall s r. (Typeable r, Eq r, Show r) => EdnsOption -> SPut s r Source #

Wire-form encoder for a EdnsOption: writes the 16-bit option code followed by the length-prefixed value bytes produced by the underlying optEncode method. Used by the OPT pseudo-RR encoder to serialise each option in turn.

Extensibility

data OptionCodec Source #

Known EDNS option Proxy + OptionExtensionVal pair, paralleling RDataCodec on the RR-type side.

Resolver EDNS option controls

data OptionCtl Source #

The list of EDNS options carried in the OPT pseudo-RR of an outgoing query. Callers do not build an OptionCtl directly; they build an endomorphism OptionCtl -> OptionCtl out of optCtlAdd and optCtlSet and pass it to the EdnsOptionCtl pattern of QueryControls. The endomorphism is applied to the resolver's ambient option list at send time, so callers see the final list as a delta on top of whatever the resolver already had configured.

Instances

Instances details
Show OptionCtl Source # 
Instance details

Defined in Net.DNSBase.EDNS.Internal.Option

Eq OptionCtl Source # 
Instance details

Defined in Net.DNSBase.EDNS.Internal.Option

optCtlSet :: [EdnsOption] -> OptionCtl -> OptionCtl Source #

Replace the option list outright with the supplied options. Use this when the per-call configuration should override anything the resolver had set; combine with optCtlAdd for partial overrides.

optCtlAdd :: [EdnsOption] -> OptionCtl -> OptionCtl Source #

Add the supplied options to the existing list. When the new and old options share an OPTCODE, the new entries replace the old ones with that code.

emptyOptionCtl :: OptionCtl Source #

The empty option list. Useful as the seed when running an OptionCtl endomorphism to inspect what it would produce.

applyOptionCtl :: (OptionCtl -> OptionCtl) -> [EdnsOption] -> [EdnsOption] Source #

Apply an OptionCtl endomorphism to a plain list of options. Used by the resolver to fold per-call EDNS-option tweaks into the option list it is about to put on the wire.