]> gitweb @ CieloNegro.org - haskell-dns.git/blobdiff - Network/DNS/Message.hs
DomainMap: totally untested yet
[haskell-dns.git] / Network / DNS / Message.hs
index 17c037f7dba99a18a3c4457f670a5aaa017b5a54..9713dd2a707ed66d8776458733401346d7eb2e72 100644 (file)
@@ -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