1/* $NetBSD: toisc.c,v 1.3 2022/04/03 01:10:59 christos Exp $ */ 2 3/* toisc.c 4 5 Convert non-ISC result codes to ISC result codes. */ 6 7/* 8 * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC") 9 * Copyright (c) 2001-2003 by Internet Software Consortium 10 * 11 * This Source Code Form is subject to the terms of the Mozilla Public 12 * License, v. 2.0. If a copy of the MPL was not distributed with this 13 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 21 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 * 23 * Internet Systems Consortium, Inc. 24 * PO Box 360 25 * Newmarket, NH 03857 USA 26 * <info@isc.org> 27 * https://www.isc.org/ 28 * 29 */ 30 31#include <sys/cdefs.h> 32__RCSID("$NetBSD: toisc.c,v 1.3 2022/04/03 01:10:59 christos Exp $"); 33 34#include "dhcpd.h" 35 36#include <omapip/omapip_p.h> 37#include "arpa/nameser.h" 38#include "ns_name.h" 39 40#include <errno.h> 41 42isc_result_t uerr2isc (int err) 43{ 44 switch (err) { 45 case EPERM: 46 return ISC_R_NOPERM; 47 48 case ENOENT: 49 return ISC_R_NOTFOUND; 50 51 case ESRCH: 52 return ISC_R_NOTFOUND; 53 54 case EIO: 55 return ISC_R_IOERROR; 56 57 case ENXIO: 58 return ISC_R_NOTFOUND; 59 60 case E2BIG: 61 return ISC_R_NOSPACE; 62 63 case ENOEXEC: 64 return DHCP_R_FORMERR; 65 66 case ECHILD: 67 return ISC_R_NOTFOUND; 68 69 case ENOMEM: 70 return ISC_R_NOMEMORY; 71 72 case EACCES: 73 return ISC_R_NOPERM; 74 75 case EFAULT: 76 return DHCP_R_INVALIDARG; 77 78 case EEXIST: 79 return ISC_R_EXISTS; 80 81 case EINVAL: 82 return DHCP_R_INVALIDARG; 83 84 case ENOTTY: 85 return DHCP_R_INVALIDARG; 86 87 case EFBIG: 88 return ISC_R_NOSPACE; 89 90 case ENOSPC: 91 return ISC_R_NOSPACE; 92 93 case EROFS: 94 return ISC_R_NOPERM; 95 96 case EMLINK: 97 return ISC_R_NOSPACE; 98 99 case EPIPE: 100 return ISC_R_NOTCONNECTED; 101 102 case EINPROGRESS: 103 return ISC_R_ALREADYRUNNING; 104 105 case EALREADY: 106 return ISC_R_ALREADYRUNNING; 107 108 case ENOTSOCK: 109 return ISC_R_INVALIDFILE; 110 111 case EDESTADDRREQ: 112 return DHCP_R_DESTADDRREQ; 113 114 case EMSGSIZE: 115 return ISC_R_NOSPACE; 116 117 case EPROTOTYPE: 118 return DHCP_R_INVALIDARG; 119 120 case ENOPROTOOPT: 121 return ISC_R_NOTIMPLEMENTED; 122 123 case EPROTONOSUPPORT: 124 return ISC_R_NOTIMPLEMENTED; 125 126 case ESOCKTNOSUPPORT: 127 return ISC_R_NOTIMPLEMENTED; 128 129 case EOPNOTSUPP: 130 return ISC_R_NOTIMPLEMENTED; 131 132 case EPFNOSUPPORT: 133 return ISC_R_NOTIMPLEMENTED; 134 135 case EAFNOSUPPORT: 136 return ISC_R_NOTIMPLEMENTED; 137 138 case EADDRINUSE: 139 return ISC_R_ADDRINUSE; 140 141 case EADDRNOTAVAIL: 142 return ISC_R_ADDRNOTAVAIL; 143 144 case ENETDOWN: 145 return ISC_R_NETDOWN; 146 147 case ENETUNREACH: 148 return ISC_R_NETUNREACH; 149 150 case ECONNABORTED: 151 return ISC_R_TIMEDOUT; 152 153 case ECONNRESET: 154 return DHCP_R_CONNRESET; 155 156 case ENOBUFS: 157 return ISC_R_NOSPACE; 158 159 case EISCONN: 160 return ISC_R_ALREADYRUNNING; 161 162 case ENOTCONN: 163 return ISC_R_NOTCONNECTED; 164 165 case ESHUTDOWN: 166 return ISC_R_SHUTTINGDOWN; 167 168 case ETIMEDOUT: 169 return ISC_R_TIMEDOUT; 170 171 case ECONNREFUSED: 172 return ISC_R_CONNREFUSED; 173 174 case EHOSTDOWN: 175 return ISC_R_HOSTDOWN; 176 177 case EHOSTUNREACH: 178 return ISC_R_HOSTUNREACH; 179 180#ifdef EDQUOT 181 case EDQUOT: 182 return ISC_R_QUOTA; 183#endif 184 185#ifdef EBADRPC 186 case EBADRPC: 187 return ISC_R_NOTIMPLEMENTED; 188#endif 189 190#ifdef ERPCMISMATCH 191 case ERPCMISMATCH: 192 return DHCP_R_VERSIONMISMATCH; 193#endif 194 195#ifdef EPROGMISMATCH 196 case EPROGMISMATCH: 197 return DHCP_R_VERSIONMISMATCH; 198#endif 199 200#ifdef EAUTH 201 case EAUTH: 202 return DHCP_R_NOTAUTH; 203#endif 204 205#ifdef ENEEDAUTH 206 case ENEEDAUTH: 207 return DHCP_R_NOTAUTH; 208#endif 209 210#ifdef EOVERFLOW 211 case EOVERFLOW: 212 return ISC_R_NOSPACE; 213#endif 214 } 215 return ISC_R_UNEXPECTED; 216} 217