diff options
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 |