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 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 |
Show ResourceRecord Source |

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 |

Instances

Eq RData Source |
Show RData Source |

data OData Source

Constructors

OD_ClientSubnet Int Int IP |
OD_Unknown Int ByteString |

Instances

Eq OData Source |
Show OData Source |

## Resource Record Type

data TYPE Source

Types for resource records.

Constructors

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

Instances

Eq TYPE Source |
Read TYPE Source |
Show TYPE Source |

intToType :: Int -> TYPE Source

typeToInt :: TYPE -> Int Source

data OPTTYPE Source

Constructors

ClientSubnet |
OUNKNOWN Int |

Instances

Eq OPTTYPE Source |

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.
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 Source |
Show DNSError Source |
Exception DNSError Source |

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

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

# 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 Source |
Show DNSFlags Source |

# DNS Body

data QorR Source

Constructors

QR_Query |
QR_Response |

Instances

Eq QorR Source |
Show QorR Source |

data OPCODE Source

Constructors

OP_STD |
OP_INV |
OP_SSR |

Instances

Enum OPCODE Source |
Eq OPCODE Source |
Show OPCODE Source |

data RCODE Source

Constructors

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

Instances

Enum RCODE Source |
Eq RCODE Source |
Show RCODE Source |

data Question Source

Raw data format for DNS questions.

Constructors

Question |

Fields

qname :: Domain
qtype :: TYPE

Instances

Eq Question Source |
Show Question Source |

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

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