Mx lookup via res_query in C

Jim Reid jim at rfc1035.com
Thu Aug 17 18:08:38 UTC 2000


>>>>> "Mikael" == Mikael Chambon <quanta at akasha.cronos.org> writes:

    Mikael> HEllo, I am trying to do a MX lookup in C (under linux
    Mikael> RH6.2), in order to do it I use the res_query function
    Mikael> that should do the job.

    Mikael> int res_query(const char *dname, int class, int type,
    Mikael>               unsigned char *answer, int anslen);

    Mikael> The problem is that I can't find any information about the
    Mikael> "type", It should be there that I write MX. But what is
    Mikael> the proper Integer that I should write to do a MX lookup
    Mikael> ??  If someone has some informations ...

    Mikael> I 've already check in /usr/include/resolv.h and
    Mikael> res_query.c but I didn't find anything..

The type parameter should be the QTYPE code for the resource record.
In this case that would be 15, the value defined in RFC1035 for an MX
record. You'll usually find a list of mnemonics and code values for
resource records in <arpa/nameser.h>. I'm sure there will be examples
of how to do MX record lookups in any of the open source mail
implementations like sendmail or Postfix.



More information about the bind-users mailing list