Network.DNS.Types

dns-2.0.1: 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
- data OData
  - = OD_ClientSubnet Int Int IP
  - | OD_Unknown Int ByteString
- data TYPE
  - = A
  - | AAAA
  - | NS
  - | TXT
  - | MX
  - | CNAME
  - | SOA
  - | PTR
  - | SRV
  - | DNAME
  - | OPT
  - | 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
  }
- 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 |
Show ResourceRecord |

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 |

Instances

Eq RData |
Show RData |

data OData

Constructors

OD_ClientSubnet Int Int IP |
OD_Unknown Int ByteString |

Instances

Eq OData |
Show OData |

## Resource Record Type

data TYPE

Types for resource records.

Constructors

A |
AAAA |
NS |
TXT |
MX |
CNAME |
SOA |
PTR |
SRV |
DNAME |
OPT |
UNKNOWN Int |

Instances

Eq TYPE |
Read TYPE |
Show TYPE |

intToType :: Int -> TYPE

typeToInt :: TYPE -> Int

data OPTTYPE

Constructors

ClientSubnet |
OUNKNOWN Int |

Instances

Eq OPTTYPE |

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 | Meaningful only for responses from an authoritative name server, 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 |
Show DNSError |
Exception DNSError |

# 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 |
Show DNSMessage |

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 |
Show DNSHeader |

# 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

Instances

Eq DNSFlags |
Show DNSFlags |

# DNS Body

data QorR

Constructors

QR_Query |
QR_Response |

Instances

Eq QorR |
Show QorR |

data OPCODE

Constructors

OP_STD |
OP_INV |
OP_SSR |

Instances

Enum OPCODE |
Eq OPCODE |
Show OPCODE |

data RCODE

Constructors

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

Instances

Enum RCODE |
Eq RCODE |
Show RCODE |

data Question

Raw data format for DNS questions.

Constructors

Question |
Fields qname :: Domain qtype :: TYPE

Instances

Eq Question |
Show Question |

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

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