dns-2.0.10: DNS library in Haskell

Safe Haskell | None
Language | Haskell2010

Network.DNS.Types

Contents

- Domain
- Resource Records
  - Resource Record Type
- DNS Error
- DNS Message
- DNS Header
- DNS Flags
- DNS Body

Description

Data types for DNS Query and Response. For more information, see http://www.ietf.org/rfc/rfc1035.

Synopsis

- type Domain = ByteString
- data ResourceRecord
  - = ResourceRecord {
    - rrname :: Domain
    - rrtype :: TYPE
    - rrttl :: Int
    - rdata :: RData
    }
  - | OptRecord {
    - orudpsize :: Int
    - ordnssecok :: Bool
    - orversion :: Int
    - rdata :: RData
    }
- data RData
  - = RD_NS Domain
  - | RD_CNAME Domain
  - | RD_DNAME Domain
  - | RD_MX Int Domain
  - | RD_PTR Domain
  - | RD_SOA Domain Domain Int Int Int Int Int
  - | RD_A IPv4
  - | RD_AAAA IPv6
  - | RD_TXT ByteString
  - | RD_SRV Int Int Int Domain
  - | RD_OPT [OData]
  - | RD_OTH ByteString
  - | RD_TLSA Word8 Word8 Word8 ByteString
- data OData
  - = OD_ClientSubnet Int Int IP
  - | OD_Unknown Int ByteString
- data TYPE
  - = A
  - | AAAA
  - | NS
  - | TXT
  - | MX
  - | CNAME
  - | SOA
  - | PTR
  - | SRV
  - | DNAME
  - | OPT
  - | DS
  - | RRSIG
  - | NSEC
  - | DNSKEY
  - | NSEC3
  - | NSEC3PARAM
  - | TLSA
  - | CDS
  - | CDNSKEY
  - | CSYNC
  - | UNKNOWN Int
- intToType :: Int -> TYPE
- typeToInt :: TYPE -> Int
- data OPTTYPE
  - = ClientSubnet
  - | OUNKNOWN Int
- intToOptType :: Int -> OPTTYPE
- optTypeToInt :: OPTTYPE -> Int
- data DNSError
  - = SequenceNumberMismatch
  - | TimeoutExpired
  - | UnexpectedRDATA
  - | IllegalDomain
  - | FormatError
  - | ServerFailure
  - | NameError
  - | NotImplemented
  - | OperationRefused
  - | BadOptRecord
- data DNSMessage = DNSMessage {
  - header :: DNSHeader
  - question :: [Question]
  - answer :: [ResourceRecord]
  - authority :: [ResourceRecord]
  - additional :: [ResourceRecord]
  }
- type DNSFormat = DNSMessage
- data DNSHeader = DNSHeader {
  - identifier :: Int
  - flags :: DNSFlags
  }
- data DNSFlags = DNSFlags {
  - qOrR :: QorR
  - opcode :: OPCODE
  - authAnswer :: Bool
  - trunCation :: Bool
  - recDesired :: Bool
  - recAvailable :: Bool
  - rcode :: RCODE
  - authenData :: Bool
  }
- data QorR
  - = QR_Query
  - | QR_Response
- data OPCODE
  - = OP_STD
  - | OP_INV
  - | OP_SSR
- data RCODE
  - = NoErr
  - | FormatErr
  - | ServFail
  - | NameErr
  - | NotImpl
  - | Refused
  - | BadOpt
- data Question = Question {
  - qname :: Domain
  - qtype :: TYPE
  }
- responseA :: Int -> Question -> [IPv4] -> DNSMessage
- responseAAAA :: Int -> Question -> [IPv6] -> DNSMessage

# Domain

type Domain = ByteString #

Type for domain.

# Resource Records

data ResourceRecord #

Raw data format for resource records.

Constructors

ResourceRecord |
Fields rrname :: Domain rrtype :: TYPE rrttl :: Int rdata :: RData
OptRecord |
Fields orudpsize :: Int ordnssecok :: Bool orversion :: Int rdata :: RData

Instances

Eq ResourceRecord # |
Methods (==) :: ResourceRecord -> ResourceRecord -> Bool # (/=) :: ResourceRecord -> ResourceRecord -> Bool #
Show ResourceRecord # |
Methods showsPrec :: Int -> ResourceRecord -> ShowS # show :: ResourceRecord -> String # showList :: [ResourceRecord] -> ShowS #

data RData #

Raw data format for each type.

Constructors

RD_NS Domain |
RD_CNAME Domain |
RD_DNAME Domain |
RD_MX Int Domain |
RD_PTR Domain |
RD_SOA Domain Domain Int Int Int Int Int |
RD_A IPv4 |
RD_AAAA IPv6 |
RD_TXT ByteString |
RD_SRV Int Int Int Domain |
RD_OPT [OData] |
RD_OTH ByteString |
RD_TLSA Word8 Word8 Word8 ByteString |

Instances

Eq RData # |
Methods (==) :: RData -> RData -> Bool # (/=) :: RData -> RData -> Bool #
Ord RData # |
Methods compare :: RData -> RData -> Ordering # (<) :: RData -> RData -> Bool # (<=) :: RData -> RData -> Bool # (>) :: RData -> RData -> Bool # (>=) :: RData -> RData -> Bool # max :: RData -> RData -> RData # min :: RData -> RData -> RData #
Show RData # |
Methods showsPrec :: Int -> RData -> ShowS # show :: RData -> String # showList :: [RData] -> ShowS #

data OData #

Constructors

OD_ClientSubnet Int Int IP |
OD_Unknown Int ByteString |

Instances

Eq OData # |
Methods (==) :: OData -> OData -> Bool # (/=) :: OData -> OData -> Bool #
Ord OData # |
Methods compare :: OData -> OData -> Ordering # (<) :: OData -> OData -> Bool # (<=) :: OData -> OData -> Bool # (>) :: OData -> OData -> Bool # (>=) :: OData -> OData -> Bool # max :: OData -> OData -> OData # min :: OData -> OData -> OData #
Show OData # |
Methods showsPrec :: Int -> OData -> ShowS # show :: OData -> String # showList :: [OData] -> ShowS #

## Resource Record Type

data TYPE #

Types for resource records.

Constructors

A |
AAAA |
NS |
TXT |
MX |
CNAME |
SOA |
PTR |
SRV |
DNAME |
OPT |
DS |
RRSIG |
NSEC |
DNSKEY |
NSEC3 |
NSEC3PARAM |
TLSA |
CDS |
CDNSKEY |
CSYNC |
UNKNOWN Int |

Instances

Eq TYPE # |
Methods (==) :: TYPE -> TYPE -> Bool # (/=) :: TYPE -> TYPE -> Bool #
Read TYPE # |
Methods readsPrec :: Int -> ReadS TYPE # readList :: ReadS [TYPE] # readPrec :: ReadPrec TYPE # readListPrec :: ReadPrec [TYPE] #
Show TYPE # |
Methods showsPrec :: Int -> TYPE -> ShowS # show :: TYPE -> String # showList :: [TYPE] -> ShowS #

intToType :: Int -> TYPE #

typeToInt :: TYPE -> Int #

data OPTTYPE #

Constructors

ClientSubnet |
OUNKNOWN Int |

Instances

Eq OPTTYPE # |
Methods (==) :: OPTTYPE -> OPTTYPE -> Bool # (/=) :: OPTTYPE -> OPTTYPE -> Bool #

intToOptType :: Int -> OPTTYPE #

optTypeToInt :: OPTTYPE -> Int #

# DNS Error

data DNSError #

An enumeration of all possible DNS errors that can occur.

Constructors

SequenceNumberMismatch | The sequence number of the answer doesn't match our query. This could indicate foul play.
TimeoutExpired | The request simply timed out.
UnexpectedRDATA | The answer has the correct sequence number, but returned an unexpected RDATA format.
IllegalDomain | The domain for query is illegal.
FormatError | The name server was unable to interpret the query.
ServerFailure | The name server was unable to process this query due to a problem with the name server.
NameError | This code signifies that the domain name referenced in the query does not exist.
NotImplemented | The name server does not support the requested kind of query.
OperationRefused | The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
BadOptRecord | The server detected a malformed OPT RR.

Instances

Eq DNSError # |
Methods (==) :: DNSError -> DNSError -> Bool # (/=) :: DNSError -> DNSError -> Bool #
Show DNSError # |
Methods showsPrec :: Int -> DNSError -> ShowS # show :: DNSError -> String # showList :: [DNSError] -> ShowS #
Exception DNSError # |
Methods toException :: DNSError -> SomeException # fromException :: SomeException -> Maybe DNSError # displayException :: DNSError -> String #

# DNS Message

data DNSMessage #

Raw data format for DNS Query and Response.

Constructors

DNSMessage |
Fields header :: DNSHeader question :: [Question] answer :: [ResourceRecord] authority :: [ResourceRecord] additional :: [ResourceRecord]

Instances

Eq DNSMessage # |
Methods (==) :: DNSMessage -> DNSMessage -> Bool # (/=) :: DNSMessage -> DNSMessage -> Bool #
Show DNSMessage # |
Methods showsPrec :: Int -> DNSMessage -> ShowS # show :: DNSMessage -> String # showList :: [DNSMessage] -> ShowS #

type DNSFormat = DNSMessage #

For backward compatibility.

# DNS Header

data DNSHeader #

Raw data format for the header of DNS Query and Response.

Constructors

DNSHeader |
Fields identifier :: Int flags :: DNSFlags

Instances

Eq DNSHeader # |
Methods (==) :: DNSHeader -> DNSHeader -> Bool # (/=) :: DNSHeader -> DNSHeader -> Bool #
Show DNSHeader # |
Methods showsPrec :: Int -> DNSHeader -> ShowS # show :: DNSHeader -> String # showList :: [DNSHeader] -> ShowS #

# DNS Flags

data DNSFlags #

Raw data format for the flags of DNS Query and Response.

Constructors

DNSFlags |
Fields qOrR :: QorR opcode :: OPCODE authAnswer :: Bool trunCation :: Bool recDesired :: Bool recAvailable :: Bool rcode :: RCODE authenData :: Bool

Instances

Eq DNSFlags # |
Methods (==) :: DNSFlags -> DNSFlags -> Bool # (/=) :: DNSFlags -> DNSFlags -> Bool #
Show DNSFlags # |
Methods showsPrec :: Int -> DNSFlags -> ShowS # show :: DNSFlags -> String # showList :: [DNSFlags] -> ShowS #

# DNS Body

data QorR #

Constructors

QR_Query |
QR_Response |

Instances

Eq QorR # |
Methods (==) :: QorR -> QorR -> Bool # (/=) :: QorR -> QorR -> Bool #
Show QorR # |
Methods showsPrec :: Int -> QorR -> ShowS # show :: QorR -> String # showList :: [QorR] -> ShowS #

data OPCODE #

Constructors

OP_STD |
OP_INV |
OP_SSR |

Instances

Bounded OPCODE # |
Methods minBound :: OPCODE # maxBound :: OPCODE #
Enum OPCODE # |
Methods succ :: OPCODE -> OPCODE # pred :: OPCODE -> OPCODE # toEnum :: Int -> OPCODE # fromEnum :: OPCODE -> Int # enumFrom :: OPCODE -> [OPCODE] # enumFromThen :: OPCODE -> OPCODE -> [OPCODE] # enumFromTo :: OPCODE -> OPCODE -> [OPCODE] # enumFromThenTo :: OPCODE -> OPCODE -> OPCODE -> [OPCODE] #
Eq OPCODE # |
Methods (==) :: OPCODE -> OPCODE -> Bool # (/=) :: OPCODE -> OPCODE -> Bool #
Show OPCODE # |
Methods showsPrec :: Int -> OPCODE -> ShowS # show :: OPCODE -> String # showList :: [OPCODE] -> ShowS #

data RCODE #

Constructors

NoErr |
FormatErr |
ServFail |
NameErr |
NotImpl |
Refused |
BadOpt |

Instances

Bounded RCODE # |
Methods minBound :: RCODE # maxBound :: RCODE #
Enum RCODE # |
Methods succ :: RCODE -> RCODE # pred :: RCODE -> RCODE # toEnum :: Int -> RCODE # fromEnum :: RCODE -> Int # enumFrom :: RCODE -> [RCODE] # enumFromThen :: RCODE -> RCODE -> [RCODE] # enumFromTo :: RCODE -> RCODE -> [RCODE] # enumFromThenTo :: RCODE -> RCODE -> RCODE -> [RCODE] #
Eq RCODE # |
Methods (==) :: RCODE -> RCODE -> Bool # (/=) :: RCODE -> RCODE -> Bool #
Ord RCODE # |
Methods compare :: RCODE -> RCODE -> Ordering # (<) :: RCODE -> RCODE -> Bool # (<=) :: RCODE -> RCODE -> Bool # (>) :: RCODE -> RCODE -> Bool # (>=) :: RCODE -> RCODE -> Bool # max :: RCODE -> RCODE -> RCODE # min :: RCODE -> RCODE -> RCODE #
Show RCODE # |
Methods showsPrec :: Int -> RCODE -> ShowS # show :: RCODE -> String # showList :: [RCODE] -> ShowS #

data Question #

Raw data format for DNS questions.

Constructors

Question |
Fields qname :: Domain qtype :: TYPE

Instances

Eq Question # |
Methods (==) :: Question -> Question -> Bool # (/=) :: Question -> Question -> Bool #
Show Question # |
Methods showsPrec :: Int -> Question -> ShowS # show :: Question -> String # showList :: [Question] -> ShowS #

responseA :: Int -> Question -> [IPv4] -> DNSMessage #

responseAAAA :: Int -> Question -> [IPv6] -> DNSMessage #