consts.h 4.84 KB
Newer Older
1
/*  Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
Lubos Slovak's avatar
Lubos Slovak committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15

    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/>.
 */
16 17 18 19 20 21 22 23
/*!
 * \file
 *
 * \brief Some DNS-related constants.
 *
 * \addtogroup libknot
 * @{
 */
Lubos Slovak's avatar
Lubos Slovak committed
24

25
#pragma once
Lubos Slovak's avatar
Lubos Slovak committed
26

27 28 29 30 31 32 33 34 35 36 37
/*!
 * \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
38
 * Each dname label byte takes 4 characters (\\DDD).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
 * 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
 */
typedef enum {
74 75 76 77 78 79 80 81 82 83 84 85
	KNOT_RCODE_NOERROR   =  0, /*!< No error. */
	KNOT_RCODE_FORMERR   =  1, /*!< Format error. */
	KNOT_RCODE_SERVFAIL  =  2, /*!< Server failure. */
	KNOT_RCODE_NXDOMAIN  =  3, /*!< Non-existent 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. */
86 87 88 89 90 91 92
	KNOT_RCODE_BADSIG    = 16, /*!< (TSIG) Signature failure. */
	KNOT_RCODE_BADKEY    = 17, /*!< (TSIG) Key is not supported. */
	KNOT_RCODE_BADTIME   = 18, /*!< (TSIG) Signature out of time window. */
	KNOT_RCODE_BADMODE   = 19, /*!< (TKEY) Bad mode. */
	KNOT_RCODE_BADNAME   = 20, /*!< (TKEY) Duplicate key name. */
	KNOT_RCODE_BADALG    = 21, /*!< (TKEY) Algorithm not supported. */
	KNOT_RCODE_BADTRUNC  = 22, /*!< (TSIG) Bad truncation. */
93
	KNOT_RCODE_BADCOOKIE = 23  /*!< Bad/missing server cookie. */
94 95
} knot_rcode_t;

96
/*!
97
 * \brief DNS packet section identifiers.
98
 */
99 100 101 102 103
typedef enum {
	KNOT_ANSWER       = 0,
	KNOT_AUTHORITY    = 1,
	KNOT_ADDITIONAL   = 2
} knot_section_t;
104 105

/*!
106
 * \brief DS digest lengths.
107
 */
108 109 110 111 112 113 114
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 */
};
115

116
/*!
117 118 119
 * \brief Constants for DNSSEC algorithm types.
 *
 * Source: http://www.iana.org/assignments/ds-rr-types/ds-rr-types.xml
120
 */
121 122 123 124 125 126
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;
127 128

/*!
129 130 131
 * \brief DNSSEC algorithm numbers.
 *
 * http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xml
132
 */
133
typedef enum {
134 135 136
	KNOT_DNSSEC_ALG_RSAMD5             =   1,
	KNOT_DNSSEC_ALG_DH                 =   2,
	KNOT_DNSSEC_ALG_DSA                =   3,
137

138 139 140 141
	KNOT_DNSSEC_ALG_RSASHA1            =   5,
	KNOT_DNSSEC_ALG_DSA_NSEC3_SHA1     =   6,
	KNOT_DNSSEC_ALG_RSASHA1_NSEC3_SHA1 =   7,
	KNOT_DNSSEC_ALG_RSASHA256          =   8,
142

143
	KNOT_DNSSEC_ALG_RSASHA512          =  10,
144

145 146 147 148
	KNOT_DNSSEC_ALG_ECC_GOST           =  12,
	KNOT_DNSSEC_ALG_ECDSAP256SHA256    =  13,
	KNOT_DNSSEC_ALG_ECDSAP384SHA384    =  14,

149 150 151
	KNOT_DNSSEC_ALG_ED25519            =  15,
	KNOT_DNSSEC_ALG_ED448              =  16,

152 153 154
	KNOT_DNSSEC_ALG_INDIRECT           = 252,
	KNOT_DNSSEC_ALG_PRIVATEDNS         = 253,
	KNOT_DNSSEC_ALG_PRIVATEOID         = 254
155
} knot_dnssec_algorithm_t;
156

157
/*! @} */