diff --git a/Knot.files b/Knot.files index e05778d4e4be2e077102a962361bfa71394c6850..18884a0b8a37f5e0b4b5efa57d36fc250696b483 100644 --- a/Knot.files +++ b/Knot.files @@ -348,7 +348,8 @@ src/knot/zone/zonefile.c src/knot/zone/zonefile.h src/libknot/binary.c src/libknot/binary.h -src/libknot/consts.c +src/libknot/codes.c +src/libknot/codes.h src/libknot/consts.h src/libknot/descriptor.c src/libknot/descriptor.h @@ -358,7 +359,6 @@ src/libknot/dnssec/rrset-sign.c src/libknot/dnssec/rrset-sign.h src/libknot/errcode.c src/libknot/errcode.h -src/libknot/internal/consts.h src/libknot/internal/errcode.c src/libknot/internal/errcode.h src/libknot/internal/hhash.c diff --git a/src/Makefile.am b/src/Makefile.am index db12b1c51377baba664ea535dd88f10aedc4440d..249f00e10822cdb3e5c8149ad55e2beb7d0af944 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,6 +43,7 @@ nobase_libcontrib_la_HEADERS = \ libknot_ladir = $(includedir) nobase_libknot_la_HEADERS = \ libknot/binary.h \ + libknot/codes.h \ libknot/consts.h \ libknot/descriptor.h \ libknot/dname.h \ @@ -77,7 +78,6 @@ nobase_libknot_la_HEADERS = \ libknot_internal_ladir = $(includedir) nobase_libknot_internal_la_HEADERS = \ - libknot/internal/consts.h \ libknot/internal/errcode.h \ libknot/internal/hhash.h \ libknot/internal/lists.h \ @@ -114,7 +114,7 @@ libcontrib_la_SOURCES = \ libknot_la_SOURCES = \ libknot/binary.c \ - libknot/consts.c \ + libknot/codes.c \ libknot/descriptor.c \ libknot/dname.c \ libknot/dnssec/rrset-sign.c \ diff --git a/src/libknot/consts.c b/src/libknot/codes.c similarity index 98% rename from src/libknot/consts.c rename to src/libknot/codes.c index 2cce59c0224a7260144a2cf7effc11fb6aecc7a5..ce3dc00f2037ab6ad080175b287a948a7d583650 100644 --- a/src/libknot/consts.c +++ b/src/libknot/codes.c @@ -14,7 +14,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "libknot/consts.h" +#include "libknot/codes.h" #include "libknot/internal/macros.h" _public_ diff --git a/src/libknot/codes.h b/src/libknot/codes.h new file mode 100644 index 0000000000000000000000000000000000000000..e79317759af3596affee345753d4dc9665d42687 --- /dev/null +++ b/src/libknot/codes.h @@ -0,0 +1,58 @@ +/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +/*! + * \file + * + * \brief Some DNS-related code names. + * + * \addtogroup libknot + * @{ + */ + +#pragma once + +#include <stdbool.h> +#include <stdint.h> + +#include "libknot/consts.h" +#include "libknot/internal/utils.h" + +/*! + * \brief DNS operation code names. + */ +extern lookup_table_t knot_opcode_names[]; + +/*! + * \brief DNS reply code names. + */ +extern lookup_table_t knot_rcode_names[]; + +/*! + * \brief TSIG error names. + */ +extern lookup_table_t knot_tsig_err_names[]; + +/*! + * \brief TKEY error names. + */ +extern lookup_table_t knot_tkey_err_names[]; + +/*! + * \brief DNSSEC algorithm names. + */ +extern lookup_table_t knot_dnssec_alg_names[]; + +/*! @} */ diff --git a/src/libknot/consts.h b/src/libknot/consts.h index 831900edf6412a2032fd5b50dd3a45ab9400687c..83cda114e9dcf20bdbf0634caac9255b5d1a2b39 100644 --- a/src/libknot/consts.h +++ b/src/libknot/consts.h @@ -1,13 +1,3 @@ -/*! - * \file consts.h - * - * \author Lubos Slovak <lubos.slovak@nic.cz> - * - * \brief Contains some DNS-related constants. - * - * \addtogroup libknot - * @{ - */ /* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify @@ -23,38 +13,163 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/*! + * \file + * + * \brief Some DNS-related constants. + * + * \addtogroup libknot + * @{ + */ #pragma once -#include <stdbool.h> -#include <stdint.h> +/*! + * \brief Basic limits for domain names (RFC 1035). + */ +#define KNOT_DNAME_MAXLEN 255 /*!< 1-byte maximum. */ +#define KNOT_DNAME_MAXLABELS 127 /*!< 1-char labels. */ +#define KNOT_DNAME_MAXLABELLEN 63 /*!< 2^6 - 1 */ + +/*! + * \brief The longest textual dname representation. + * + * 3 x maximum_label + 1 x rest_label + 1 x zero_label + * Each dname label byte takes 4 characters (\DDD). + * Each label takes 1 more byte for '.' character. + * + * KNOT_DNAME_TXT_MAXLEN = 3x(1 + 63x4) + 1x(1 + 61x4) + 1x(1 + 0) + */ +#define KNOT_DNAME_TXT_MAXLEN 1005 + +/*! + * \brief Address family numbers. + * + * http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml + */ +typedef enum { + KNOT_ADDR_FAMILY_IPV4 = 1, /*!< IP version 4. */ + KNOT_ADDR_FAMILY_IPV6 = 2 /*!< IP version 6. */ +} knot_addr_family_t; + +/*! + * \brief DNS operation codes (OPCODEs). + * + * http://www.iana.org/assignments/dns-parameters/dns-parameters.xml + */ +typedef enum { + KNOT_OPCODE_QUERY = 0, /*!< Standard query. */ + KNOT_OPCODE_IQUERY = 1, /*!< Inverse query. */ + KNOT_OPCODE_STATUS = 2, /*!< Server status request. */ + KNOT_OPCODE_NOTIFY = 4, /*!< Notify message. */ + KNOT_OPCODE_UPDATE = 5 /*!< Dynamic update. */ +} knot_opcode_t; + +/*! + * \brief DNS reply codes (RCODEs). + * + * http://www.iana.org/assignments/dns-parameters/dns-parameters.xml + * + * \note Here, only RCODEs present in Header or as an Extended RCODE in + * OPT + Header are listed. Other codes are used in dedicated fields of + * other RRs. + */ +typedef enum { + KNOT_RCODE_NOERROR = 0, /*!< No error. */ + KNOT_RCODE_FORMERR = 1, /*!< Format error. */ + KNOT_RCODE_SERVFAIL = 2, /*!< Server failure. */ + KNOT_RCODE_NXDOMAIN = 3, /*!< Non-existend domain. */ + KNOT_RCODE_NOTIMPL = 4, /*!< Not implemented. */ + KNOT_RCODE_REFUSED = 5, /*!< Refused. */ + KNOT_RCODE_YXDOMAIN = 6, /*!< Name should not exist. */ + KNOT_RCODE_YXRRSET = 7, /*!< RR set should not exist. */ + KNOT_RCODE_NXRRSET = 8, /*!< RR set does not exist. */ + KNOT_RCODE_NOTAUTH = 9, /*!< Server not authoritative. / Query not authorized. */ + KNOT_RCODE_NOTZONE = 10, /*!< Name is not inside zone. */ + KNOT_RCODE_BADVERS = 16 /*!< Bad OPT Version. */ +} knot_rcode_t; + +/*! + * \brief TSIG error codes to be set in the TSIG RR's RDATA. + * + * Defined in RFC 2845 and RFC 4635. + * See also https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml + */ +typedef enum { + KNOT_TSIG_ERR_BADSIG = 16, /*!< TSIG signature failed. */ + KNOT_TSIG_ERR_BADKEY = 17, /*!< Key is not supported. */ + KNOT_TSIG_ERR_BADTIME = 18, /*!< Signature out of time window. */ + KNOT_TSIG_ERR_BADTRUNC = 22 /*!< Bad truncation. */ +} knot_tsig_error_t; -#include "libknot/internal/utils.h" -#include "libknot/internal/consts.h" +/*! + * \brief TKEY error codes. (Defined in RFC 2930.) + */ +typedef enum { + KNOT_TKEY_ERR_BADMODE = 19, /*!< Bad TKEY mode. */ + KNOT_TKEY_ERR_BADNAME = 20, /*!< Duplicate key name. */ + KNOT_TKEY_ERR_BADALG = 21 /*!< Algorithm not supported. */ +} knot_tkey_error_t; /*! - * \brief DNS operation code names. + * \brief DNS packet section identifiers. */ -extern lookup_table_t knot_opcode_names[]; +typedef enum { + KNOT_ANSWER = 0, + KNOT_AUTHORITY = 1, + KNOT_ADDITIONAL = 2 +} knot_section_t; /*! - * \brief DNS reply code names. + * \brief DS digest lengths. */ -extern lookup_table_t knot_rcode_names[]; +enum knot_ds_algorithm_len +{ + KNOT_DS_DIGEST_LEN_SHA1 = 20, /*!< RFC 3658 */ + KNOT_DS_DIGEST_LEN_SHA256 = 32, /*!< RFC 4509 */ + KNOT_DS_DIGEST_LEN_GOST = 32, /*!< RFC 5933 */ + KNOT_DS_DIGEST_LEN_SHA384 = 48 /*!< RFC 6605 */ +}; /*! - * \brief TSIG error names. + * \brief Constants for DNSSEC algorithm types. + * + * Source: http://www.iana.org/assignments/ds-rr-types/ds-rr-types.xml */ -extern lookup_table_t knot_tsig_err_names[]; +typedef enum { + KNOT_DS_ALG_SHA1 = 1, + KNOT_DS_ALG_SHA256 = 2, + KNOT_DS_ALG_GOST = 3, + KNOT_DS_ALG_SHA384 = 4 +} knot_ds_algorithm_t; /*! - * \brief TKEY error names. + * \brief DNSSEC algorithm numbers. + * + * http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xml */ -extern lookup_table_t knot_tkey_err_names[]; +typedef enum { + KNOT_DNSSEC_ALG_RSAMD5 = 1, + KNOT_DNSSEC_ALG_DH = 2, + KNOT_DNSSEC_ALG_DSA = 3, + + KNOT_DNSSEC_ALG_RSASHA1 = 5, + KNOT_DNSSEC_ALG_DSA_NSEC3_SHA1 = 6, + KNOT_DNSSEC_ALG_RSASHA1_NSEC3_SHA1 = 7, + KNOT_DNSSEC_ALG_RSASHA256 = 8, + + KNOT_DNSSEC_ALG_RSASHA512 = 10, + + KNOT_DNSSEC_ALG_ECC_GOST = 12, + KNOT_DNSSEC_ALG_ECDSAP256SHA256 = 13, + KNOT_DNSSEC_ALG_ECDSAP384SHA384 = 14 +} knot_dnssec_algorithm_t; /*! - * \brief DNSSEC algorithm names. + * \brief NSEC3 hash algorithm numbers. */ -extern lookup_table_t knot_dnssec_alg_names[]; +typedef enum { + KNOT_NSEC3_ALGORITHM_SHA1 = 1 +} knot_nsec3_hash_algorithm_t; /*! @} */ diff --git a/src/libknot/dname.c b/src/libknot/dname.c index e9f42e2853e331254b038cced99465c45bd7a56c..5f890f70c4913bb8ce585a88fd253cfe4c3aa8fe 100644 --- a/src/libknot/dname.c +++ b/src/libknot/dname.c @@ -21,8 +21,8 @@ #include <string.h> #include <inttypes.h> -#include "libknot/dname.h" #include "libknot/consts.h" +#include "libknot/dname.h" #include "libknot/errcode.h" #include "libknot/packet/wire.h" #include "libknot/internal/macros.h" diff --git a/src/libknot/internal/consts.h b/src/libknot/internal/consts.h deleted file mode 100644 index 3897df8c8301349ee9d638c12a610d57d71e590d..0000000000000000000000000000000000000000 --- a/src/libknot/internal/consts.h +++ /dev/null @@ -1,177 +0,0 @@ -/*! - * \file consts.h - * - * \author Lubos Slovak <lubos.slovak@nic.cz> - * - * \brief Contains some DNS-related constants. - * - * \addtogroup libknot - * @{ - */ -/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -/*! - * \brief Basic limits for domain names (RFC 1035). - */ -#define KNOT_DNAME_MAXLEN 255 /*!< 1-byte maximum. */ -#define KNOT_DNAME_MAXLABELS 127 /*!< 1-char labels. */ -#define KNOT_DNAME_MAXLABELLEN 63 /*!< 2^6 - 1 */ - -/*! - * \brief The longest textual dname representation. - * - * 3 x maximum_label + 1 x rest_label + 1 x zero_label - * Each dname label byte takes 4 characters (\DDD). - * Each label takes 1 more byte for '.' character. - * - * KNOT_DNAME_TXT_MAXLEN = 3x(1 + 63x4) + 1x(1 + 61x4) + 1x(1 + 0) - */ -#define KNOT_DNAME_TXT_MAXLEN 1005 - -/*! - * \brief Address family numbers. - * - * http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml - */ -typedef enum { - KNOT_ADDR_FAMILY_IPV4 = 1, /*!< IP version 4. */ - KNOT_ADDR_FAMILY_IPV6 = 2 /*!< IP version 6. */ -} knot_addr_family_t; - -/*! - * \brief DNS operation codes (OPCODEs). - * - * http://www.iana.org/assignments/dns-parameters/dns-parameters.xml - */ -typedef enum { - KNOT_OPCODE_QUERY = 0, /*!< Standard query. */ - KNOT_OPCODE_IQUERY = 1, /*!< Inverse query. */ - KNOT_OPCODE_STATUS = 2, /*!< Server status request. */ - KNOT_OPCODE_NOTIFY = 4, /*!< Notify message. */ - KNOT_OPCODE_UPDATE = 5 /*!< Dynamic update. */ -} knot_opcode_t; - -/*! - * \brief DNS reply codes (RCODEs). - * - * http://www.iana.org/assignments/dns-parameters/dns-parameters.xml - * - * \note Here, only RCODEs present in Header or as an Extended RCODE in - * OPT + Header are listed. Other codes are used in dedicated fields of - * other RRs. - */ -typedef enum { - KNOT_RCODE_NOERROR = 0, /*!< No error. */ - KNOT_RCODE_FORMERR = 1, /*!< Format error. */ - KNOT_RCODE_SERVFAIL = 2, /*!< Server failure. */ - KNOT_RCODE_NXDOMAIN = 3, /*!< Non-existend domain. */ - KNOT_RCODE_NOTIMPL = 4, /*!< Not implemented. */ - KNOT_RCODE_REFUSED = 5, /*!< Refused. */ - KNOT_RCODE_YXDOMAIN = 6, /*!< Name should not exist. */ - KNOT_RCODE_YXRRSET = 7, /*!< RR set should not exist. */ - KNOT_RCODE_NXRRSET = 8, /*!< RR set does not exist. */ - KNOT_RCODE_NOTAUTH = 9, /*!< Server not authoritative. / Query not authorized. */ - KNOT_RCODE_NOTZONE = 10, /*!< Name is not inside zone. */ - KNOT_RCODE_BADVERS = 16 /*!< Bad OPT Version. */ -} knot_rcode_t; - -/*! - * \brief TSIG error codes to be set in the TSIG RR's RDATA. - * - * Defined in RFC 2845 and RFC 4635. - * See also https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml - */ -typedef enum { - KNOT_TSIG_ERR_BADSIG = 16, /*!< TSIG signature failed. */ - KNOT_TSIG_ERR_BADKEY = 17, /*!< Key is not supported. */ - KNOT_TSIG_ERR_BADTIME = 18, /*!< Signature out of time window. */ - KNOT_TSIG_ERR_BADTRUNC = 22 /*!< Bad truncation. */ -} knot_tsig_error_t; - -/*! - * \brief TKEY error codes. (Defined in RFC 2930.) - */ -typedef enum { - KNOT_TKEY_ERR_BADMODE = 19, /*!< Bad TKEY mode. */ - KNOT_TKEY_ERR_BADNAME = 20, /*!< Duplicate key name. */ - KNOT_TKEY_ERR_BADALG = 21 /*!< Algorithm not supported. */ -} knot_tkey_error_t; - -/*! - * \brief DNS packet section identifiers. - */ -typedef enum { - KNOT_ANSWER = 0, - KNOT_AUTHORITY = 1, - KNOT_ADDITIONAL = 2 -} knot_section_t; - -/*! - * \brief DS digest lengths. - */ -enum knot_ds_algorithm_len -{ - KNOT_DS_DIGEST_LEN_SHA1 = 20, /*!< RFC 3658 */ - KNOT_DS_DIGEST_LEN_SHA256 = 32, /*!< RFC 4509 */ - KNOT_DS_DIGEST_LEN_GOST = 32, /*!< RFC 5933 */ - KNOT_DS_DIGEST_LEN_SHA384 = 48 /*!< RFC 6605 */ -}; - -/*! - * \brief Constants for DNSSEC algorithm types. - * - * Source: http://www.iana.org/assignments/ds-rr-types/ds-rr-types.xml - */ -typedef enum { - KNOT_DS_ALG_SHA1 = 1, - KNOT_DS_ALG_SHA256 = 2, - KNOT_DS_ALG_GOST = 3, - KNOT_DS_ALG_SHA384 = 4 -} knot_ds_algorithm_t; - -/*! - * \brief DNSSEC algorithm numbers. - * - * http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xml - */ -typedef enum { - KNOT_DNSSEC_ALG_RSAMD5 = 1, - KNOT_DNSSEC_ALG_DH = 2, - KNOT_DNSSEC_ALG_DSA = 3, - - KNOT_DNSSEC_ALG_RSASHA1 = 5, - KNOT_DNSSEC_ALG_DSA_NSEC3_SHA1 = 6, - KNOT_DNSSEC_ALG_RSASHA1_NSEC3_SHA1 = 7, - KNOT_DNSSEC_ALG_RSASHA256 = 8, - - KNOT_DNSSEC_ALG_RSASHA512 = 10, - - KNOT_DNSSEC_ALG_ECC_GOST = 12, - KNOT_DNSSEC_ALG_ECDSAP256SHA256 = 13, - KNOT_DNSSEC_ALG_ECDSAP384SHA384 = 14 -} knot_dnssec_algorithm_t; - -/*! - * \brief NSEC3 hash algorithm numbers. - */ -typedef enum { - KNOT_NSEC3_ALGORITHM_SHA1 = 1 -} knot_nsec3_hash_algorithm_t; - -/*! @} */ diff --git a/src/libknot/internal/sockaddr.c b/src/libknot/internal/sockaddr.c index 4554a41dd50f87aef4c1dc5d82a0ca13e3416ead..e447155d823680fffea1c951051ad64c51f7632f 100644 --- a/src/libknot/internal/sockaddr.c +++ b/src/libknot/internal/sockaddr.c @@ -18,11 +18,11 @@ #include <string.h> #include <netdb.h> +#include "libknot/consts.h" #include "libknot/internal/macros.h" #include "libknot/internal/utils.h" #include "libknot/internal/sockaddr.h" #include "libknot/internal/errcode.h" -#include "libknot/internal/consts.h" #include "contrib/openbsd/strlcpy.h" int sockaddr_len(const struct sockaddr *ss) diff --git a/src/libknot/rrset-dump.c b/src/libknot/rrset-dump.c index 93a617f112ecdc2832ae5a65c8ed3335cfcd3f07..3f14ddab1289df4fecfffef35e0fc5aad0cfb1a6 100644 --- a/src/libknot/rrset-dump.c +++ b/src/libknot/rrset-dump.c @@ -28,7 +28,7 @@ #include "dnssec/binary.h" #include "dnssec/keytag.h" #include "libknot/rrset-dump.h" -#include "libknot/consts.h" +#include "libknot/codes.h" #include "libknot/descriptor.h" #include "libknot/errcode.h" #include "libknot/internal/macros.h" diff --git a/src/libknot/rrtype/nsec3.h b/src/libknot/rrtype/nsec3.h index 7e6ca7edecbdf753d721edd4ca9f070c83e15033..52c95638ee012488b1ad7e59aef5029c15f44b0e 100644 --- a/src/libknot/rrtype/nsec3.h +++ b/src/libknot/rrtype/nsec3.h @@ -31,7 +31,7 @@ #include <stdint.h> #include <string.h> -#include "libknot/consts.h" +#include "libknot/codes.h" #include "libknot/rdataset.h" #include "libknot/rrtype/nsec3param.h" diff --git a/src/libknot/rrtype/nsec3param.h b/src/libknot/rrtype/nsec3param.h index d5655fe7a2eb8e4f2edd589ed95d248ae91612b9..133013a101e81856f5954ff8738f1028308c2d76 100644 --- a/src/libknot/rrtype/nsec3param.h +++ b/src/libknot/rrtype/nsec3param.h @@ -22,6 +22,7 @@ #include "libknot/consts.h" #include "libknot/rdataset.h" +#include "libknot/internal/utils.h" /*! * \brief Structure representing the NSEC3PARAM resource record.