1 | /* |
---|
2 | ** OLDBIND.COMPAT.C |
---|
3 | ** |
---|
4 | ** Very old systems do not have res_query(), res_querydomain() or |
---|
5 | ** res_search(), so emulate them here. |
---|
6 | ** |
---|
7 | ** You really ought to be upgrading to a newer version of BIND |
---|
8 | ** (4.8.2 or later) rather than be using this. |
---|
9 | ** |
---|
10 | ** J.R. Oldroyd <jr@inset.com> |
---|
11 | */ |
---|
12 | |
---|
13 | #include <sys/types.h> |
---|
14 | #include <netinet/in.h> |
---|
15 | #include <arpa/nameser.h> |
---|
16 | #include <resolv.h> |
---|
17 | |
---|
18 | typedef union |
---|
19 | { |
---|
20 | HEADER qb1; |
---|
21 | char qb2[PACKETSZ]; |
---|
22 | } querybuf; |
---|
23 | |
---|
24 | res_query(dname, class, type, data, datalen) |
---|
25 | char * dname; |
---|
26 | int class; |
---|
27 | int type; |
---|
28 | char * data; |
---|
29 | int datalen; |
---|
30 | { |
---|
31 | int n; |
---|
32 | querybuf buf; |
---|
33 | |
---|
34 | n = res_mkquery(QUERY, dname, class, type, (char *) NULL, 0, |
---|
35 | NULL, (char *) &buf, sizeof buf); |
---|
36 | n = res_send((char *)&buf, n, data, datalen); |
---|
37 | |
---|
38 | return n; |
---|
39 | } |
---|
40 | |
---|
41 | res_querydomain(host, dname, class, type, data, datalen) |
---|
42 | char * host; |
---|
43 | char * dname; |
---|
44 | int class; |
---|
45 | int type; |
---|
46 | char * data; |
---|
47 | int datalen; |
---|
48 | { |
---|
49 | int n; |
---|
50 | querybuf buf; |
---|
51 | char dbuf[256]; |
---|
52 | |
---|
53 | strcpy(dbuf, host); |
---|
54 | if (dbuf[strlen(dbuf)-1] != '.') |
---|
55 | strcat(dbuf, "."); |
---|
56 | strcat(dbuf, dname); |
---|
57 | n = res_mkquery(QUERY, dbuf, class, type, (char *) NULL, 0, |
---|
58 | NULL, (char *)&buf, sizeof buf); |
---|
59 | n = res_send((char *) &buf, n, data, datalen); |
---|
60 | |
---|
61 | return n; |
---|
62 | } |
---|
63 | |
---|
64 | res_search(dname, class, type, data, datalen) |
---|
65 | char * dname; |
---|
66 | int class; |
---|
67 | int type; |
---|
68 | char * data; |
---|
69 | int datalen; |
---|
70 | { |
---|
71 | int n; |
---|
72 | querybuf buf; |
---|
73 | |
---|
74 | n = res_mkquery(QUERY, dname, class, type, (char *)NULL, 0, |
---|
75 | NULL, (char *) &buf, sizeof buf); |
---|
76 | n = res_send((char *) &buf, n, data, datalen); |
---|
77 | |
---|
78 | return n; |
---|
79 | } |
---|