From 4fa2676715d20ad9b7b01d504188a538cd20194d Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Mon, 24 Oct 2011 16:14:27 +0900 Subject: ordering. --- Network/DNS/Encode.hs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Network/DNS/Encode.hs') 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 -- cgit v1.2.3