hi folks,
This is a more detailed update to the previous post.
Problem : to determine whether the DNS Nameserver functions (
prototypes in <arpa/nameser.h> ) are user-defined or built in in the
libresolv library!!!!
Source file : myDns.c which uses 'ns_name_uncompress' and 'ns_parserr'
functions which are declared in the mentioned header file. But while
ns_parserr(...) works without any user-defined body, the
ns_name_uncompress(...) function gives linker error without a
user-defined body. Why the disparity? Can anyone please enlighten me?
Here's a part of the process :
[timmyj@ibis:/users/in1478c/GUIDEPROGS~]gcc -Wall -g myDns.c -lsocket
-lnsl -lresolv
myDns.c: In function `send_ptr_query':
myDns.c:108: warning: initialization from incompatible pointer type
myDns.c:108: warning: initialization from incompatible pointer type
Undefined first referenced
symbol in file
__ns_name_uncompress /var/tmp//ccGTqvma.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
[timmyj@ibis:/users/in1478c/GUIDEPROGS~]
The function ns_name_uncompress is geiven as a prototype in
<arpa/nameser.h>
but the file 'myDns.c' does not contain the definition. ( It is present
in another source file called 'rr_name.c'...) But some other functions
such as 'ns_parserr' whose prototypes are present in the same header
file and whose bodies are not defined in the 'myDns.c' source file do
not generate any error!!!
The calling function is :
if (ns_name_uncompress(
ns_msg_base(handle),/* Start of the
packet */
ns_msg_end(handle), /* End of the
packet */
ns_rr_rdata(rr), /* Position in the
packet*/
hostname, /*Result*/
255) /* Size of server
name buffer */
< 0)
{ /* Negative: error */
printf(", ns_name_uncompress failed on %dth
record\n",rrnum);
continue;
}
printf(", Server name : %s\n", hostname);
The types are as follows :
// The code from the header file arpa/nameser.h
typedef struct __ns_msg {
const uchar_t *_msg, *_eom;
uint16_t _id, _flags, _counts[ns_s_max];
const uchar_t *_sections[ns_s_max];
ns_sect _sect;
int _rrnum;
const uchar_t *_ptr;
} ns_msg;
/* Private data structure - do not use from outside library. */
struct _ns_flagdata { int mask, shift; };
extern struct _ns_flagdata _ns_flagdata[];
/* Accessor macros - this is part of the public interface. */
#define ns_msg_id(handle) ((handle)._id + 0)
#define ns_msg_base(handle) ((handle)._msg + 0)
#define ns_msg_end(handle) ((handle)._eom + 0)
#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
The prototype of the ns_name_uncompress function given in the
<arpa/nameser.h> header file is :
int ns_name_uncompress(const uchar_t *, const uchar_t *,
const uchar_t *, char *, size_t);
As you can see, the types in the prototype and the invocation are the
same!!!!
Any ideas, please?!
Regards,
Timmy Jose.
|