Safe Haskell | None |
---|---|
Language | Haskell2010 |
DNS message decoders.
When in doubt, use the decodeAt
or decodeManyAt
functions, which
correctly handle circle-arithmetic DNS timestamps, e.g., in RRSIG
resource records. The decode
, and decodeMany
functions are only
appropriate in pure contexts when the current time is not available, and
RRSIG
records are not expected or desired.
The decodeMany
and decodeManyAt
functions decode a buffer holding one or
more messages, each preceded by 16-bit length in network byte order. This
encoding is generally only appropriate for DNS TCP, and because TCP does not
preserve message boundaries, the decode is prepared to return a trailing
message fragment to be completed and retried when more input arrives from
network.
Synopsis
- decodeAt :: Int64 -> ByteString -> Either DNSError DNSMessage
- decode :: ByteString -> Either DNSError DNSMessage
- decodeManyAt :: Int64 -> ByteString -> Either DNSError ([DNSMessage], ByteString)
- decodeMany :: ByteString -> Either DNSError ([DNSMessage], ByteString)
Decoding a single DNS message
:: Int64 | current epoch time |
-> ByteString | encoded input buffer |
-> Either DNSError DNSMessage | decoded message or error |
Decode an input buffer containing a single encoded DNS message. If the input buffer has excess content beyond the end of the message an error is returned. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted at the supplied epoch time.
:: ByteString | encoded input buffer |
-> Either DNSError DNSMessage | decoded message or error |
Decode an input buffer containing a single encoded DNS message. If the input buffer has excess content beyond the end of the message an error is returned. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted based on a nominal time in the year 2073 chosen to maximize the time range for which this gives correct translations of 32-bit epoch times to absolute 64-bit epoch times. This will yield incorrect results starting circa 2141.
Decoding multple length-encoded DNS messages,
:: Int64 | current epoch time |
-> ByteString | encoded input buffer |
-> Either DNSError ([DNSMessage], ByteString) | decoded messages and left-over partial message or error if any complete message fails to parse. |
Decode a buffer containing multiple encoded DNS messages each preceded by a 16-bit length in network byte order. Any left-over bytes of a partial message after the last complete message are returned as the second element of the result tuple. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted at the supplied epoch time.
:: ByteString | encoded input buffer |
-> Either DNSError ([DNSMessage], ByteString) | decoded messages and left-over partial message or error if any complete message fails to parse. |
Decode a buffer containing multiple encoded DNS messages each preceded by a 16-bit length in network byte order. Any left-over bytes of a partial message after the last complete message are returned as the second element of the result tuple. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted based on a nominal time in the year 2078 chosen to give correct dates for DNS timestamps over a 136 year time range from the date the root zone was signed on the 15th of July 2010 until the 21st of August in 2146. Outside this date range the output is off by some non-zero multiple 2^32 seconds.