"Fossies" - the Fresh Open Source Software Archive

Member "knot-2.8.3/src/libdnssec/error.h" (16 Jul 2019, 2533 Bytes) of package /linux/misc/dns/knot-2.8.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "error.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.7.6_vs_2.8.0.

    1 /*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
    2 
    3     This program is free software: you can redistribute it and/or modify
    4     it under the terms of the GNU General Public License as published by
    5     the Free Software Foundation, either version 3 of the License, or
    6     (at your option) any later version.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
   10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11     GNU General Public License for more details.
   12 
   13     You should have received a copy of the GNU General Public License
   14     along with this program.  If not, see <https://www.gnu.org/licenses/>.
   15 */
   16 /*!
   17  * \file
   18  *
   19  * \addtogroup error
   20  *
   21  * \brief Error codes and error reporting.
   22  *
   23  * The module defines all error codes used in the library, and functions
   24  * to convert the error codes to sensible error strings.
   25  *
   26  * ~~~~~ {.c}
   27  * int result;
   28  *
   29  * result = dnssec_key_set_pubkey(NULL, NULL);
   30  * assert(result == DNSSEC_EINVAL);
   31  *
   32  * fprintf(stderr, "Error: %s.\n", dnssec_strerror(result));
   33  * // Error: Invalid argument.
   34  * ~~~~~
   35  *
   36  * @{
   37  */
   38 
   39 #pragma once
   40 
   41 #include <errno.h>
   42 
   43 /*!
   44  * Library error codes.
   45  */
   46 enum dnssec_error {
   47     DNSSEC_EOK = 0,
   48 
   49     DNSSEC_ENOMEM = -ENOMEM,
   50     DNSSEC_EINVAL = -EINVAL,
   51     DNSSEC_ENOENT = -ENOENT,
   52 
   53     DNSSEC_ERROR_MIN = -1500,
   54 
   55     DNSSEC_ERROR = DNSSEC_ERROR_MIN,
   56     DNSSEC_NOT_IMPLEMENTED_ERROR,
   57     DNSSEC_MALFORMED_DATA,
   58     DNSSEC_NOT_FOUND,
   59 
   60     DNSSEC_PKCS8_IMPORT_ERROR,
   61     DNSSEC_KEY_EXPORT_ERROR,
   62     DNSSEC_KEY_IMPORT_ERROR,
   63     DNSSEC_KEY_GENERATE_ERROR,
   64 
   65     DNSSEC_INVALID_PUBLIC_KEY,
   66     DNSSEC_INVALID_PRIVATE_KEY,
   67     DNSSEC_INVALID_KEY_ALGORITHM,
   68     DNSSEC_INVALID_KEY_SIZE,
   69     DNSSEC_INVALID_KEY_ID,
   70     DNSSEC_INVALID_KEY_NAME,
   71 
   72     DNSSEC_NO_PUBLIC_KEY,
   73     DNSSEC_NO_PRIVATE_KEY,
   74     DNSSEC_KEY_ALREADY_PRESENT,
   75 
   76     DNSSEC_SIGN_INIT_ERROR,
   77     DNSSEC_SIGN_ERROR,
   78     DNSSEC_INVALID_SIGNATURE,
   79 
   80     DNSSEC_INVALID_NSEC3_ALGORITHM,
   81     DNSSEC_NSEC3_HASHING_ERROR,
   82 
   83     DNSSEC_INVALID_DS_ALGORITHM,
   84     DNSSEC_DS_HASHING_ERROR,
   85 
   86     DNSSEC_KEYSTORE_INVALID_CONFIG,
   87 
   88     DNSSEC_P11_FAILED_TO_LOAD_MODULE,
   89     DNSSEC_P11_TOO_MANY_MODULES,
   90     DNSSEC_P11_TOKEN_NOT_AVAILABLE,
   91 
   92     DNSSEC_ERROR_MAX = -1001
   93 };
   94 
   95 /*!
   96  * Translate error code to error message.
   97  *
   98  * \param error  Error code.
   99  *
  100  * \return Statically allocated error message string or NULL if unknown.
  101  */
  102 const char *dnssec_strerror(int error);
  103 
  104 /*!
  105  * Convert errno value to DNSSEC error code.
  106  */
  107 static inline int dnssec_errno_to_error(int ecode)
  108 {
  109     return -ecode;
  110 }
  111 
  112 /*! @} */