summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libresolv2/common/sunw/sunw_updrec.c')
-rw-r--r--usr/src/lib/libresolv2/common/sunw/sunw_updrec.c77
1 files changed, 62 insertions, 15 deletions
diff --git a/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c b/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c
index c9bc2b2038..3b0ffc49df 100644
--- a/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c
+++ b/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c
@@ -1,10 +1,8 @@
/*
- * Copyright (c) 1999 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* As of BIND 8.2.2, ISC (a) removed res_mkupdate(), res_update(), and
* res_mkupdrec() from what they consider the supported interface. The
@@ -25,19 +23,25 @@
#include <sys/types.h>
#include <netinet/in.h>
+/* get the Solaris ns_updrec before any renaming happens */
+#include <arpa/nameser.h>
+
+/* get the __ISC_ns_updrec */
#include <res_update.h>
+
+#include <port_after.h>
+
+/* un-rename ns_updrec and res_* functions so we can wrap them */
#undef ns_updrec
#undef res_mkupdate
#undef res_update
#undef res_mkupdrec
#undef res_freeupdrec
-#include <arpa/nameser.h>
-
-#include <port_after.h>
+#undef res_nmkupdate
+#undef res_nupdate
void res_freeupdrec(ns_updrec *);
-
static int
old2new(ns_updrec *old, __ISC_ns_updrec *new) {
@@ -106,7 +110,7 @@ delete_list(__ISC_ns_updrec *list) {
static __ISC_ns_updrec *
-copy_list(ns_updrec *old) {
+copy_list(ns_updrec *old, int do_glink) {
__ISC_ns_updrec *list = 0, *r, *p;
@@ -122,23 +126,34 @@ copy_list(ns_updrec *old) {
}
r->r_link.prev = p;
r->r_link.next = 0;
- if (p != 0)
+ /* res_update and res_nupdate want r_glink set up like this */
+ if (do_glink) {
+ r->r_glink.prev = p;
+ r->r_glink.next = 0;
+ } else {
+ r->r_glink.prev = (void *)-1;
+ r->r_glink.next = (void *)-1;
+ }
+ if (p != 0) {
p->r_link.next = r;
- else
+ if (do_glink) {
+ p->r_glink.next = r;
+ }
+ } else {
list = r;
+ }
}
-
return (list);
}
int
-res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int length) {
+res_mkupdate(ns_updrec *rrecp_in, uchar_t *buf, int length) {
__ISC_ns_updrec *r;
int ret;
- if ((r = copy_list(rrecp_in)) == 0)
+ if ((r = copy_list(rrecp_in, 1)) == 0)
return (-1);
ret = __ISC_res_mkupdate(r, buf, length);
@@ -148,6 +163,22 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int length) {
return (ret);
}
+int
+res_nmkupdate(res_state statp, ns_updrec *rrecp_in, uchar_t *buf, int length) {
+
+ __ISC_ns_updrec *r;
+ int ret;
+
+ if ((r = copy_list(rrecp_in, 1)) == 0)
+ return (-1);
+
+ ret = __ISC_res_nmkupdate(statp, r, buf, length);
+
+ delete_list(r);
+
+ return (ret);
+}
+
int
res_update(ns_updrec *rrecp_in) {
@@ -155,7 +186,7 @@ res_update(ns_updrec *rrecp_in) {
__ISC_ns_updrec *r;
int ret;
- if ((r = copy_list(rrecp_in)) == 0)
+ if ((r = copy_list(rrecp_in, 0)) == 0)
return (-1);
ret = __ISC_res_update(r);
@@ -165,6 +196,22 @@ res_update(ns_updrec *rrecp_in) {
return (ret);
}
+int
+res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
+
+ __ISC_ns_updrec *r;
+ int ret;
+
+ if ((r = copy_list(rrecp_in, 0)) == 0)
+ return (-1);
+
+ ret = __ISC_res_nupdate(statp, r, key);
+
+ delete_list(r);
+
+ return (ret);
+}
+
ns_updrec *