spf-discuss
[Top] [All Lists]

Re: Length of txt records

2004-06-22 10:17:55
On Tue, 22 Jun 2004 08:54:21 -0400, Hector Santos
<winserver(_dot_)support(_at_)winserver(_dot_)com> wrote:

I don't remember the details but when writing/updating our DNS client to
support SPF TXT lookups,  I found that TXT record are "delimited" every 255
bytes.

Sorry my mistake, a TXT record can be up to 64K, but it's made up of
"one or more strings" (up to 255 bytes each) and a DNS record carried
by UDP should be under 512 bytes total (this is a feature of the
underlying frame size - over ethernet you can normally get 1500 bytes
or so easily but where carried over other layers the number can be
smaller).

To clear it up (and your other questions) heres some extracts from
RFC1035 which, I have to say, is not one of the best laid out RFCs
I've seen (no excuse, I know)  !

Section 4.2.1: "Messages carried by UDP are restricted to 512 bytes " 

Section 3.3.14 says "TXT-DATA  One or more <character-string>s. - TXT
RRs are used to hold descriptive text.  The semantics of the text
depends on the domain where it is found.", and section 3.3 describes
the format: "<character-string> is a single
length octet followed by that number of characters.  <character-string>
is treated as binary information, and can be up to 256 characters in
length (including the length octet)."

Section 3.1 describes encoding domain names for different record
types: "Domain names in messages are expressed in terms of a sequence
of labels. Each label is represented as a one octet length field
followed by that number of octets.  Since every domain name ends with
the null label of the root, a domain name is terminated by a length
byte of zero.  The high order two bits of every length octet must be
zero, and the remaining six bits of the length field limit the label
to 63 octets or less." - so that matches up with the code you quoted
and would be used for records types such as MX and CNAME which are
explicitly documented as holding domain names.

The reason for the two high bits being 0 is so that they can compress
messages by avoiding repeating domain names. Section 4.1.4 describes
the compression (quoting the offset to previous use of the same name):
"The first two bits are ones.  This allows a pointer to be
distinguished from a label, since the label must begin with two zero
bits because labels are restricted to 63 octets or less.  (The 10 and
01 combinations are reserved for future use.) "

So sorry - I'll pull my head back in.

--
T


<Prev in Thread] Current Thread [Next in Thread>