diff options
author | Kazu Yamamoto <kazu@iij.ad.jp> | 2011-10-24 16:14:27 +0900 |
---|---|---|
committer | Kazu Yamamoto <kazu@iij.ad.jp> | 2011-10-24 16:14:27 +0900 |
commit | 4fa2676715d20ad9b7b01d504188a538cd20194d (patch) | |
tree | f0e16437255a996f456b9ccebd6a2bb24783c0df /Network/DNS/Encode.hs | |
parent | d16870464640fcd94d318a919dbf10eec0f96ee3 (diff) |
ordering.
Diffstat (limited to 'Network/DNS/Encode.hs')
-rw-r--r-- | Network/DNS/Encode.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Network/DNS/Encode.hs b/Network/DNS/Encode.hs index 6116a04..c3457f2 100644 --- a/Network/DNS/Encode.hs +++ b/Network/DNS/Encode.hs @@ -1,5 +1,8 @@ {-# LANGUAGE RecordWildCards #-} -module Network.DNS.Encode (encode) where +module Network.DNS.Encode ( + encode + , composeQuery + ) where import qualified Data.ByteString.Lazy.Char8 as BL (ByteString) import qualified Data.ByteString.Char8 as BS (length, null, break, drop) @@ -16,6 +19,22 @@ import Data.IP ---------------------------------------------------------------- +{-| Composing query. First argument is a number to identify response. +-} +composeQuery :: Int -> [Question] -> BL.ByteString +composeQuery idt qs = encode qry + where + hdr = header defaultQuery + qry = defaultQuery { + header = hdr { + identifier = idt + , qdCount = length qs + } + , question = qs + } + +---------------------------------------------------------------- + {-| Composing DNS data. -} encode :: DNSFormat -> BL.ByteString |