X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FDNS%2FMessage.hs;h=9713dd2a707ed66d8776458733401346d7eb2e72;hb=248b1c63284bbe00550bf2402ee6a9da6997143e;hp=17c037f7dba99a18a3c4457f670a5aaa017b5a54;hpb=caf521ccd3edd8a9f042d1aa8a097b98cf40c1da;p=haskell-dns.git diff --git a/Network/DNS/Message.hs b/Network/DNS/Message.hs index 17c037f..9713dd2 100644 --- a/Network/DNS/Message.hs +++ b/Network/DNS/Message.hs @@ -19,8 +19,8 @@ module Network.DNS.Message , SOAFields(..) , WKSFields(..) - , SomeQ - , SomeRR + , SomeQ(..) + , SomeRR(..) , A(..) , NS(..) @@ -50,6 +50,14 @@ module Network.DNS.Message , HS(..) , mkDomainName + , mkDN + , rootName + , isRootName + , consLabel + , unconsLabel + , nameToLabels + , isZoneOf + , wrapQuestion , wrapRecord ) @@ -70,6 +78,7 @@ import qualified Data.IntMap as IM import Data.IntMap (IntMap) import qualified Data.IntSet as IS import Data.IntSet (IntSet) +import Data.List import qualified Data.Map as M import Data.Map (Map) import Data.Word @@ -224,6 +233,12 @@ unconsLabel :: DomainName -> (DomainLabel, DomainName) unconsLabel (DN (x:xs)) = (x, DN xs) unconsLabel x = error ("Illegal use of unconsLabel: " ++ show x) +nameToLabels :: DomainName -> [DomainLabel] +nameToLabels (DN xs) = xs + +isZoneOf :: DomainName -> DomainName -> Bool +isZoneOf (DN a) (DN b) = a `isSuffixOf` b + mkDomainName :: String -> DomainName mkDomainName = DN . mkLabels [] . notEmpty where @@ -237,6 +252,9 @@ mkDomainName = DN . mkLabels [] . notEmpty -> mkLabels (C8.pack l : soFar) rest _ -> error ("Illegal domain name: " ++ xs) +mkDN :: String -> DomainName +mkDN = mkDomainName + class (Show rc, Eq rc, Typeable rc) => RecordClass rc where rcToInt :: rc -> Int @@ -904,4 +922,4 @@ wrapQuestion :: (QueryType qt, QueryClass qc) => Question qt qc -> SomeQ wrapQuestion = SomeQ wrapRecord :: (RecordType rt dt, RecordClass rc) => ResourceRecord rt rc dt -> SomeRR -wrapRecord = SomeRR \ No newline at end of file +wrapRecord = SomeRR