]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Use ISC result codes instead of NS rcodes to report update errors.
authorTed Lemon <source@isc.org>
Tue, 16 Jan 2001 22:34:47 +0000 (22:34 +0000)
committerTed Lemon <source@isc.org>
Tue, 16 Jan 2001 22:34:47 +0000 (22:34 +0000)
13 files changed:
includes/isc/result.h
minires/Makefile.dist
minires/ns_parse.c
minires/ns_samedomain.c
minires/ns_sign.c
minires/ns_verify.c
minires/res_findzonecut.c
minires/res_mkquery.c
minires/res_query.c
minires/res_send.c
minires/res_sendsigned.c
minires/res_update.c
omapip/result.c

index dc940345002c41fa7b1eb57203e21d2462f0d9d1..ad6f39fe5bbdfe6afa81c94a36492180a141e60d 100644 (file)
 
 ISC_LANG_BEGINDECLS
 
-#define ISC_R_SUCCESS                  0
-#define ISC_R_NOMEMORY                 1
-#define ISC_R_TIMEDOUT                 2
-#define ISC_R_NOTHREADS                        3
-#define ISC_R_ADDRNOTAVAIL             4
-#define ISC_R_ADDRINUSE                        5
-#define ISC_R_NOPERM                   6
-#define ISC_R_NOCONN                   7
-#define ISC_R_NETUNREACH               8
-#define ISC_R_HOSTUNREACH              9
-#define ISC_R_NETDOWN                  10
-#define ISC_R_HOSTDOWN                 11
-#define ISC_R_CONNREFUSED              12
-#define ISC_R_NORESOURCES              13      /* not enough resources */
-#define ISC_R_EOF                      14      /* end of file */
-#define ISC_R_BOUND                    15      /* already bound */
-#define ISC_R_TASKDONE                 16      /* task is done */
-#define ISC_R_LOCKBUSY                 17
-#define ISC_R_EXISTS                   18
-#define ISC_R_NOSPACE                  19      /* ran out of space */
-#define ISC_R_CANCELED                 20
-#define ISC_R_TASKNOSEND               21
-#define ISC_R_SHUTTINGDOWN             22      /* shutting down */
-#define ISC_R_NOTFOUND                 23
-#define ISC_R_UNEXPECTEDEND            24      /* unexpected end of input */
-#define ISC_R_FAILURE                  25      /* generic failure */
-#define ISC_R_IOERROR                  26
-#define ISC_R_NOTIMPLEMENTED           27
-#define ISC_R_UNBALANCED               28
-#define ISC_R_NOMORE                   29
-#define ISC_R_INVALIDFILE              30
-#define ISC_R_BADBASE64                        31
-#define ISC_R_UNEXPECTEDTOKEN          32
-#define ISC_R_QUOTA                    33
-#define ISC_R_UNEXPECTED               34
-#define ISC_R_ALREADYRUNNING           35
-#define ISC_R_HOSTUNKNOWN              36
-#define ISC_R_VERSIONMISMATCH          37
-#define ISC_R_PROTOCOLERROR            38
-#define ISC_R_INVALIDARG               39
-#define ISC_R_NOTCONNECTED             40
-#define ISC_R_NOTYET                   41
-#define ISC_R_UNCHANGED                        42
-#define ISC_R_MULTIPLE                 43
-#define ISC_R_KEYCONFLICT              44
-#define ISC_R_BADPARSE                 45
-#define ISC_R_NOKEYS                   46
-#define ISC_R_KEY_UNKNOWN              47
-#define ISC_R_INVALIDKEY               48
-#define ISC_R_INCOMPLETE               49
-#define ISC_R_FORMERR                  50
-#define        ISC_R_SERVFAIL                  51
-#define        ISC_R_NXDOMAIN                  52
-#define        ISC_R_NOTIMPL                   53
-#define        ISC_R_REFUSED                   54
-#define        ISC_R_YXDOMAIN                  55
-#define        ISC_R_YXRRSET                   56
-#define        ISC_R_NXRRSET                   57
-#define        ISC_R_NOTAUTH                   58
-#define        ISC_R_NOTZONE                   59
-#define        ISC_R_BADSIG                    60
-#define        ISC_R_BADKEY                    61
-#define        ISC_R_BADTIME                   62
+typedef enum {
+       ISC_R_SUCCESS = 0,
+       ISC_R_NOMEMORY = 1,
+       ISC_R_TIMEDOUT = 2,
+       ISC_R_NOTHREADS = 3,
+       ISC_R_ADDRNOTAVAIL = 4,
+       ISC_R_ADDRINUSE = 5,
+       ISC_R_NOPERM = 6,
+       ISC_R_NOCONN = 7,
+       ISC_R_NETUNREACH = 8,
+       ISC_R_HOSTUNREACH = 9,
+       ISC_R_NETDOWN = 10,
+       ISC_R_HOSTDOWN = 11,
+       ISC_R_CONNREFUSED = 12,
+       ISC_R_NORESOURCES = 13,
+       ISC_R_EOF = 14,
+       ISC_R_BOUND = 15,
+       ISC_R_TASKDONE = 16,
+       ISC_R_LOCKBUSY = 17,
+       ISC_R_EXISTS = 18,
+       ISC_R_NOSPACE = 19,
+       ISC_R_CANCELED = 20,
+       ISC_R_TASKNOSEND = 21,
+       ISC_R_SHUTTINGDOWN = 22,
+       ISC_R_NOTFOUND = 23,
+       ISC_R_UNEXPECTEDEND = 24,
+       ISC_R_FAILURE = 25,
+       ISC_R_IOERROR = 26,
+       ISC_R_NOTIMPLEMENTED = 27,
+       ISC_R_UNBALANCED = 28,
+       ISC_R_NOMORE = 29,
+       ISC_R_INVALIDFILE = 30,
+       ISC_R_BADBASE64 = 31,
+       ISC_R_UNEXPECTEDTOKEN = 32,
+       ISC_R_QUOTA = 33,
+       ISC_R_UNEXPECTED = 34,
+       ISC_R_ALREADYRUNNING = 35,
+       ISC_R_HOSTUNKNOWN = 36,
+       ISC_R_VERSIONMISMATCH = 37,
+       ISC_R_PROTOCOLERROR = 38,
+       ISC_R_INVALIDARG = 39,
+       ISC_R_NOTCONNECTED = 40,
+       ISC_R_NOTYET = 41,
+       ISC_R_UNCHANGED = 42,
+       ISC_R_MULTIPLE = 43,
+       ISC_R_KEYCONFLICT = 44,
+       ISC_R_BADPARSE = 45,
+       ISC_R_NOKEYS = 46,
+       ISC_R_KEY_UNKNOWN = 47,
+       ISC_R_INVALIDKEY = 48,
+       ISC_R_INCOMPLETE = 49,
+       ISC_R_FORMERR = 50,
+       ISC_R_SERVFAIL = 51,
+       ISC_R_NXDOMAIN = 52,
+       ISC_R_NOTIMPL = 53,
+       ISC_R_REFUSED = 54,
+       ISC_R_YXDOMAIN = 55,
+       ISC_R_YXRRSET = 56,
+       ISC_R_NXRRSET = 57,
+       ISC_R_NOTAUTH = 58,
+       ISC_R_NOTZONE = 59,
+       ISC_R_BADSIG = 60,
+       ISC_R_BADKEY = 61,
+       ISC_R_BADTIME = 62,
+       ISC_R_NOROOTZONE = 63,
+       ISC_R_DESTADDRREQ = 64,
+       ISC_R_CROSSZONE = 65,
+       ISC_R_NO_TSIG = 66,
+       ISC_R_NOT_EQUAL = 67
+} isc_result_t;
 
-#define ISC_R_NRESULTS                         63      /* Number of results */
+
+#define ISC_R_NRESULTS                         68      /* Number of results */
 
 const char *           isc_result_totext(isc_result_t);
 isc_result_t           isc_result_register(unsigned int base,
index c0525f19a400f806c876119dc6a89391f6657abb..bd785b675396ee5ac2e20c9391fee97262ca7019 100644 (file)
@@ -23,11 +23,13 @@ MAN    = dhcpctl.3
 SRC    = res_mkupdate.c res_init.c res_update.c res_send.c res_comp.c \
         res_sendsigned.c res_findzonecut.c res_query.c res_mkquery.c \
         ns_date.c ns_parse.c ns_sign.c ns_name.c ns_samedomain.c ns_verify.c \
-        dst_api.c hmac_link.c md5_dgst.c prandom.c support.c base64.c
+        dst_api.c hmac_link.c md5_dgst.c prandom.c support.c base64.c \
+        toisc.c
 OBJ    = res_mkupdate.o res_init.o res_update.o res_send.o res_comp.o \
         res_sendsigned.o res_findzonecut.o res_query.o res_mkquery.o \
         ns_date.o ns_parse.o ns_sign.o ns_name.o ns_samedomain.o ns_verify.o \
-        dst_api.o hmac_link.o md5_dgst.o prandom.o support.o base64.o
+        dst_api.o hmac_link.o md5_dgst.o prandom.o support.o base64.o \
+        toisc.o
 HDRS   = dst_internal.h md5.h md5_locl.h
 
 DEBUG  = -g
index 2eb989921993a7f2da257533b332745f4ce12f85..27b06a1adca0688ba31d8054e99faf8cd89f6560 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_parse.c,v 1.1 2000/02/02 07:28:15 mellon Exp $";
+static const char rcsid[] = "$Id: ns_parse.c,v 1.2 2001/01/16 22:33:08 mellon Exp $";
 #endif
 
 /* Import. */
@@ -127,13 +127,13 @@ ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
        return (0);
 }
 
-int
+isc_result_t
 ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
        int b;
 
        /* Make section right. */
        if (section < 0 || section >= ns_s_max)
-               RETERR(ENODEV);
+               return ISC_R_NOTIMPLEMENTED;
        if (section != handle->_sect)
                setsection(handle, section);
 
@@ -161,7 +161,7 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
                return (-1);
        handle->_ptr += b;
        if (handle->_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
-               RETERR(EMSGSIZE);
+               return ISC_R_NOSPACE;
        rr->type = getUShort (handle->_ptr);
        handle -> _ptr += 2;
        rr->rr_class = getUShort (handle->_ptr);
@@ -172,13 +172,13 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
                rr->rdata = NULL;
        } else {
                if (handle->_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
-                       RETERR(EMSGSIZE);
+                       return ISC_R_NOSPACE;
                rr->ttl = getULong (handle->_ptr);
                handle -> _ptr += 4;
                rr->rdlength = getUShort (handle->_ptr);
                handle -> _ptr += 2;
                if (handle->_ptr + rr->rdlength > handle->_eom)
-                       RETERR(EMSGSIZE);
+                       return ISC_R_NOSPACE;
                rr->rdata = handle->_ptr;
                handle->_ptr += rr->rdlength;
        }
@@ -186,7 +186,7 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
                setsection(handle, (ns_sect)((int)section + 1));
 
        /* All done. */
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
 /* Private. */
index cc689a3617bf0c2b9735fe6320ba77b4a8c75cee..ac17a52378e856d31fbfacfd216ff63f0fe67dae 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_samedomain.c,v 1.2 2000/02/02 19:59:15 mellon Exp $";
+static const char rcsid[] = "$Id: ns_samedomain.c,v 1.3 2001/01/16 22:33:09 mellon Exp $";
 #endif
 
 #include <sys/types.h>
@@ -163,13 +163,12 @@ ns_subdomain(const char *a, const char *b) {
  *     foo\\. -> foo\\.
  */
 
-int
+isc_result_t
 ns_makecanon(const char *src, char *dst, size_t dstsize) {
        size_t n = strlen(src);
 
        if (n + sizeof "." > dstsize) {
-               errno = EMSGSIZE;
-               return (-1);
+               ISC_R_NOSPACE;
        }
        strcpy(dst, src);
        while (n > 0 && dst[n - 1] == '.')              /* Ends in "." */
@@ -180,7 +179,7 @@ ns_makecanon(const char *src, char *dst, size_t dstsize) {
                        dst[--n] = '\0';
        dst[n++] = '.';
        dst[n] = '\0';
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
 /*
@@ -196,9 +195,13 @@ ns_makecanon(const char *src, char *dst, size_t dstsize) {
 int
 ns_samename(const char *a, const char *b) {
        char ta[NS_MAXDNAME], tb[NS_MAXDNAME];
+       isc_result_t status;
 
-       if (ns_makecanon(a, ta, sizeof ta) < 0 ||
-           ns_makecanon(b, tb, sizeof tb) < 0)
+       status = ns_makecanon(a, ta, sizeof ta);
+       if (status != ISC_R_SUCCESS)
+               return status;
+       status = ns_makecanon(b, tb, sizeof tb);
+       if (status != ISC_R_SUCCESS)
                return (-1);
        if (strcasecmp(ta, tb) == 0)
                return (1);
index 60d9693df05462a0b29e322cff6dbeeeb7ba479b..641751f5f1837add16b1c84c7409dda78f4f3dff 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2000/02/02 19:59:15 mellon Exp $";
+static const char rcsid[] = "$Id: ns_sign.c,v 1.3 2001/01/16 22:33:10 mellon Exp $";
 #endif
 
 /* Import. */
@@ -44,8 +44,7 @@ static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2000/02/02 19:59:15 mellon Exp
 #define BOUNDS_CHECK(ptr, count) \
        do { \
                if ((ptr) + (count) > eob) { \
-                       errno = EMSGSIZE; \
-                       return(NS_TSIG_ERROR_NO_SPACE); \
+                       return ISC_R_NOSPACE; \
                } \
        } while (0)
 
@@ -68,7 +67,7 @@ static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2000/02/02 19:59:15 mellon Exp
  *     - bad key / sign failed (-BADKEY)
  *     - not enough space (NS_TSIG_ERROR_NO_SPACE)
  */
-int
+isc_result_t
 ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
        const u_char *querysig, unsigned querysiglen, u_char *sig,
        unsigned *siglen, time_t in_timesigned)
@@ -83,7 +82,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
 
        dst_init();
        if (msg == NULL || msglen == NULL || sig == NULL || siglen == NULL)
-               return (-1);
+               ISC_R_INVALIDARG;
 
        /* Name. */
        if (key != NULL && error != ns_r_badsig && error != ns_r_badkey)
@@ -92,7 +91,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
        else
                n = dn_comp("", cp, (unsigned)(eob - cp), NULL, NULL);
        if (n < 0)
-               return (NS_TSIG_ERROR_NO_SPACE);
+               return ISC_R_NOSPACE;
        name = cp;
        cp += n;
 
@@ -107,14 +106,14 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
        /* Alg. */
        if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) {
                if (key->dk_alg != KEY_HMAC_MD5)
-                       return (-ns_r_badkey);
+                       return ISC_R_BADKEY;
                n = dn_comp(NS_TSIG_ALG_HMAC_MD5,
                            cp, (unsigned)(eob - cp), NULL, NULL);
        }
        else
                n = dn_comp("", cp, (unsigned)(eob - cp), NULL, NULL);
        if (n < 0)
-               return (NS_TSIG_ERROR_NO_SPACE);
+               ISC_R_NOSPACE;
        alg = cp;
        cp += n;
        
@@ -186,7 +185,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
                n = dst_sign_data(SIG_MODE_FINAL, key, &ctx, NULL, 0,
                                  sig, *siglen);
                if (n < 0)
-                       return (-ns_r_badkey);
+                       ISC_R_BADKEY;
                *siglen = n;
        } else
                *siglen = 0;
@@ -218,28 +217,29 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
 
        hp->arcount = htons(ntohs(hp->arcount) + 1);
        *msglen = (cp - msg);
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
-int
+#if 0
+isc_result_t
 ns_sign_tcp_init(void *k, const u_char *querysig, unsigned querysiglen,
                 ns_tcp_tsig_state *state)
 {
        dst_init();
        if (state == NULL || k == NULL || querysig == NULL || querysiglen < 0)
-               return (-1);
+               return ISC_R_INVALIDARG;
        state->counter = -1;
        state->key = k;
        if (state->key->dk_alg != KEY_HMAC_MD5)
-               return (-ns_r_badkey);
+               return ISC_R_BADKEY;
        if (querysiglen > sizeof(state->sig))
-               return (-1);
+               return ISC_R_NOSPACE;
        memcpy(state->sig, querysig, querysiglen);
        state->siglen = querysiglen;
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
-int
+isc_result_t
 ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
            ns_tcp_tsig_state *state, int done)
 {
@@ -250,13 +250,13 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
        int n;
 
        if (msg == NULL || msglen == NULL || state == NULL)
-               return (-1);
+               return ISC_R_INVALIDARG;
 
        state->counter++;
        if (state->counter == 0)
-               return (ns_sign(msg, msglen, msgsize, error, state->key,
-                               state->sig, state->siglen,
-                               state->sig, &state->siglen, 0));
+               return ns_sign(msg, msglen, msgsize, error, state->key,
+                              state->sig, state->siglen,
+                              state->sig, &state->siglen, 0);
 
        if (state->siglen > 0) {
                u_int16_t siglen_n = htons(state->siglen);
@@ -273,7 +273,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
                      NULL, 0);
 
        if (done == 0 && (state->counter % 100 != 0))
-               return (0);
+               return ISC_R_SUCCESS;
 
        cp = msg + *msglen;
        eob = msg + msgsize;
@@ -282,7 +282,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
        n = dn_comp(state->key->dk_key_name,
                    cp, (unsigned)(eob - cp), NULL, NULL);
        if (n < 0)
-               return (NS_TSIG_ERROR_NO_SPACE);
+               return ISC_R_NOSPACE;
        cp += n;
 
        /* Type, class, ttl, length (not filled in yet). */
@@ -297,7 +297,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
        n = dn_comp(NS_TSIG_ALG_HMAC_MD5,
                    cp, (unsigned)(eob - cp), NULL, NULL);
        if (n < 0)
-               return (NS_TSIG_ERROR_NO_SPACE);
+               return ISC_R_NOSPACE;
        cp += n;
        
        /* Time. */
@@ -323,7 +323,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
        n = dst_sign_data(SIG_MODE_FINAL, state->key, &state->ctx, NULL, 0,
                          state->sig, sizeof(state->sig));
        if (n < 0)
-               return (-ns_r_badkey);
+               return ISC_R_BADKEY;
        state->siglen = n;
 
        /* Add the signature. */
@@ -346,5 +346,6 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error,
 
        hp->arcount = htons(ntohs(hp->arcount) + 1);
        *msglen = (cp - msg);
-       return (0);
+       return ISC_R_SUCCESS;
 }
+#endif
index 31bbc5b79d8f19c0adab9214393d92e48d0099fd..b6ce68970ecb3cbd081469e9f850a53e62f6ae35 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_verify.c,v 1.2 2000/02/02 19:59:16 mellon Exp $";
+static const char rcsid[] = "$Id: ns_verify.c,v 1.3 2001/01/16 22:33:11 mellon Exp $";
 #endif
 
 /* Import. */
@@ -126,7 +126,7 @@ ns_find_tsig(u_char *msg, u_char *eom) {
  *     - TSIG verification succeeds, error set to BADSIG (ns_r_badsig)
  *     - TSIG verification succeeds, error set to BADTIME (ns_r_badtime)
  */
-int
+isc_result_t
 ns_verify(u_char *msg, unsigned *msglen, void *k,
          const u_char *querysig, unsigned querysiglen,
          u_char *sig, unsigned *siglen, time_t *timesigned, int nostrip)
@@ -144,41 +144,41 @@ ns_verify(u_char *msg, unsigned *msglen, void *k,
 
        dst_init();
        if (msg == NULL || msglen == NULL || *msglen < 0)
-               return (-1);
+               return ISC_R_INVALIDARG;
 
        eom = msg + *msglen;
 
        recstart = ns_find_tsig(msg, eom);
        if (recstart == NULL)
-               return (NS_TSIG_ERROR_NO_TSIG);
+               return ISC_R_NO_TSIG;
 
        cp = recstart;
 
        /* Read the key name. */
        n = dn_expand(msg, eom, cp, name, MAXDNAME);
        if (n < 0)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
        cp += n;
 
        /* Read the type. */
        BOUNDS_CHECK(cp, 2*INT16SZ + INT32SZ + INT16SZ);
        GETSHORT(type, cp);
        if (type != ns_t_tsig)
-               return (NS_TSIG_ERROR_NO_TSIG);
+               return ISC_R_NO_TSIG;
 
        /* Skip the class and TTL, save the length. */
        cp += INT16SZ + INT32SZ;
        GETSHORT(length, cp);
        if (eom - cp != length)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
 
        /* Read the algorithm name. */
        rdatastart = cp;
        n = dn_expand(msg, eom, cp, alg, MAXDNAME);
        if (n < 0)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
        if (ns_samename(alg, NS_TSIG_ALG_HMAC_MD5) != 1)
-               return (-ns_r_badkey);
+               return ISC_R_INVALIDKEY;
        cp += n;
 
        /* Read the time signed and fudge. */
@@ -207,15 +207,15 @@ ns_verify(u_char *msg, unsigned *msglen, void *k,
        cp += otherfieldlen;
 
        if (cp != eom)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
 
        /* Verify that the key used is OK. */
        if (key != NULL) {
                if (key->dk_alg != KEY_HMAC_MD5)
-                       return (-ns_r_badkey);
+                       return ISC_R_INVALIDKEY;
                if (error != ns_r_badsig && error != ns_r_badkey) {
                        if (ns_samename(key->dk_key_name, name) != 1)
-                               return (-ns_r_badkey);
+                               return ISC_R_INVALIDKEY;
                }
        }
 
@@ -271,17 +271,17 @@ ns_verify(u_char *msg, unsigned *msglen, void *k,
                                    sigstart, sigfieldlen);
 
                if (n < 0)
-                       return (-ns_r_badsig);
+                       return ISC_R_BADSIG;
 
                if (sig != NULL && siglen != NULL) {
                        if (*siglen < sigfieldlen)
-                               return (NS_TSIG_ERROR_NO_SPACE);
+                               return ISC_R_NOSPACE;
                        memcpy(sig, sigstart, sigfieldlen);
                        *siglen = sigfieldlen;
                }
        } else {
                if (sigfieldlen > 0)
-                       return (NS_TSIG_ERROR_FORMERR);
+                       return ISC_R_FORMERR;
                if (sig != NULL && siglen != NULL)
                        *siglen = 0;
        }
@@ -291,7 +291,7 @@ ns_verify(u_char *msg, unsigned *msglen, void *k,
 
        /* Verify the time. */
        if (abs((*timesigned) - time(NULL)) > fudge)
-               return (-ns_r_badtime);
+               return ISC_R_BADTIME;
 
        if (nostrip == 0) {
                *msglen = recstart - msg;
@@ -299,30 +299,31 @@ ns_verify(u_char *msg, unsigned *msglen, void *k,
        }
 
        if (error != NOERROR)
-               return (error);
+               return ns_rcode_to_isc (error);
 
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
-int
+#if 0
+isc_result_t
 ns_verify_tcp_init(void *k, const u_char *querysig, unsigned querysiglen,
                   ns_tcp_tsig_state *state)
 {
        dst_init();
        if (state == NULL || k == NULL || querysig == NULL || querysiglen < 0)
-               return (-1);
+               return ISC_R_INVALIDARG;
        state->counter = -1;
        state->key = k;
        if (state->key->dk_alg != KEY_HMAC_MD5)
-               return (-ns_r_badkey);
+               return ISC_R_BADKEY;
        if (querysiglen > sizeof(state->sig))
-               return (-1);
+               return ISC_R_NOSPACE;
        memcpy(state->sig, querysig, querysiglen);
        state->siglen = querysiglen;
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
-int
+isc_result_t
 ns_verify_tcp(u_char *msg, unsigned *msglen, ns_tcp_tsig_state *state,
              int required)
 {
@@ -336,7 +337,7 @@ ns_verify_tcp(u_char *msg, unsigned *msglen, ns_tcp_tsig_state *state,
        time_t timesigned;
 
        if (msg == NULL || msglen == NULL || state == NULL)
-               return (-1);
+               return ISC_R_INVALIDARG;
 
        state->counter++;
        if (state->counter == 0)
@@ -360,10 +361,10 @@ ns_verify_tcp(u_char *msg, unsigned *msglen, ns_tcp_tsig_state *state,
 
        if (recstart == NULL) {
                if (required)
-                       return (NS_TSIG_ERROR_NO_TSIG);
+                       return ISC_R_NO_TSIG;
                dst_verify_data(SIG_MODE_UPDATE, state->key, &state->ctx,
                                msg, *msglen, NULL, 0);
-               return (0);
+               return ISC_R_SUCCESS;
        }
 
        hp->arcount = htons(ntohs(hp->arcount) - 1);
@@ -373,34 +374,34 @@ ns_verify_tcp(u_char *msg, unsigned *msglen, ns_tcp_tsig_state *state,
        /* Read the key name. */
        n = dn_expand(msg, eom, cp, name, MAXDNAME);
        if (n < 0)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
        cp += n;
 
        /* Read the type. */
        BOUNDS_CHECK(cp, 2*INT16SZ + INT32SZ + INT16SZ);
        GETSHORT(type, cp);
        if (type != ns_t_tsig)
-               return (NS_TSIG_ERROR_NO_TSIG);
+               return ISC_R_NO_TSIG;
 
        /* Skip the class and TTL, save the length. */
        cp += INT16SZ + INT32SZ;
        GETSHORT(length, cp);
        if (eom - cp != length)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
 
        /* Read the algorithm name. */
        rdatastart = cp;
        n = dn_expand(msg, eom, cp, alg, MAXDNAME);
        if (n < 0)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
        if (ns_samename(alg, NS_TSIG_ALG_HMAC_MD5) != 1)
-               return (-ns_r_badkey);
+               return ISC_R_BADKEY;
        cp += n;
 
        /* Verify that the key used is OK. */
        if ((ns_samename(state->key->dk_key_name, name) != 1 ||
             state->key->dk_alg != KEY_HMAC_MD5))
-               return (-ns_r_badkey);
+               return ISC_R_BADKEY;
 
        /* Read the time signed and fudge. */
        BOUNDS_CHECK(cp, INT16SZ + INT32SZ + INT16SZ);
@@ -427,7 +428,7 @@ ns_verify_tcp(u_char *msg, unsigned *msglen, ns_tcp_tsig_state *state,
        cp += otherfieldlen;
 
        if (cp != eom)
-               return (NS_TSIG_ERROR_FORMERR);
+               return ISC_R_FORMERR;
 
        /*
         * Do the verification.
@@ -445,25 +446,26 @@ ns_verify_tcp(u_char *msg, unsigned *msglen, ns_tcp_tsig_state *state,
        n = dst_verify_data(SIG_MODE_FINAL, state->key, &state->ctx, NULL, 0,
                            sigstart, sigfieldlen);
        if (n < 0)
-               return (-ns_r_badsig);
+               return ISC_R_BADSIG;
 
        if (sigfieldlen > sizeof(state->sig))
-               return (ns_r_badsig);
+               return ISC_R_BADSIG;
 
        if (sigfieldlen > sizeof(state->sig))
-               return (NS_TSIG_ERROR_NO_SPACE);
+               return ISC_R_NOSPACE;
 
        memcpy(state->sig, sigstart, sigfieldlen);
        state->siglen = sigfieldlen;
 
        /* Verify the time. */
        if (abs(timesigned - time(NULL)) > fudge)
-               return (-ns_r_badtime);
+               return ISC_R_BADTIME;
 
        *msglen = recstart - msg;
 
        if (error != NOERROR)
-               return (error);
+               return ns_rcode_to_isc (error);
 
-       return (0);
+       return ISC_R_SUCCESS;
 }
+#endif
index aae8b23654844135ddbc30cbec5db9bc7a568b9f..d56c8babdd1f5ac818fd42d4359c623e844361eb 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_findzonecut.c,v 1.10 2000/10/12 09:04:24 mellon Exp $";
+static const char rcsid[] = "$Id: res_findzonecut.c,v 1.11 2001/01/16 22:33:13 mellon Exp $";
 #endif /* not lint */
 
 /*
@@ -64,12 +64,12 @@ static int  add_addrs(res_state, rr_ns *, struct in_addr *, int);
 static ns_rcode        get_soa(res_state, const char *, ns_class,
                        char *, size_t, char *, size_t,
                        rrset_ns *);
-static int     get_ns(res_state, const char *, ns_class, rrset_ns *);
-static ns_rcode        get_glue(res_state, ns_class, rrset_ns *);
-static int     save_ns(res_state, ns_msg *, ns_sect,
-                       const char *, ns_class, rrset_ns *);
-static int     save_a(res_state, ns_msg *, ns_sect,
-                      const char *, ns_class, rrset_a *);
+static isc_result_t get_ns(res_state, const char *, ns_class, rrset_ns *);
+static isc_result_t get_glue(res_state, ns_class, rrset_ns *);
+static isc_result_t save_ns(res_state, ns_msg *, ns_sect,
+                           const char *, ns_class, rrset_ns *);
+static isc_result_t save_a(res_state, ns_msg *, ns_sect,
+                          const char *, ns_class, rrset_a *);
 static void    free_nsrrset(rrset_ns *);
 static void    free_nsrr(rrset_ns *, rr_ns *);
 static rr_ns * find_ns(rrset_ns *, const char *);
@@ -142,7 +142,7 @@ res_findzonecut(res_state statp, const char *dname, ns_class class, int opts,
        u_long save_pfcode;
        rrset_ns nsrrs;
        int n = 0;
-       ns_rcode rcode;
+       isc_result_t rcode;
 
        DPRINTF(("START dname='%s' class=%s, zsize=%ld, naddrs=%d",
                 dname, p_class(class), (long)zsize, naddrs));
@@ -153,9 +153,9 @@ res_findzonecut(res_state statp, const char *dname, ns_class class, int opts,
        ISC_LIST_INIT(nsrrs);
 
        DPRINTF (("look for a predefined zone statement"));
-       rcode = find_cached_zone (dname, class, zname, zsize, addrs, naddrs,
-                                 &n, zcookie);
-       if (rcode == ns_r_noerror)
+       rcode = find_cached_zone (dname, class, zname, zsize,
+                                 addrs, naddrs, &n, zcookie);
+       if (rcode == ISC_R_SUCCESS)
                goto done;
 
        DPRINTF(("get the soa, and see if it has enough glue"));
@@ -245,15 +245,16 @@ get_soa(res_state statp, const char *dname, ns_class class,
        ns_sect sect;
        ns_msg msg;
        u_int rcode;
-       ns_rcode status;
+       isc_result_t status;
 
        /*
         * Find closest enclosing SOA, even if it's for the root zone.
         */
 
        /* First canonicalize dname (exactly one unescaped trailing "."). */
-       if (ns_makecanon(dname, tname, sizeof tname) < 0)
-               return ns_r_servfail;
+       status = ns_makecanon(dname, tname, sizeof tname);
+       if (status != ISC_R_SUCCESS)
+               return status;
        dname = tname;
 
        /* Now grovel the subdomains, hunting for an SOA answer or auth. */
@@ -289,10 +290,11 @@ get_soa(res_state statp, const char *dname, ns_class class,
                        int rdlen;
                        ns_rr rr;
 
-                       if (ns_parserr(&msg, sect, i, &rr) < 0) {
+                       rcode = ns_parserr(&msg, sect, i, &rr) < 0;
+                       if (rcode != ISC_R_SUCCESS) {
                                DPRINTF(("get_soa: ns_parserr(%s, %d) failed",
                                         p_section(sect, ns_o_query), i));
-                               return ns_r_servfail;
+                               return rcode;
                        }
                        if (ns_rr_type(rr) == ns_t_cname ||
                            ns_rr_type(rr) == ns_t_dname)
@@ -304,19 +306,18 @@ get_soa(res_state statp, const char *dname, ns_class class,
                        switch (sect) {
                        case ns_s_an:
                                if (ns_samedomain(dname, t) == 0) {
-                                       DPRINTF(("get_soa: ns_samedomain('%s', '%s') == 0",
-                                                dname, t));
-                                       errno = EPROTOTYPE;
-                                       return ns_r_notzone;
+                                       DPRINTF(("get_soa: %s'%s', '%s') == 0",
+                                                "ns_samedomain(", dname, t));
+                                       return ISC_R_NOTZONE;
                                }
                                break;
                        case ns_s_ns:
                                if (ns_samename(dname, t) == 1 ||
                                    ns_samedomain(dname, t) == 0) {
-                                       DPRINTF(("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
+                                       DPRINTF(("get_soa: %smain('%s', '%s')",
+                                                "ns_samename() || !ns_samedo",
                                                 dname, t));
-                                       errno = EPROTOTYPE;
-                                       return ns_r_notzone;
+                                       return ISC_R_NOTZONE;
                                }
                                break;
                        default:
@@ -325,8 +326,7 @@ get_soa(res_state statp, const char *dname, ns_class class,
                        if (strlen(t) + 1 > zsize) {
                                DPRINTF(("get_soa: zname(%d) too small (%d)",
                                         zsize, strlen(t) + 1));
-                               errno = EMSGSIZE;
-                               return ns_r_servfail;
+                               return ISC_R_NOSPACE;
                        }
                        strcpy(zname, t);
                        rdata = ns_rr_rdata(rr);
@@ -334,15 +334,17 @@ get_soa(res_state statp, const char *dname, ns_class class,
                        if (ns_name_uncompress((u_char *)resp,
                                               ns_msg_end(msg), rdata,
                                               mname, msize) < 0) {
-                               DPRINTF(("get_soa: ns_name_uncompress failed"));
-                               return ns_r_servfail;
+                               DPRINTF(("get_soa: %s failed",
+                                        "ns_name_uncompress"));
+                               return ISC_R_NOMEMORY;
                        }
-                       if (save_ns(statp, &msg, ns_s_ns,
-                                   zname, class, nsrrsp) < 0) {
+                       rcode = save_ns(statp, &msg,
+                                       ns_s_ns, zname, class, nsrrsp);
+                       if (rcode != ISC_R_SUCCESS) {
                                DPRINTF(("get_soa: save_ns failed"));
-                               return ns_r_servfail;
+                               return rcode;
                        }
-                       return ns_r_noerror;
+                       return ISC_R_SUCCESS;
                }
 
                /* If we're out of labels, then not even "." has an SOA! */
@@ -353,43 +355,42 @@ get_soa(res_state statp, const char *dname, ns_class class,
                while (*dname != '.') {
                        if (*dname == '\\')
                                if (*++dname == '\0') {
-                                       errno = EMSGSIZE;
-                                       return ns_r_servfail;
+                                       ISC_R_NOSPACE;
                                }
                        dname++;
                }
        }
        DPRINTF(("get_soa: out of labels"));
-       errno = EDESTADDRREQ;
-       return ns_r_servfail;
+       return ISC_R_DESTADDRREQ;
 }
 
-static int
+static isc_result_t
 get_ns(res_state statp, const char *zname, ns_class class, rrset_ns *nsrrsp) {
        double resp[NS_PACKETSZ / sizeof (double)];
        ns_msg msg;
        int n;
-       ns_rcode rcode;
+       isc_result_t rcode;
 
        /* Go and get the NS RRs for this zone. */
        rcode = do_query(statp, zname, class, ns_t_ns, resp, &msg, &n);
-       if (rcode != ns_r_noerror) {
+       if (rcode != ISC_R_SUCCESS) {
                DPRINTF(("get_ns: do_query('zname', %s) failed (%d)",
                         zname, p_class(class), rcode));
                return rcode;
        }
 
        /* Remember the NS RRs and associated A RRs that came back. */
-       if (save_ns(statp, &msg, ns_s_an, zname, class, nsrrsp) < 0) {
+       rcode = save_ns(statp, &msg, ns_s_an, zname, class, nsrrsp);
+       if (rcode != ISC_R_SUCCESS) {
                DPRINTF(("get_ns save_ns('%s', %s) failed",
                         zname, p_class(class)));
-               return ns_r_servfail;
+               return rcode;
        }
 
-       return ns_r_noerror;
+       return ISC_R_SUCCESS;
 }
 
-static ns_rcode
+static isc_result_t
 get_glue(res_state statp, ns_class class, rrset_ns *nsrrsp) {
        rr_ns *nsrr, *nsrr_n;
 
@@ -398,28 +399,29 @@ get_glue(res_state statp, ns_class class, rrset_ns *nsrrsp) {
                double resp[NS_PACKETSZ / sizeof (double)];
                ns_msg msg;
                int n;
-               ns_rcode rcode;
+               isc_result_t rcode;
 
                nsrr_n = ISC_LIST_NEXT(nsrr, link);
 
                if (ISC_LIST_EMPTY(nsrr->addrs)) {
                        rcode = do_query(statp, nsrr->name, class, ns_t_a,
                                         resp, &msg, &n);
-                       if (rcode != ns_r_noerror) {
-                               DPRINTF(("get_glue: do_query('%s', %s') failed",
-                                        nsrr->name, p_class(class)));
-                               return rcode;
+                       if (rcode != ISC_R_SUCCESS) {
+                           DPRINTF(("get_glue: do_query('%s', %s') failed",
+                                    nsrr->name, p_class(class)));
+                           return rcode;
                        }
                        if (n > 0) {
                                DPRINTF((
                        "get_glue: do_query('%s', %s') CNAME or DNAME found",
                                         nsrr->name, p_class(class)));
                        }
-                       if (save_a(statp, &msg, ns_s_an, nsrr->name, class,
-                                  &nsrr->addrs) < 0) {
+                       rcode = save_a(statp, &msg, ns_s_an, nsrr->name, class,
+                                      &nsrr->addrs);
+                       if (rcode != ISC_R_SUCCESS) {
                                DPRINTF(("get_glue: save_r('%s', %s) failed",
                                         nsrr->name, p_class(class)));
-                               return ns_r_servfail;
+                               return rcode;
                        }
                        /* If it's still empty, it's just chaff. */
                        if (ISC_LIST_EMPTY(nsrr->addrs)) {
@@ -429,15 +431,16 @@ get_glue(res_state statp, ns_class class, rrset_ns *nsrrsp) {
                        }
                }
        }
-       return ns_r_noerror;
+       return ISC_R_SUCCESS;
 }
 
-static int
+static isc_result_t
 save_ns(res_state statp, ns_msg *msg, ns_sect sect,
        const char *owner, ns_class class,
        rrset_ns *nsrrsp)
 {
        int i;
+       isc_result_t rcode;
 
        for (i = 0; i < ns_msg_count(*msg, sect); i++) {
                char tname[MAXDNAME];
@@ -446,10 +449,11 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
                ns_rr rr;
                int rdlen;
 
-               if (ns_parserr(msg, sect, i, &rr) < 0) {
+               rcode = ns_parserr(msg, sect, i, &rr);
+               if (rcode != ISC_R_SUCCESS) {
                        DPRINTF(("save_ns: ns_parserr(%s, %d) failed",
                                 p_section(sect, ns_o_query), i));
-                       return (-1);
+                       return rcode;
                }
                if (ns_rr_type(rr) != ns_t_ns ||
                    ns_rr_class(rr) != class ||
@@ -460,7 +464,7 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
                        nsrr = malloc(sizeof *nsrr);
                        if (nsrr == NULL) {
                                DPRINTF(("save_ns: malloc failed"));
-                               return (-1);
+                               return ISC_R_NOMEMORY;
                        }
                        rdata = ns_rr_rdata(rr);
                        rdlen = ns_rr_rdlen(rr);
@@ -469,42 +473,45 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
                                               tname, sizeof tname) < 0) {
                                DPRINTF(("save_ns: ns_name_uncompress failed"));
                                free(nsrr);
-                               return (-1);
+                               return ISC_R_NOMEMORY;
                        }
                        nsrr->name = strdup(tname);
                        if (nsrr->name == NULL) {
                                DPRINTF(("save_ns: strdup failed"));
                                free(nsrr);
-                               return (-1);
+                               return ISC_R_NOMEMORY;
                        }
                        ISC_LIST_INIT(nsrr->addrs);
                        ISC_LIST_APPEND(*nsrrsp, nsrr, link);
                }
-               if (save_a(statp, msg, ns_s_ar,
-                          nsrr->name, class, &nsrr->addrs) < 0) {
+               rcode = save_a(statp, msg, ns_s_ar,
+                              nsrr->name, class, &nsrr->addrs);
+               if (rcode != ISC_R_SUCCESS) {
                        DPRINTF(("save_ns: save_r('%s', %s) failed",
                                 nsrr->name, p_class(class)));
-                       return (-1);
+                       return rcode;
                }
        }
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
-static int
+static isc_result_t
 save_a(res_state statp, ns_msg *msg, ns_sect sect,
        const char *owner, ns_class class,
        rrset_a *arrsp)
 {
        int i;
+       isc_result_t rcode;
 
        for (i = 0; i < ns_msg_count(*msg, sect); i++) {
                ns_rr rr;
                rr_a *arr;
 
-               if (ns_parserr(msg, sect, i, &rr) < 0) {
+               rcode = ns_parserr(msg, sect, i, &rr);
+               if (rcode != ISC_R_SUCCESS) {
                        DPRINTF(("save_a: ns_parserr(%s, %d) failed",
                                 p_section(sect, ns_o_query), i));
-                       return (-1);
+                       return rcode;
                }
                if (ns_rr_type(rr) != ns_t_a ||
                    ns_rr_class(rr) != class ||
@@ -514,12 +521,12 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
                arr = malloc(sizeof *arr);
                if (arr == NULL) {
                        DPRINTF(("save_a: malloc failed"));
-                       return (-1);
+                       return ISC_R_NOMEMORY;
                }
                memcpy(&arr->addr, ns_rr_rdata(rr), NS_INADDRSZ);
                ISC_LIST_APPEND(*arrsp, arr, link);
        }
-       return (0);
+       return ISC_R_SUCCESS;
 }
 
 static void
@@ -554,41 +561,42 @@ find_ns(rrset_ns *nsrrsp, const char *dname) {
        return (NULL);
 }
 
-static ns_rcode
+static isc_result_t
 do_query(res_state statp, const char *dname, ns_class class, ns_type qtype,
         double *resp, ns_msg *msg, int *alias_count)
 {
        double req[NS_PACKETSZ / sizeof (double)];
        int i;
        unsigned n;
+       isc_result_t status;
 
-       n = res_nmkquery(statp, ns_o_query, dname, class, qtype,
-                        NULL, 0, NULL, req, NS_PACKETSZ);
-       if (n < 0) {
+       status = res_nmkquery(statp, ns_o_query, dname, class, qtype,
+                             NULL, 0, NULL, req, NS_PACKETSZ, &n);
+       if (status != ISC_R_SUCCESS) {
                DPRINTF(("do_query: res_nmkquery failed"));
-               return ns_r_servfail;
+               return status;
        }
-       n = res_nsend(statp, req, n, resp, NS_PACKETSZ);
-       if (n < 0) {
+       status = res_nsend(statp, req, n, resp, NS_PACKETSZ, &n);
+       if (status != ISC_R_SUCCESS) {
                DPRINTF(("do_query: res_nsend failed"));
-               return ns_r_servfail;
+               return status;
        }
        if (n == 0) {
                DPRINTF(("do_query: res_nsend returned 0"));
-               errno = EMSGSIZE;
-               return ns_r_servfail;
+               return ISC_R_NOTFOUND;
        }
        if (ns_initparse((u_char *)resp, n, msg) < 0) {
                DPRINTF(("do_query: ns_initparse failed"));
-               return ns_r_servfail;
+               return ISC_R_NOSPACE;
        }
        n = 0;
        for (i = 0; i < ns_msg_count(*msg, ns_s_an); i++) {
                ns_rr rr;
 
-               if (ns_parserr(msg, ns_s_an, i, &rr) < 0) {
+               status = ns_parserr(msg, ns_s_an, i, &rr);
+               if (status != ISC_R_SUCCESS) {
                        DPRINTF(("do_query: ns_parserr failed"));
-                       return ns_r_servfail;
+                       return status;
                }
                n += (ns_rr_class(rr) == class &&
                      (ns_rr_type(rr) == ns_t_cname ||
@@ -596,5 +604,5 @@ do_query(res_state statp, const char *dname, ns_class class, ns_type qtype,
        }
        if (alias_count)
                *alias_count = n;
-       return (ns_rcode)ns_msg_getflag (*msg, ns_f_rcode);
+       return ns_rcode_to_isc (ns_msg_getflag (*msg, ns_f_rcode));
 }
index f21cd1a333c7fb9997e9cdaeab967862f59b9f91..88fe7e6a1ef66f3e671d0ff8eeec3063d10400bb 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_mkquery.c        8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_mkquery.c,v 1.3 2000/07/17 20:51:13 mellon Exp $";
+static const char rcsid[] = "$Id: res_mkquery.c,v 1.4 2001/01/16 22:33:14 mellon Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -90,7 +90,7 @@ extern const char *_res_opcodes[];
  * Form all types of queries.
  * Returns the size of the result or -1.
  */
-int
+isc_result_t
 res_nmkquery(res_state statp,
             int op,                    /* opcode of query */
             const char *dname,         /* domain name */
@@ -99,7 +99,8 @@ res_nmkquery(res_state statp,
             unsigned datalen,          /* length of data */
             const u_char *newrr_in,    /* new rr for modify or append */
             double *buf,               /* buffer to put query */
-            unsigned buflen)           /* size of buffer */
+            unsigned buflen,           /* size of buffer */
+            unsigned *rbuflen)         /* returned size of buffer */
 {
        register HEADER *hp;
        register u_char *cp;
@@ -110,7 +111,7 @@ res_nmkquery(res_state statp,
         * Initialize header fields.
         */
        if ((buf == NULL) || (buflen < HFIXEDSZ))
-               return (-1);
+               return ISC_R_INVALIDARG;
        memset(buf, 0, HFIXEDSZ);
        hp = (HEADER *) buf;
        hp->id = htons(++statp->id);
@@ -130,9 +131,9 @@ res_nmkquery(res_state statp,
        case QUERY:     /*FALLTHROUGH*/
        case NS_NOTIFY_OP:
                if ((buflen -= QFIXEDSZ) < 0)
-                       return (-1);
+                       return ISC_R_NOSPACE;
                if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
-                       return (-1);
+                       return ISC_R_NOSPACE;
                cp += n;
                buflen -= n;
                putUShort(cp, type);
@@ -148,7 +149,7 @@ res_nmkquery(res_state statp,
                buflen -= RRFIXEDSZ;
                n = dn_comp((const char *)data, cp, buflen, dnptrs, lastdnptr);
                if (n < 0)
-                       return (-1);
+                       return ISC_R_NOSPACE;
                cp += n;
                buflen -= n;
                putUShort(cp, T_NULL);
@@ -167,7 +168,7 @@ res_nmkquery(res_state statp,
                 * Initialize answer section
                 */
                if (buflen < 1 + RRFIXEDSZ + datalen)
-                       return (-1);
+                       return ISC_R_NOSPACE;
                *cp++ = '\0';   /* no domain name */
                putUShort(cp, type);
                cp += INT16SZ;
@@ -185,7 +186,8 @@ res_nmkquery(res_state statp,
                break;
 
        default:
-               return (-1);
+               return ISC_R_NOTIMPLEMENTED;
        }
-       return (cp - ((u_char *)buf));
+       *rbuflen = cp - ((u_char *)buf);
+       return ISC_R_SUCCESS;
 }
index 69e6fb9ece05195b7a85acaa75965702eba131a5..412da65a36ca419bae1a2721819a80d9ef892f3b 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_query.c  8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_query.c,v 1.3 2000/07/17 20:51:16 mellon Exp $";
+static const char rcsid[] = "$Id: res_query.c,v 1.4 2001/01/16 22:33:15 mellon Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -107,16 +107,18 @@ static const char rcsid[] = "$Id: res_query.c,v 1.3 2000/07/17 20:51:16 mellon E
  *
  * Caller must parse answer and determine whether it answers the question.
  */
-int
+isc_result_t
 res_nquery(res_state statp,
           const char *name,    /* domain name */
           ns_class class, ns_type type, /* class and type of query */
           double *answer,      /* buffer to put answer */
-          unsigned anslen)     /* size of answer buffer */
+          unsigned anslen,
+          unsigned *ansret)    /* size of answer buffer */
 {
        double buf[MAXPACKET / sizeof (double)];
        HEADER *hp = (HEADER *) answer;
        unsigned n;
+       isc_result_t rcode;
 
        hp->rcode = NOERROR;    /* default */
 
@@ -125,24 +127,24 @@ res_nquery(res_state statp,
                printf(";; res_query(%s, %d, %d)\n", name, class, type);
 #endif
 
-       n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
-                        buf, sizeof(buf));
-       if (n <= 0) {
+       rcode = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
+                            buf, sizeof(buf), &n);
+       if (rcode != ISC_R_SUCCESS) {
 #ifdef DEBUG
                if (statp->options & RES_DEBUG)
                        printf(";; res_query: mkquery failed\n");
 #endif
                RES_SET_H_ERRNO(statp, NO_RECOVERY);
-               return (n);
+               return rcode;
        }
-       n = res_nsend(statp, buf, n, answer, anslen);
-       if (n < 0) {
+       rcode = res_nsend(statp, buf, n, answer, anslen, &n);
+       if (rcode != ISC_R_SUCCESS) {
 #ifdef DEBUG
                if (statp->options & RES_DEBUG)
                        printf(";; res_query: send error\n");
 #endif
                RES_SET_H_ERRNO(statp, TRY_AGAIN);
-               return (n);
+               return rcode;
        }
 
        if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
@@ -168,23 +170,26 @@ res_nquery(res_state statp,
                        RES_SET_H_ERRNO(statp, NO_RECOVERY);
                        break;
                }
-               return (-1);
+               return ns_rcode_to_isc (hp -> rcode);
        }
-       return (n);
+       *ansret = n;
+       return ISC_R_SUCCESS;
 }
 
+#if 0
 /*
  * Formulate a normal query, send, and retrieve answer in supplied buffer.
  * Return the size of the response on success, -1 on error.
  * If enabled, implement search rules until answer or unrecoverable failure
  * is detected.  Error code, if any, is left in H_ERRNO.
  */
-int
+isc_result_t
 res_nsearch(res_state statp,
            const char *name,   /* domain name */
            ns_class class, ns_type type, /* class and type of query */
            double *answer,     /* buffer to put answer */
-           unsigned anslen)            /* size of answer */
+           unsigned anslen,
+           unsigned *ansret)           /* size of answer */
 {
        const char *cp, * const *domain;
        HEADER *hp = (HEADER *) answer;
@@ -192,6 +197,7 @@ res_nsearch(res_state statp,
        u_int dots;
        int trailing_dot, ret;
        int got_nodata = 0, got_servfail = 0, root_on_list = 0;
+       isc_result_t rcode;
 
        errno = 0;
        RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);  /* True if we never query. */
@@ -205,15 +211,16 @@ res_nsearch(res_state statp,
 
        /* If there aren't any dots, it could be a user-level alias. */
        if (!dots && (cp = res_hostalias(statp, name, tmp, sizeof tmp))!= NULL)
-               return (res_nquery(statp, cp, class, type, answer, anslen));
+               return res_nquery(statp, cp, class, type,
+                                 answer, anslen, ansret);
 
        /*
         * If there are enough dots in the name, do no searching.
         * (The threshold can be set with the "ndots" option.)
         */
        if (dots >= statp->ndots || trailing_dot)
-               return (res_nquerydomain(statp, name, NULL, class, type,
-                                        answer, anslen));
+               return res_nquerydomain(statp, name, NULL, class, type,
+                                       answer, anslen, ansret);
 
        /*
         * We do at least one level of search if
@@ -233,11 +240,13 @@ res_nsearch(res_state statp,
                            (domain[0][0] == '.' && domain[0][1] == '\0'))
                                root_on_list++;
 
-                       ret = res_nquerydomain(statp, name, *domain,
-                                              class, type,
-                                              answer, anslen);
-                       if (ret > 0)
-                               return (ret);
+                       rcode = res_nquerydomain(statp, name, *domain,
+                                                class, type,
+                                                answer, anslen, &ret);
+                       if (rcode == ISC_R_SUCCESS && ret > 0) {
+                               *ansret = ret;
+                               return rcode;
+                       }
 
                        /*
                         * If no server present, give up.
@@ -254,7 +263,7 @@ res_nsearch(res_state statp,
                         */
                        if (errno == ECONNREFUSED) {
                                RES_SET_H_ERRNO(statp, TRY_AGAIN);
-                               return (-1);
+                               return ISC_R_CONNREFUSED;
                        }
 
                        switch (statp->res_h_errno) {
@@ -289,10 +298,12 @@ res_nsearch(res_state statp,
         * list, then try an as-is query now.
         */
        if (statp->ndots) {
-               ret = res_nquerydomain(statp, name, NULL, class, type,
-                                      answer, anslen);
-               if (ret > 0)
-                       return (ret);
+               rcode = res_nquerydomain(statp, name, NULL, class, type,
+                                        answer, anslen, &ret);
+               if (rcode == ISC_R_SUCCESS && ret > 0) {
+                       *ansret = ret;
+                       return rcode;
+               }
        }
 
        /* if we got here, we didn't satisfy the search.
@@ -302,24 +313,29 @@ res_nsearch(res_state statp,
         * else send back meaningless H_ERRNO, that being the one from
         * the last DNSRCH we did.
         */
-       if (got_nodata)
+       if (got_nodata) {
                RES_SET_H_ERRNO(statp, NO_DATA);
-       else if (got_servfail)
+               return ISC_R_NOTFOUND;
+       } else if (got_servfail) {
                RES_SET_H_ERRNO(statp, TRY_AGAIN);
-       return (-1);
+               return ISC_R_TIMEDOUT;
+       }
+       return ISC_R_UNEXPECTED;
 }
+#endif
 
 /*
  * Perform a call on res_query on the concatenation of name and domain,
  * removing a trailing dot from name if domain is NULL.
  */
-int
+isc_result_t
 res_nquerydomain(res_state statp,
-           const char *name,
-           const char *domain,
-           ns_class class, ns_type type,
-           double *answer,
-           unsigned anslen)
+                const char *name,
+                const char *domain,
+                ns_class class, ns_type type,
+                double *answer,
+                unsigned anslen,
+                unsigned *ansret)
 {
        char nbuf[MAXDNAME];
        const char *longname = nbuf;
@@ -338,7 +354,7 @@ res_nquerydomain(res_state statp,
                n = strlen(name);
                if (n >= MAXDNAME) {
                        RES_SET_H_ERRNO(statp, NO_RECOVERY);
-                       return (-1);
+                       return ISC_R_NOSPACE;
                }
                n--;
                if (n >= 0 && name[n] == '.') {
@@ -351,11 +367,12 @@ res_nquerydomain(res_state statp,
                d = strlen(domain);
                if (n + d + 1 >= MAXDNAME) {
                        RES_SET_H_ERRNO(statp, NO_RECOVERY);
-                       return (-1);
+                       return ISC_R_NOSPACE;
                }
                sprintf(nbuf, "%s.%s", name, domain);
        }
-       return (res_nquery(statp, longname, class, type, answer, anslen));
+       return res_nquery(statp,
+                         longname, class, type, answer, anslen, ansret);
 }
 
 const char *
index 07393b041fac4393bec7298385e298da2a597e4e..9f3a83f9d7be8a5b5f82ca0e3337dd2a49eb4e5d 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_send.c   8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.4 2000/07/17 20:51:17 mellon Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 1.5 2001/01/16 22:33:16 mellon Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -216,9 +216,10 @@ res_queriesmatch(const u_char *buf1, const u_char *eom1,
        return (1);
 }
 
-int
+isc_result_t
 res_nsend(res_state statp,
-         double *buf, unsigned buflen, double *ans, unsigned anssiz)
+         double *buf, unsigned buflen,
+         double *ans, unsigned anssiz, unsigned *ansret)
 {
        HEADER *hp = (HEADER *) buf;
        HEADER *anhp = (HEADER *) ans;
@@ -227,8 +228,7 @@ res_nsend(res_state statp,
        static int highestFD = FD_SETSIZE - 1;
 
        if (anssiz < HFIXEDSZ) {
-               errno = EINVAL;
-               return (-1);
+               return ISC_R_INVALIDARG;
        }
        DprintQ((statp->options & RES_DEBUG) ||
                (statp->pfcode & RES_PRF_QUERY),
@@ -236,7 +236,7 @@ res_nsend(res_state statp,
        v_circuit = (statp->options & RES_USEVC) || buflen > PACKETSZ;
        gotsomewhere = 0;
        connreset = 0;
-       terrno = ETIMEDOUT;
+       terrno = ISC_R_TIMEDOUT;
        badns = 0;
 
        /*
@@ -289,7 +289,7 @@ res_nsend(res_state statp,
                                case res_error:
                                        /*FALLTHROUGH*/
                                default:
-                                       return (-1);
+                                       return ISC_R_UNEXPECTED;
                                }
                        } while (!done);
                }
@@ -334,7 +334,7 @@ res_nsend(res_state statp,
                                                       SOCK_STREAM, 0);
                                if (statp->_sock < 0 ||
                                    statp->_sock > highestFD) {
-                                       terrno = errno;
+                                       terrno = uerr2isc (errno);
                                        Perror(statp, stderr,
                                               "socket(vc)", errno);
                                        return (-1);
@@ -343,7 +343,7 @@ res_nsend(res_state statp,
                                if (connect(statp->_sock,
                                            (struct sockaddr *)nsap,
                                            sizeof *nsap) < 0) {
-                                       terrno = errno;
+                                       terrno = uerr2isc (errno);
                                        Aerror(statp, stderr, "connect/vc",
                                               errno, *nsap);
                                        badns |= (1 << ns);
@@ -362,7 +362,7 @@ res_nsend(res_state statp,
                        iov[1].iov_len = buflen;
                        if (writev(statp->_sock, iov, 2) !=
                            (INT16SZ + buflen)) {
-                               terrno = errno;
+                               terrno = uerr2isc (errno);
                                Perror(statp, stderr, "write failed", errno);
                                badns |= (1 << ns);
                                res_nclose(statp);
@@ -381,7 +381,7 @@ res_nsend(res_state statp,
                                        break;
                        }
                        if (n <= 0) {
-                               terrno = errno;
+                               terrno = uerr2isc (errno);
                                Perror(statp, stderr, "read failed", errno);
                                res_nclose(statp);
                                /*
@@ -393,7 +393,8 @@ res_nsend(res_state statp,
                                 * instead of failing.  We only allow one reset
                                 * per query to prevent looping.
                                 */
-                               if (terrno == ECONNRESET && !connreset) {
+                               if (terrno == ISC_R_CONNREFUSED &&
+                                   !connreset) {
                                        connreset = 1;
                                        res_nclose(statp);
                                        goto same_ns;
@@ -416,7 +417,7 @@ res_nsend(res_state statp,
                                 */
                                Dprint(statp->options & RES_DEBUG,
                                       (stdout, ";; undersized: %d\n", len));
-                               terrno = EMSGSIZE;
+                               terrno = ISC_R_NOSPACE;
                                badns |= (1 << ns);
                                res_nclose(statp);
                                goto next_ns;
@@ -430,7 +431,7 @@ res_nsend(res_state statp,
                                len -= n;
                        }
                        if (n <= 0) {
-                               terrno = errno;
+                               terrno = uerr2isc (errno);
                                Perror(statp, stderr, "read(vc)", errno);
                                res_nclose(statp);
                                goto next_ns;
@@ -491,10 +492,10 @@ res_nsend(res_state statp,
 #ifndef CAN_RECONNECT
  bad_dg_sock:
 #endif
-                                       terrno = errno;
+                                       terrno = uerr2isc (errno);
                                        Perror(statp, stderr,
                                               "socket(dg)", errno);
-                                       return (-1);
+                                       return terrno;
                                }
                                statp->_flags &= ~RES_F_CONN;
                        }
@@ -667,7 +668,7 @@ res_nsend(res_state statp,
                                Dprint(statp->options & RES_DEBUG,
                                       (stdout, ";; undersized: %d\n",
                                        resplen));
-                               terrno = EMSGSIZE;
+                               terrno = ISC_R_NOSPACE;
                                badns |= (1 << ns);
                                res_nclose(statp);
                                goto next_ns;
@@ -783,24 +784,24 @@ res_nsend(res_state statp,
                                case res_error:
                                        /*FALLTHROUGH*/
                                default:
-                                       return (-1);
+                                       return ISC_R_UNEXPECTED;
                                }
                        } while (!done);
 
                }
-               return (resplen);
+               *ansret = resplen;
+               return ISC_R_SUCCESS;
  next_ns: ;
           } /*foreach ns*/
        } /*foreach retry*/
        res_nclose(statp);
        if (!v_circuit) {
                if (!gotsomewhere)
-                       errno = ECONNREFUSED;   /* no nameservers found */
+                       terrno = ISC_R_CONNREFUSED;  /* no nameservers found */
                else
-                       errno = ETIMEDOUT;      /* no answer obtained */
-       } else
-               errno = terrno;
-       return (-1);
+                       errno = ISC_R_TIMEDOUT; /* no answer obtained */
+       }
+       return terrno;
 }
 
 /*
index 8eb72b2ed43672e3110b81ea5cd84947096b7544..1c0c441fb5b51d33a9a032f757f61361bac3c651 100644 (file)
 #include <isc/dst.h>
 
 /* res_nsendsigned */
-int
-res_nsendsigned(res_state statp, double *msg, unsigned msglen,
-               ns_tsig_key *key, double *answer, unsigned anslen)
+isc_result_t
+res_nsendsigned(res_state statp,
+               double *msg, unsigned msglen, ns_tsig_key *key,
+               double *answer, unsigned anslen, unsigned *anssize)
 {
        res_state nstatp;
        DST_KEY *dstkey;
@@ -32,22 +33,19 @@ res_nsendsigned(res_state statp, double *msg, unsigned msglen,
        HEADER *hp;
        time_t tsig_time;
        int ret;
+       isc_result_t rcode;
 
        dst_init();
 
        nstatp = (res_state) malloc(sizeof(*statp));
-       if (nstatp == NULL) {
-               errno = ENOMEM;
-               return (-1);
-       }
+       if (nstatp == NULL)
+               return ISC_R_NOMEMORY;
        memcpy(nstatp, statp, sizeof(*statp));
 
        bufsize = msglen + 1024;
        newmsg = (double *) malloc(bufsize);
-       if (newmsg == NULL) {
-               errno = ENOMEM;
-               return (-1);
-       }
+       if (newmsg == NULL)
+               return ISC_R_NOMEMORY;
        memcpy(newmsg, msg, msglen);
        newmsglen = msglen;
 
@@ -59,25 +57,20 @@ res_nsendsigned(res_state statp, double *msg, unsigned msglen,
                                           NS_KEY_PROT_ANY,
                                           key->data, key->len);
        if (dstkey == NULL) {
-               errno = EINVAL;
                free(nstatp);
                free(newmsg);
-               return (-1);
+               return ISC_R_INVALIDARG;
        }
 
        nstatp->nscount = 1;
        siglen = sizeof(sig);
-       ret = ns_sign((u_char *)newmsg, &newmsglen, bufsize,
-                     NOERROR, dstkey, NULL, 0,
-                     sig, &siglen, 0);
-       if (ret < 0) {
+       rcode = ns_sign((u_char *)newmsg, &newmsglen, bufsize,
+                       NOERROR, dstkey, NULL, 0,
+                       sig, &siglen, 0);
+       if (rcode != ISC_R_SUCCESS) {
                free (nstatp);
                free (newmsg);
-               if (ret == NS_TSIG_ERROR_NO_SPACE)
-                       errno  = EMSGSIZE;
-               else if (ret == -1)
-                       errno  = EINVAL;
-               return (ret);
+               return rcode;
        }
 
        if (newmsglen > PACKETSZ || (nstatp->options & RES_IGNTC))
@@ -89,27 +82,23 @@ res_nsendsigned(res_state statp, double *msg, unsigned msglen,
 
 retry:
 
-       ret = res_nsend(nstatp, newmsg, newmsglen, answer, anslen);
-       if (ret < 0) {
+       rcode = res_nsend(nstatp, newmsg, newmsglen, answer, anslen, &ret);
+       if (rcode != ISC_R_SUCCESS) {
                free (nstatp);
                free (newmsg);
-               return (ret);
+               return rcode;
        }
 
        anslen = ret;
-       ret = ns_verify((u_char *)answer, &anslen, dstkey, sig, siglen,
-                       NULL, NULL, &tsig_time,
-                       (nstatp->options & RES_KEEPTSIG) ? 1 : 0);
-       if (ret != 0) {
+       rcode = ns_verify((u_char *)answer, &anslen, dstkey, sig, siglen,
+                         NULL, NULL, &tsig_time,
+                         (nstatp->options & RES_KEEPTSIG) ? 1 : 0);
+       if (rcode != ISC_R_SUCCESS) {
                Dprint(nstatp->pfcode & RES_PRF_REPLY,
                       (stdout, ";; TSIG invalid (%s)\n", p_rcode(ret)));
                free (nstatp);
                free (newmsg);
-               if (ret == -1)
-                       errno = EINVAL;
-               else
-                       errno = ENOTTY;
-               return (-1);
+               return rcode;
        }
        Dprint(nstatp->pfcode & RES_PRF_REPLY, (stdout, ";; TSIG ok\n"));
 
@@ -122,5 +111,6 @@ retry:
 
        free (nstatp);
        free (newmsg);
-       return (anslen);
+       *anssize = anslen;
+       return ISC_R_SUCCESS;
 }
index 53efffbafdab1f963a2b722c43eb8ab3f24ec1fe..d7e4c8820a3bf01cd457132c2105068d0b35c841 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_update.c,v 1.9 2000/09/12 18:38:23 mellon Exp $";
+static const char rcsid[] = "$Id: res_update.c,v 1.10 2001/01/16 22:33:18 mellon Exp $";
 #endif /* not lint */
 
 /*
@@ -76,7 +76,7 @@ static int    nsprom(struct sockaddr_in *, const struct in_addr *, int);
 
 void tkey_free (ns_tsig_key **);
 
-ns_rcode
+isc_result_t
 res_nupdate(res_state statp, ns_updrec *rrecp_in) {
        ns_updrec *rrecp;
        double answer[PACKETSZ / sizeof (double)];
@@ -86,10 +86,10 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
        unsigned n;
        int rval;
        struct sockaddr_in nsaddrs[MAXNS];
-       ns_rcode rcode;
        ns_tsig_key *key;
        void *zcookie = 0;
        void *zcookp = &zcookie;
+       isc_result_t rcode;
 
       again:
        /* Make sure all the updates are in the same zone, and find out
@@ -104,16 +104,17 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
                                        sizeof tgrp.z_origin,
                                        tgrp.z_nsaddrs, MAXNS, &tgrp.z_nscount,
                                        zcookp);
-               if (rcode != ns_r_noerror)
+               if (rcode != ISC_R_SUCCESS)
                        goto done;
                if (tgrp.z_nscount <= 0) {
-                       rcode = ns_r_notzone;
+                       rcode = ISC_R_NOTZONE;
                        goto done;
                }
                /* Make a group for it if there isn't one. */
                if (zptr == NULL) {
                        zptr = malloc(sizeof *zptr);
                        if (zptr == NULL) {
+                               rcode = ISC_R_NOMEMORY;
                                goto done;
                        }
                        *zptr = tgrp;
@@ -122,7 +123,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
                } else if (ns_samename(tgrp.z_origin, zptr->z_origin) == 0 ||
                           tgrp.z_class != zptr->z_class) {
                        /* Some of the records are in different zones. */
-                       rcode = ns_r_notzone;
+                       rcode = ISC_R_CROSSZONE;
                        goto done;
                }
                /* Thread this rrecp onto the zone group. */
@@ -141,10 +142,10 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
 
        /* Marshall the update message. */
        n = sizeof packet;
-       if (res_nmkupdate(statp, ISC_LIST_HEAD(zptr->z_rrlist), packet, &n)) {
-               rcode = -1;
+       rcode = res_nmkupdate(statp,
+                             ISC_LIST_HEAD(zptr->z_rrlist), packet, &n);
+       if (rcode != ISC_R_SUCCESS)
                goto done;
-       }
 
        /* Temporarily replace the resolver's nameserver set. */
        nscount = nscopy(nsaddrs, statp->nsaddr_list, statp->nscount);
@@ -154,18 +155,18 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
        /* Send the update and remember the result. */
        key = (ns_tsig_key *)0;
        if (!find_tsig_key (&key, zptr->z_origin, zcookie)) {
-               rval = res_nsendsigned(statp, packet, n, key,
-                                      answer, sizeof answer);
+               rcode = res_nsendsigned(statp, packet, n, key,
+                                       answer, sizeof answer, &rval);
                tkey_free (&key);
        } else {
-               rval = res_nsend(statp, packet, n, answer, sizeof answer);
+               rcode = res_nsend(statp, packet, n,
+                                 answer, sizeof answer, &rval);
        }
-       if (rval < 0) {
-               rcode = -1;
+       if (rcode != ISC_R_SUCCESS) {
                goto undone;
        }
-       rcode = ((HEADER *)answer)->rcode;
-       if (zcookie && rcode == ns_r_badsig) {
+       rcode = ns_rcode_to_isc (((HEADER *)answer)->rcode);
+       if (zcookie && rcode == ISC_R_BADSIG) {
                repudiate_zone (&zcookie);
        }
 
@@ -182,7 +183,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
 
        /* If the update failed because we used a cached zone and it
           didn't work, try it again without the cached zone. */
-       if (zcookp && (rcode == ns_r_notzone || rcode == ns_r_badsig)) {
+       if (zcookp && (rcode == ISC_R_NOTZONE || rcode == ISC_R_BADSIG)) {
                zcookp = 0;
                goto again;
        }
index b1888e6e0fb2e3846ad0dcf5a906a4f77d040391..c079d7ee435e375ec40164eb20fec5e6782332ef 100644 (file)
@@ -4,7 +4,7 @@
    until the actual libisc merge. */
 
 /*
- * Copyright (c) 1999-2000 Internet Software Consortium.
+ * Copyright (c) 1999-2001 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -107,7 +107,12 @@ static const char *text[ISC_R_NRESULTS] = {
        "not a zone",                           /* 59 */
        "bad DNS signature",                    /* 60 */
        "bad DNS key",                          /* 61 */
-       "clock skew too great"                  /* 62 */
+       "clock skew too great",                 /* 62 */
+       "no root zone",                         /* 63 */
+       "destination address required",         /* 64 */
+       "cross-zone update",                    /* 65 */
+       "no TSIG signature",                    /* 66 */
+       "not equal"                             /* 67 */
 };
 
 const char *isc_result_totext (isc_result_t result)