Annotation of embedaddon/dhcp/omapip/toisc.c, revision 1.1.1.1

1.1       misho       1: /* toisc.c
                      2: 
                      3:    Convert non-ISC result codes to ISC result codes. */
                      4: 
                      5: /*
                      6:  * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
                      7:  * Copyright (c) 2001-2003 by Internet Software Consortium
                      8:  *
                      9:  * Permission to use, copy, modify, and distribute this software for any
                     10:  * purpose with or without fee is hereby granted, provided that the above
                     11:  * copyright notice and this permission notice appear in all copies.
                     12:  *
                     13:  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
                     14:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     15:  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
                     16:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     17:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     18:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
                     19:  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     20:  *
                     21:  *   Internet Systems Consortium, Inc.
                     22:  *   950 Charter Street
                     23:  *   Redwood City, CA 94063
                     24:  *   <info@isc.org>
                     25:  *   https://www.isc.org/
                     26:  *
                     27:  * This software has been written for Internet Systems Consortium
                     28:  * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
                     29:  * To learn more about Internet Systems Consortium, see
                     30:  * ``https://www.isc.org/''.  To learn more about Vixie Enterprises,
                     31:  * see ``http://www.vix.com''.   To learn more about Nominum, Inc., see
                     32:  * ``http://www.nominum.com''.
                     33:  */
                     34: 
                     35: #include "dhcpd.h"
                     36: 
                     37: #include <omapip/omapip_p.h>
                     38: #include "arpa/nameser.h"
                     39: #include "minires/minires.h"
                     40: 
                     41: #include <errno.h>
                     42: 
                     43: isc_result_t ns_rcode_to_isc (int nsr)
                     44: {
                     45:        switch (nsr) {
                     46:              case ns_r_noerror:
                     47:                return ISC_R_SUCCESS;
                     48: 
                     49:              case ns_r_formerr:
                     50:                return ISC_R_FORMERR;
                     51: 
                     52:              case ns_r_servfail:
                     53:                return ISC_R_SERVFAIL;
                     54: 
                     55:              case ns_r_nxdomain:
                     56:                return ISC_R_NXDOMAIN;
                     57: 
                     58:              case ns_r_notimpl:
                     59:                return ISC_R_NOTIMPL;
                     60: 
                     61:              case ns_r_refused:
                     62:                return ISC_R_REFUSED;
                     63: 
                     64:              case ns_r_yxdomain:
                     65:                return ISC_R_YXDOMAIN;
                     66: 
                     67:              case ns_r_yxrrset:
                     68:                return ISC_R_YXRRSET;
                     69: 
                     70:              case ns_r_nxrrset:
                     71:                return ISC_R_NXRRSET;
                     72: 
                     73:              case ns_r_notauth:
                     74:                return ISC_R_NOTAUTH;
                     75: 
                     76:              case ns_r_notzone:
                     77:                return ISC_R_NOTZONE;
                     78: 
                     79:              case ns_r_badsig:
                     80:                return ISC_R_BADSIG;
                     81: 
                     82:              case ns_r_badkey:
                     83:                return ISC_R_BADKEY;
                     84: 
                     85:              case ns_r_badtime:
                     86:                return ISC_R_BADTIME;
                     87: 
                     88:              default:
                     89:                ;
                     90:        }
                     91:        return ISC_R_UNEXPECTED;
                     92: }
                     93: 
                     94: isc_result_t uerr2isc (int err)
                     95: {
                     96:        switch (err) {
                     97:              case EPERM:
                     98:                return ISC_R_NOPERM;
                     99: 
                    100:              case ENOENT:
                    101:                return ISC_R_NOTFOUND;
                    102: 
                    103:              case ESRCH:
                    104:                return ISC_R_NOTFOUND;
                    105: 
                    106:              case EIO:
                    107:                return ISC_R_IOERROR;
                    108: 
                    109:              case ENXIO:
                    110:                return ISC_R_NOTFOUND;
                    111: 
                    112:              case E2BIG:
                    113:                return ISC_R_NOSPACE;
                    114: 
                    115:              case ENOEXEC:
                    116:                return ISC_R_FORMERR;
                    117: 
                    118:              case ECHILD:
                    119:                return ISC_R_NOTFOUND;
                    120: 
                    121:              case ENOMEM:
                    122:                return ISC_R_NOMEMORY;
                    123: 
                    124:              case EACCES:
                    125:                return ISC_R_NOPERM;
                    126: 
                    127:              case EFAULT:
                    128:                return ISC_R_INVALIDARG;
                    129: 
                    130:              case EEXIST:
                    131:                return ISC_R_EXISTS;
                    132: 
                    133:              case EINVAL:
                    134:                return ISC_R_INVALIDARG;
                    135: 
                    136:              case ENOTTY:
                    137:                return ISC_R_INVALIDARG;
                    138: 
                    139:              case EFBIG:
                    140:                return ISC_R_NOSPACE;
                    141: 
                    142:              case ENOSPC:
                    143:                return ISC_R_NOSPACE;
                    144: 
                    145:              case EROFS:
                    146:                return ISC_R_NOPERM;
                    147: 
                    148:              case EMLINK:
                    149:                return ISC_R_NOSPACE;
                    150: 
                    151:              case EPIPE:
                    152:                return ISC_R_NOTCONNECTED;
                    153: 
                    154:              case EINPROGRESS:
                    155:                return ISC_R_ALREADYRUNNING;
                    156: 
                    157:              case EALREADY:
                    158:                return ISC_R_ALREADYRUNNING;
                    159: 
                    160:              case ENOTSOCK:
                    161:                return ISC_R_INVALIDFILE;
                    162: 
                    163:              case EDESTADDRREQ:
                    164:                return ISC_R_DESTADDRREQ;
                    165: 
                    166:              case EMSGSIZE:
                    167:                return ISC_R_NOSPACE;
                    168: 
                    169:              case EPROTOTYPE:
                    170:                return ISC_R_INVALIDARG;
                    171: 
                    172:              case ENOPROTOOPT:
                    173:                return ISC_R_NOTIMPLEMENTED;
                    174: 
                    175:              case EPROTONOSUPPORT:
                    176:                return ISC_R_NOTIMPLEMENTED;
                    177: 
                    178:              case ESOCKTNOSUPPORT:
                    179:                return ISC_R_NOTIMPLEMENTED;
                    180: 
                    181:              case EOPNOTSUPP:
                    182:                return ISC_R_NOTIMPLEMENTED;
                    183: 
                    184:              case EPFNOSUPPORT:
                    185:                return ISC_R_NOTIMPLEMENTED;
                    186: 
                    187:              case EAFNOSUPPORT:
                    188:                return ISC_R_NOTIMPLEMENTED;
                    189: 
                    190:              case EADDRINUSE:
                    191:                return ISC_R_ADDRINUSE;
                    192: 
                    193:              case EADDRNOTAVAIL:
                    194:                return ISC_R_ADDRNOTAVAIL;
                    195: 
                    196:              case ENETDOWN:
                    197:                return ISC_R_NETDOWN;
                    198: 
                    199:              case ENETUNREACH:
                    200:                return ISC_R_NETUNREACH;
                    201: 
                    202:              case ECONNABORTED:
                    203:                return ISC_R_TIMEDOUT;
                    204: 
                    205:              case ECONNRESET:
                    206:                return ISC_R_CONNRESET;
                    207: 
                    208:              case ENOBUFS:
                    209:                return ISC_R_NOSPACE;
                    210: 
                    211:              case EISCONN:
                    212:                return ISC_R_ALREADYRUNNING;
                    213: 
                    214:              case ENOTCONN:
                    215:                return ISC_R_NOTCONNECTED;
                    216: 
                    217:              case ESHUTDOWN:
                    218:                return ISC_R_SHUTTINGDOWN;
                    219: 
                    220:              case ETIMEDOUT:
                    221:                return ISC_R_TIMEDOUT;
                    222: 
                    223:              case ECONNREFUSED:
                    224:                return ISC_R_CONNREFUSED;
                    225: 
                    226:              case EHOSTDOWN:
                    227:                return ISC_R_HOSTDOWN;
                    228: 
                    229:              case EHOSTUNREACH:
                    230:                return ISC_R_HOSTUNREACH;
                    231: 
                    232: #ifdef EDQUOT
                    233:              case EDQUOT:
                    234:                return ISC_R_QUOTA;
                    235: #endif
                    236: 
                    237: #ifdef EBADRPC
                    238:              case EBADRPC:
                    239:                return ISC_R_NOTIMPLEMENTED;
                    240: #endif
                    241: 
                    242: #ifdef ERPCMISMATCH
                    243:              case ERPCMISMATCH:
                    244:                return ISC_R_VERSIONMISMATCH;
                    245: #endif
                    246: 
                    247: #ifdef EPROGMISMATCH
                    248:              case EPROGMISMATCH:
                    249:                return ISC_R_VERSIONMISMATCH;
                    250: #endif
                    251: 
                    252: #ifdef EAUTH
                    253:              case EAUTH:
                    254:                return ISC_R_NOTAUTH;
                    255: #endif
                    256: 
                    257: #ifdef ENEEDAUTH
                    258:              case ENEEDAUTH:
                    259:                return ISC_R_NOTAUTH;
                    260: #endif
                    261: 
                    262: #ifdef EOVERFLOW
                    263:              case EOVERFLOW:
                    264:                return ISC_R_NOSPACE;
                    265: #endif
                    266:        }
                    267:        return ISC_R_UNEXPECTED;
                    268: }
                    269: 
                    270: ns_rcode isc_rcode_to_ns (isc_result_t isc)
                    271: {
                    272:        switch (isc) {
                    273:              case ISC_R_SUCCESS:
                    274:                return ns_r_noerror;
                    275: 
                    276:              case ISC_R_FORMERR:
                    277:                return ns_r_formerr;
                    278: 
                    279:              case ISC_R_SERVFAIL:
                    280:                return ns_r_servfail;
                    281: 
                    282:              case ISC_R_NXDOMAIN:
                    283:                return ns_r_nxdomain;
                    284: 
                    285:              case ISC_R_NOTIMPL:
                    286:                return ns_r_notimpl;
                    287: 
                    288:              case ISC_R_REFUSED:
                    289:                return ns_r_refused;
                    290: 
                    291:              case ISC_R_YXDOMAIN:
                    292:                return ns_r_yxdomain;
                    293: 
                    294:              case ISC_R_YXRRSET:
                    295:                return ns_r_yxrrset;
                    296: 
                    297:              case ISC_R_NXRRSET:
                    298:                return ns_r_nxrrset;
                    299: 
                    300:              case ISC_R_NOTAUTH:
                    301:                return ns_r_notauth;
                    302: 
                    303:              case ISC_R_NOTZONE:
                    304:                return ns_r_notzone;
                    305: 
                    306:              case ISC_R_BADSIG:
                    307:                return ns_r_badsig;
                    308: 
                    309:              case ISC_R_BADKEY:
                    310:                return ns_r_badkey;
                    311: 
                    312:              case ISC_R_BADTIME:
                    313:                return ns_r_badtime;
                    314: 
                    315:              default:
                    316:                ;
                    317:        }
                    318:        return ns_r_servfail;
                    319: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>