summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/Makefile2
-rw-r--r--include/res_update.h (renamed from lib/libc/net/res_update.h)4
-rw-r--r--lib/libc/net/Symbol.map8
-rw-r--r--lib/libc/net/res_mkupdate.c15
-rw-r--r--lib/libc/net/res_update.c44
-rw-r--r--lib/libc/resolv/Symbol.map2
-rw-r--r--lib/libc/resolv/res_data.c6
7 files changed, 38 insertions, 43 deletions
diff --git a/include/Makefile b/include/Makefile
index ad37ab6..b274a54 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -18,7 +18,7 @@ INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
netdb.h nl_types.h nlist.h nss.h nsswitch.h objformat.h paths.h \
printf.h proc_service.h pthread.h \
pthread_np.h pwd.h ranlib.h readpassphrase.h regex.h regexp.h \
- resolv.h runetype.h search.h setjmp.h sgtty.h \
+ res_update.h resolv.h runetype.h search.h setjmp.h sgtty.h \
signal.h stab.h \
stdbool.h stddef.h stdio.h stdlib.h string.h stringlist.h \
strings.h sysexits.h tar.h tgmath.h \
diff --git a/lib/libc/net/res_update.h b/include/res_update.h
index a9528c0..b6675b2 100644
--- a/lib/libc/net/res_update.h
+++ b/include/res_update.h
@@ -61,6 +61,8 @@ typedef struct ns_updrec ns_updrec;
#define res_freeupdrec __res_freeupdrec
#define res_mkupdate __res_mkupdate
#define res_mkupdrec __res_mkupdrec
+#define res_nmkupdate __res_nmkupdate
+#define res_nupdate __res_nupdate
#if 0
#define res_update __res_update
#endif
@@ -69,6 +71,8 @@ __BEGIN_DECLS
void res_freeupdrec(ns_updrec *);
int res_mkupdate(ns_updrec *, u_char *, int);
ns_updrec * res_mkupdrec(int, const char *, u_int, u_int, u_long);
+int res_nmkupdate(res_state, ns_updrec *, u_char *, int);
+int res_nupdate(res_state, ns_updrec *, ns_tsig_key *);
int res_update(ns_updrec *);
__END_DECLS
diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map
index 1568907..c5e4866 100644
--- a/lib/libc/net/Symbol.map
+++ b/lib/libc/net/Symbol.map
@@ -90,10 +90,10 @@ FBSD_1.0 {
iruserok_sa;
rcmdsh;
recv;
- #__res_mkupdate; # Obsoleted
- #__res_mkupdrec; # Obsoleted
- #__res_freeupdrec; # Obsoleted
- #res_update; # Obsoleted Why is this not __res_update?
+ __res_freeupdrec;
+ __res_mkupdrec;
+ __res_nmkupdate;
+ __res_nupdate;
inet6_rthdr_space;
inet6_rthdr_init;
inet6_rthdr_add;
diff --git a/lib/libc/net/res_mkupdate.c b/lib/libc/net/res_mkupdate.c
index 29cb95a..ebcaba2 100644
--- a/lib/libc/net/res_mkupdate.c
+++ b/lib/libc/net/res_mkupdate.c
@@ -33,13 +33,13 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <netdb.h>
#include <resolv.h>
+#include <res_update.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
-#include "res_update.h"
#include "res_config.h"
static int getnum_str(u_char **, u_char *);
@@ -60,7 +60,7 @@ static int getword_str(char *, int, u_char **, u_char *);
* -5 unknown operation or no records
*/
int
-res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
+res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
ns_updrec *rrecp_start = rrecp_in;
HEADER *hp;
u_char *cp, *sp2, *startp, *endp;
@@ -73,11 +73,6 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
u_int32_t n1, rttl;
u_char *dnptrs[20], **dpp, **lastdnptr;
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
- return (-1);
- }
-
/*
* Initialize header fields.
*/
@@ -85,7 +80,7 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
return (-1);
memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf;
- hp->id = htons(++_res.id);
+ hp->id = htons(++statp->id);
hp->opcode = ns_o_update;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;
@@ -137,7 +132,7 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
break;
default:
fprintf(stderr,
- "res_mkupdate: incorrect opcode: %d\n",
+ "res_nmkupdate: incorrect opcode: %d\n",
rrecp->r_opcode);
fflush(stderr);
return (-1);
@@ -151,7 +146,7 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
break;
default:
fprintf(stderr,
- "res_mkupdate: incorrect opcode: %d\n",
+ "res_nmkupdate: incorrect opcode: %d\n",
rrecp->r_opcode);
fflush(stderr);
return (-1);
diff --git a/lib/libc/net/res_update.c b/lib/libc/net/res_update.c
index d78ca70..46f1efa 100644
--- a/lib/libc/net/res_update.c
+++ b/lib/libc/net/res_update.c
@@ -32,12 +32,11 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <netdb.h>
#include <resolv.h>
+#include <res_update.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "res_update.h"
-
/*
* Separate a linked list of records into groups so that all records
* in a group will belong to a single zone on the nameserver.
@@ -71,7 +70,7 @@ struct zonegrp {
int
-res_update(ns_updrec *rrecp_in) {
+res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
ns_updrec *rrecp, *tmprrecp;
u_char buf[PACKETSZ], answer[PACKETSZ], packet[2*PACKETSZ];
char name[MAXDNAME], zname[MAXDNAME], primary[MAXDNAME],
@@ -86,8 +85,9 @@ res_update(ns_updrec *rrecp_in) {
u_int16_t dlen, class, qclass, type, qtype;
u_int32_t ttl;
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ if (key != NULL) {
+ /* TSIG is not supported. */
+ RES_SET_H_ERRNO(statp, NO_RECOVERY);
return (-1);
}
@@ -150,19 +150,19 @@ res_update(ns_updrec *rrecp_in) {
}
if (done)
break;
- n = res_mkquery(QUERY, dname, qclass, qtype, NULL,
+ n = res_nmkquery(statp, QUERY, dname, qclass, qtype, NULL,
0, NULL, buf, sizeof buf);
if (n <= 0) {
- fprintf(stderr, "res_update: mkquery failed\n");
+ fprintf(stderr, "res_nupdate: mkquery failed\n");
return (n);
}
- n = res_send(buf, n, answer, sizeof answer);
+ n = res_nsend(statp, buf, n, answer, sizeof answer);
if (n < 0) {
- fprintf(stderr, "res_update: send error for %s\n",
+ fprintf(stderr, "res_nupdate: send error for %s\n",
rrecp->r_dname);
return (n);
} else if (n > sizeof(answer)) {
- fprintf(stderr, "res_update: buffer too small\n");
+ fprintf(stderr, "res_nupdate: buffer too small\n");
return (-1);
}
if (n < HFIXEDSZ)
@@ -447,7 +447,7 @@ ans=%d, auth=%d, add=%d, rcode=%d\n",
} /* while */
}
- _res.options |= RES_DEBUG;
+ statp->options |= RES_DEBUG;
for (zptr = zgrp_start; zptr; zptr = zptr->z_next) {
/* append zone section */
@@ -461,16 +461,16 @@ ans=%d, auth=%d, add=%d, rcode=%d\n",
rrecp->r_grpnext = zptr->z_rr;
zptr->z_rr = rrecp;
- n = res_mkupdate(zptr->z_rr, packet, sizeof packet);
+ n = res_nmkupdate(statp, zptr->z_rr, packet, sizeof packet);
if (n < 0) {
- fprintf(stderr, "res_mkupdate error\n");
+ fprintf(stderr, "res_nmkupdate error\n");
fflush(stderr);
return (-1);
} else
- fprintf(stdout, "res_mkupdate: packet size = %d\n", n);
+ fprintf(stdout, "res_nmkupdate: packet size = %d\n", n);
/*
- * Override the list of NS records from res_init() with
+ * Override the list of NS records from res_ninit() with
* the authoritative nameservers for the zone being updated.
* Sort primary to be the first in the list of nameservers.
*/
@@ -493,18 +493,18 @@ ans=%d, auth=%d, add=%d, rcode=%d\n",
}
}
for (i = 0; i < MAXNS; i++) {
- _res.nsaddr_list[i].sin_addr = zptr->z_ns[i].nsaddr1;
- _res.nsaddr_list[i].sin_family = AF_INET;
- _res.nsaddr_list[i].sin_port = htons(NAMESERVER_PORT);
+ statp->nsaddr_list[i].sin_addr = zptr->z_ns[i].nsaddr1;
+ statp->nsaddr_list[i].sin_family = AF_INET;
+ statp->nsaddr_list[i].sin_port = htons(NAMESERVER_PORT);
}
- _res.nscount = (zptr->z_nscount < MAXNS) ?
+ statp->nscount = (zptr->z_nscount < MAXNS) ?
zptr->z_nscount : MAXNS;
- n = res_send(packet, n, answer, sizeof(answer));
+ n = res_nsend(statp, packet, n, answer, sizeof(answer));
if (n < 0) {
- fprintf(stderr, "res_send: send error, n=%d\n", n);
+ fprintf(stderr, "res_nsend: send error, n=%d\n", n);
break;
} else if (n > sizeof(answer)) {
- fprintf(stderr, "res_send: buffer too small\n");
+ fprintf(stderr, "res_nsend: buffer too small\n");
break;
}
numzones++;
diff --git a/lib/libc/resolv/Symbol.map b/lib/libc/resolv/Symbol.map
index 6e1de65..7aa2256 100644
--- a/lib/libc/resolv/Symbol.map
+++ b/lib/libc/resolv/Symbol.map
@@ -100,4 +100,6 @@ FBSD_1.0 {
__res_close;
_res_close;
res_send;
+ __res_mkupdate;
+ res_update; # Why is this not __res_update?
};
diff --git a/lib/libc/resolv/res_data.c b/lib/libc/resolv/res_data.c
index a864b60..ab6d575 100644
--- a/lib/libc/resolv/res_data.c
+++ b/lib/libc/resolv/res_data.c
@@ -35,9 +35,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <netdb.h>
#include <resolv.h>
-#ifndef _LIBC
#include <res_update.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -156,7 +154,6 @@ res_mkquery(int op, /* opcode of query */
newrr_in, buf, buflen));
}
-#ifndef _LIBC
int
res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
@@ -166,7 +163,6 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
return (res_nmkupdate(&_res, rrecp_in, buf, buflen));
}
-#endif
int
res_query(const char *name, /* domain name */
@@ -227,7 +223,6 @@ res_close(void) {
res_nclose(&_res);
}
-#ifndef _LIBC
int
res_update(ns_updrec *rrecp_in) {
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
@@ -237,7 +232,6 @@ res_update(ns_updrec *rrecp_in) {
return (res_nupdate(&_res, rrecp_in, NULL));
}
-#endif
int
res_search(const char *name, /* domain name */
OpenPOWER on IntegriCloud