dns-2.0.13: 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
  - | RetryLimitExceeded
  - | 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 Source #

Type for domain.

# Resource Records

data ResourceRecord Source #

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 Source # |
Methods (==) :: ResourceRecord -> ResourceRecord -> Bool # (/=) :: ResourceRecord -> ResourceRecord -> Bool #
Show ResourceRecord Source # |
Methods showsPrec :: Int -> ResourceRecord -> ShowS # show :: ResourceRecord -> String # showList :: [ResourceRecord] -> ShowS #

data RData Source #

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 Source # |
Methods (==) :: RData -> RData -> Bool # (/=) :: RData -> RData -> Bool #
Ord RData Source # |
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 Source # |
Methods showsPrec :: Int -> RData -> ShowS # show :: RData -> String # showList :: [RData] -> ShowS #

data OData Source #

Constructors

OD_ClientSubnet Int Int IP |
OD_Unknown Int ByteString |

Instances

Eq OData Source # |
Methods (==) :: OData -> OData -> Bool # (/=) :: OData -> OData -> Bool #
Ord OData Source # |
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 Source # |
Methods showsPrec :: Int -> OData -> ShowS # show :: OData -> String # showList :: [OData] -> ShowS #

## Resource Record Type

data TYPE Source #

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

intToType :: Int -> TYPE Source #

typeToInt :: TYPE -> Int Source #

data OPTTYPE Source #

Constructors

ClientSubnet |
OUNKNOWN Int |

Instances

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

intToOptType :: Int -> OPTTYPE Source #

optTypeToInt :: OPTTYPE -> Int Source #

# DNS Error

data DNSError Source #

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.
RetryLimitExceeded | The number of retries for the request was exceeded.
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 Source # |
Methods (==) :: DNSError -> DNSError -> Bool # (/=) :: DNSError -> DNSError -> Bool #
Show DNSError Source # |
Methods showsPrec :: Int -> DNSError -> ShowS # show :: DNSError -> String # showList :: [DNSError] -> ShowS #
Exception DNSError Source # |
Methods toException :: DNSError -> SomeException # fromException :: SomeException -> Maybe DNSError # displayException :: DNSError -> String #

# DNS Message

data DNSMessage Source #

Raw data format for DNS Query and Response.

Constructors

DNSMessage |

Fields

- header :: DNSHeader
- question :: [Question]
- answer :: [ResourceRecord]
- authority :: [ResourceRecord]
- additional :: [ResourceRecord]

Instances

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

type DNSFormat = DNSMessage Source #

For backward compatibility.

# DNS Header

data DNSHeader Source #

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

Constructors

DNSHeader |

Fields

- identifier :: Int
- flags :: DNSFlags

Instances

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

# DNS Flags

data DNSFlags Source #

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 Source # |
Methods (==) :: DNSFlags -> DNSFlags -> Bool # (/=) :: DNSFlags -> DNSFlags -> Bool #
Show DNSFlags Source # |
Methods showsPrec :: Int -> DNSFlags -> ShowS # show :: DNSFlags -> String # showList :: [DNSFlags] -> ShowS #

# DNS Body

data QorR Source #

Constructors

QR_Query |
QR_Response |

Instances

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

data OPCODE Source #

Constructors

OP_STD |
OP_INV |
OP_SSR |

Instances

Bounded OPCODE Source # |
Methods minBound :: OPCODE # maxBound :: OPCODE #
Enum OPCODE Source # |
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 Source # |
Methods (==) :: OPCODE -> OPCODE -> Bool # (/=) :: OPCODE -> OPCODE -> Bool #
Show OPCODE Source # |
Methods showsPrec :: Int -> OPCODE -> ShowS # show :: OPCODE -> String # showList :: [OPCODE] -> ShowS #

data RCODE Source #

Constructors

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

Instances

Bounded RCODE Source # |
Methods minBound :: RCODE # maxBound :: RCODE #
Enum RCODE Source # |
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 Source # |
Methods (==) :: RCODE -> RCODE -> Bool # (/=) :: RCODE -> RCODE -> Bool #
Ord RCODE Source # |
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 Source # |
Methods showsPrec :: Int -> RCODE -> ShowS # show :: RCODE -> String # showList :: [RCODE] -> ShowS #

data Question Source #

Raw data format for DNS questions.

Constructors

Question |

Fields

- qname :: Domain
- qtype :: TYPE

Instances

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

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

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