I'm using functions defined in arpa/nameser.h, undocumented in libc, but
explained in chapter 12 of O'Reilly's DNS & BIND (ISBN: 0-596-00158-4).
I do think that this lack of documentation is also a bug.
They are included in /usr/lib/libresolv.a from libc6-dev package, but
not in libresolv.so. Below is included a small example program to
demonstrate this.
This is the error:
$ gcc -Wall -pedantic test.c -lresolv -o test
/tmp/cc6jU6ZL.o(.text+0xa4): In function `main':
: undefined reference to `__ns_initparse'
/tmp/cc6jU6ZL.o(.text+0x124): In function `main':
: undefined reference to `__ns_parserr'
/tmp/cc6jU6ZL.o(.text+0x190): In function `main':
: undefined reference to `__ns_name_uncompress'
collect2: ld returned 1 exit status
$
But this works:
$ gcc -Wall -pedantic test.c /usr/lib/libresolv.a -o test
$
I have repeated this behaviour in Woody.
Code (test.c)
====================
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
int main(void) {
char domain[] = "debian.org";
int rlen;
u_char ans[PACKETSZ];
u_char *cp;
ns_msg handle;
ns_rr rr;
int i;
int prio;
char mx[MAXDNAME + 1];
rlen = res_query(domain, C_IN, T_MX, ans, PACKETSZ);
if(rlen < 0) {
herror("resolver");
return 1;
}
if (ns_initparse(ans, rlen, &handle) < 0) {
perror("ns_initparse");
return(1);
}
if(ns_msg_count(handle, ns_s_an) == 0) {
return(1);
}
for(i = 0; i < ns_msg_count(handle, ns_s_an); i++) {
if(ns_parserr(&handle, ns_s_an, i, &rr) < 0) {
perror("ns_parserr");
continue;
}
cp = (u_char *)ns_rr_rdata(rr);
prio = ns_get16(cp);
if(ns_name_uncompress(ns_msg_base(handle), ns_msg_end(handle),
cp + 2, mx, sizeof(mx)) < 0) {
perror("ns_name_uncompress");
continue;
}
printf("prio: %d, mx: %s\n", prio, mx);
}
return 0;
}
=========================
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (900, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-1-686
Locale: LANG=es_AR, LC_CTYPE=es_AR (charmap=ISO-8859-1)
Versions of packages libc6 depends on:
ii libdb1-compat 2.1.3-7 The Berkeley database routines [gl
-- no debconf information
--
To UNSUBSCRIBE, email to debian-bugs-...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
FYI, they are in libresolv.so, but deliberately not exported. Static
linking ignores the export checks.
Whether they should be or not, I have no opinion.
--
Daniel Jacobowitz
Hi,
I'd like to see these symbols exported in libresolv.so, as I'm currently
packaging a DNS utility which makes use of them.
--
Robert Edmonds
edm...@debian.org