dns-1.0.0: DNS library in Haskell

Safe Haskell | None

Network.DNS.Types

Contents

- Domain
- TYPE
- DNS Error
- DNS Format
- 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 TYPE
  - = A
  - | AAAA
  - | NS
  - | TXT
  - | MX
  - | CNAME
  - | SOA
  - | PTR
  - | SRV
  - | UNKNOWN Int
- intToType :: Int -> TYPE
- typeToInt :: TYPE -> Int
- toType :: String -> TYPE
- data DNSError
  - = SequenceNumberMismatch
  - | TimeoutExpired
  - | UnexpectedRDATA
- data DNSFormat = DNSFormat {
  - header :: DNSHeader
  - question :: [Question]
  - answer :: [ResourceRecord]
  - authority :: [ResourceRecord]
  - additional :: [ResourceRecord]
  }
- data DNSHeader = DNSHeader {
  - identifier :: Int
  - flags :: DNSFlags
  - qdCount :: Int
  - anCount :: Int
  - nsCount :: Int
  - arCount :: Int
  }
- 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
- data ResourceRecord = ResourceRecord {
  - rrname :: Domain
  - rrtype :: TYPE
  - rrttl :: Int
  - rdlen :: Int
  - rdata :: RDATA
  }
- data Question = Question {
  - qname :: Domain
  - qtype :: TYPE
  }
- data RDATA
  - = RD_NS Domain
  - | RD_CNAME 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_OTH [Int]
- responseA :: Int -> Question -> IPv4 -> DNSFormat
- responseAAAA :: Int -> Question -> IPv6 -> DNSFormat

# Domain

type Domain = ByteString Source

Type for domain.

# TYPE

data TYPE Source

Types for resource records.

Constructors

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

Instances

Eq TYPE |
Read TYPE |
Show TYPE |

intToType :: Int -> TYPE Source

typeToInt :: TYPE -> Int Source

toType :: String -> TYPE 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.
TimeoutExpired | The request simply timed out.
UnexpectedRDATA | The answer has the correct sequence number, but returned an unexpected RDATA format.

Instances

Eq DNSError |
Show DNSError |

# DNS Format

data DNSFormat Source

Raw data format for DNS Query and Response.

Constructors

DNSFormat |

Fields

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

Instances

Eq DNSFormat |
Show DNSFormat |

# DNS Header

data DNSHeader Source

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

Constructors

DNSHeader |

Fields

identifier :: Int
flags :: DNSFlags
qdCount :: Int
anCount :: Int
nsCount :: Int
arCount :: Int

Instances

Eq DNSHeader |
Show DNSHeader |

# 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

Instances

Eq DNSFlags |
Show DNSFlags |

# DNS Body

data QorR Source

Constructors

QR_Query |
QR_Response |

Instances

Eq QorR |
Show QorR |

data OPCODE Source

Constructors

OP_STD |
OP_INV |
OP_SSR |

Instances

Enum OPCODE |
Eq OPCODE |
Show OPCODE |

data RCODE Source

Constructors

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

Instances

Enum RCODE |
Eq RCODE |
Show RCODE |

data ResourceRecord Source

Raw data format for resource records.

Constructors

ResourceRecord |

Fields

rrname :: Domain
rrtype :: TYPE
rrttl :: Int
rdlen :: Int
rdata :: RDATA

Instances

Eq ResourceRecord |
Show ResourceRecord |

data Question Source

Raw data format for DNS questions.

Constructors

Question |

Fields

qname :: Domain
qtype :: TYPE

Instances

Eq Question |
Show Question |

data RDATA Source

Raw data format for each type.

Constructors

RD_NS Domain |
RD_CNAME 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_OTH [Int] |

Instances

Eq RDATA |
Show RDATA |

responseA :: Int -> Question -> IPv4 -> DNSFormat Source

responseAAAA :: Int -> Question -> IPv6 -> DNSFormat Source