Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.unix.programmer Subject: Re: Resolver API question Date: Wed, 30 Mar 2016 15:54:16 +0100 Lines: 47 Message-ID: <87mvpg3tk7.fsf@doppelsaurus.mobileactivedefense.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net WOIC9xD2naEzdnf7s0KIjAsaYaeC755VQdhQfChMRQ+yCwx88= Cancel-Lock: sha1:I7w7Xi94u/IdDxG0ZlaCjpRCx+Y= sha1:Wd/0jIWnx4z7AG0g+yc0Dn+DrBQ= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Xref: csiph.com comp.unix.programmer:8278 spud@potato.field writes: > On Tue, 29 Mar 2016 11:35:00 -0400 > Barry Margolin wrote: >>In article , spud@potato.field wrote: >> >>> I'm trying to decode the rdata field returned in a resource record by the >>> ns_parserr() function. eg: >>> >>> ns_parserr(&msg,ns_s_an,i,&r_rec); >>> rdata = ns_rr_rdata(r_rec); >>> >>> However the ns_name_uncompress() function only seems to work with rdata in >> NS records [...] >>There's no name in the rdata of an A record, it just has an IP address, >>which is in binary. And for an MX record you have to skip over the >>priority field to get to the server name. > > I'm presuming that priority field is a subfield of the rdata field in the > resource record because its not a field defined in the ns_rr structure? DNS answers contain so-called 'resource records' of various types and the resource record data (rdata) format depends on the type, eg, for MX records, RFC1035 says ,---- | 3.3.9. MX RDATA format | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | PREFERENCE | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / EXCHANGE / | / / | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | where: | | PREFERENCE A 16 bit integer which specifies the preference given to | this RR among others at the same owner. Lower values | are preferred. | | EXCHANGE A which specifies a host willing to act as | a mail exchange for the owner name. `---- https://tools.ietf.org/html/rfc1035