summaryrefslogtreecommitdiff
path: root/src/libknot/consts.h
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2013-06-28 12:59:40 +0200
committerOndřej Surý <ondrej@sury.org>2013-06-28 12:59:40 +0200
commit124965832295a277b9ca6ae9fac4f45a74a36b2a (patch)
treef299e2335863f74e0be0707f84b85211baaf2d03 /src/libknot/consts.h
parent3d2d198c71a6b844b60fa9ef68801b66bba93361 (diff)
downloadknot-124965832295a277b9ca6ae9fac4f45a74a36b2a.tar.gz
New upstream version 1.3.0~rc3upstream/1.3.0_rc3
Diffstat (limited to 'src/libknot/consts.h')
-rw-r--r--src/libknot/consts.h216
1 files changed, 161 insertions, 55 deletions
diff --git a/src/libknot/consts.h b/src/libknot/consts.h
index 3431bc3..e2b3a82 100644
--- a/src/libknot/consts.h
+++ b/src/libknot/consts.h
@@ -28,27 +28,64 @@
#define _KNOT_CONSTS_H_
#include <stdint.h>
-#include "util/descriptor.h"
-
-/*
- * OPCODEs
- */
-typedef enum knot_opcode {
- KNOT_OPCODE_QUERY = 0, /* a standard query (QUERY) */
- KNOT_OPCODE_IQUERY = 1, /* an inverse query (IQUERY) */
- KNOT_OPCODE_STATUS = 2, /* a server status request (STATUS) */
- KNOT_OPCODE_NOTIFY = 4, /* NOTIFY */
- KNOT_OPCODE_UPDATE = 5, /* Dynamic update */
- KNOT_OPCODE_OFFSET = 14
+
+#include "libknot/util/utils.h"
+
+/*!
+ * \brief Basic limits for domain names (RFC 1035).
+ */
+typedef enum {
+ KNOT_MAX_DNAME_LENGTH = 255, /*!< 1-byte maximum. */
+ KNOT_MAX_DNAME_LABELS = 127 /*!< 1-char labels. */
+} knot_const_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 Query types (internal use only).
+ * \brief DNS reply codes (RCODEs).
+ *
+ * http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
+ */
+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. */
+ KNOT_RCODE_NOTZONE = 10, /*!< Name is not inside zone. */
+ KNOT_RCODE_BADSIG = 16, /*!< TSIG signature failed. */
+ KNOT_RCODE_BADKEY = 17, /*!< Key is not supported. */
+ KNOT_RCODE_BADTIME = 18, /*!< Signature out of time window. */
+ KNOT_RCODE_BADMODE = 19, /*!< Bad TKEY mode. */
+ KNOT_RCODE_BADNAME = 20, /*!< Duplicate key name. */
+ KNOT_RCODE_BADALG = 21, /*!< Algorithm not supported. */
+ KNOT_RCODE_BADTRUNC = 22 /*!< Bad truncation. */
+} knot_rcode_t;
+
+/*!
+ * \brief DNS query types (internal use only).
*
* This type encompasses the different query types distinguished by both the
* OPCODE and the QTYPE.
*/
-typedef enum knot_packet_type {
+typedef enum {
+ KNOT_QUERY_INVALID, /*!< Invalid query. */
KNOT_QUERY_NORMAL, /*!< Normal query. */
KNOT_QUERY_AXFR, /*!< Request for AXFR transfer. */
KNOT_QUERY_IXFR, /*!< Request for IXFR transfer. */
@@ -61,48 +98,117 @@ typedef enum knot_packet_type {
KNOT_RESPONSE_UPDATE /*!< Dynamic update response. */
} knot_packet_type_t;
-/*
- * RCODEs
- */
-typedef enum knot_rcode {
- KNOT_RCODE_NOERROR = 0, /* No error condition */
- KNOT_RCODE_FORMERR = 1, /* Format error */
- KNOT_RCODE_SERVFAIL = 2, /* Server failure */
- KNOT_RCODE_NXDOMAIN = 3, /* Name Error */
- KNOT_RCODE_NOTIMPL = 4, /* Not implemented */
- KNOT_RCODE_REFUSED = 5, /* Refused */
- KNOT_RCODE_YXDOMAIN = 6, /* name should not exist */
- KNOT_RCODE_YXRRSET = 7, /* rrset should not exist */
- KNOT_RCODE_NXRRSET = 8, /* rrset does not exist */
- KNOT_RCODE_NOTAUTH = 9, /* server not authoritative */
- KNOT_RCODE_NOTZONE = 10, /* name not inside zone */
-} knot_rcode_t;
+/*!
+ * \brief TSIG algorithm numbers.
+ *
+ * These constants were taken from the Bind file key format (dnssec-keygen).
+ */
+typedef enum {
+ KNOT_TSIG_ALG_NULL = 0,
+ KNOT_TSIG_ALG_GSS_TSIG = 128,
+ KNOT_TSIG_ALG_HMAC_MD5 = 157,
+ KNOT_TSIG_ALG_HMAC_SHA1 = 161,
+ KNOT_TSIG_ALG_HMAC_SHA224 = 162,
+ KNOT_TSIG_ALG_HMAC_SHA256 = 163,
+ KNOT_TSIG_ALG_HMAC_SHA384 = 164,
+ KNOT_TSIG_ALG_HMAC_SHA512 = 165
+} knot_tsig_algorithm_t;
-typedef enum knot_tsig_rcode {
- KNOT_TSIG_RCODE_BADSIG = 16,
- KNOT_TSIG_RCODE_BADKEY = 17,
- KNOT_TSIG_RCODE_BADTIME = 18
-} knot_tsig_rcode_t;
-
-/*
- * CLASSes
- */
-//typedef enum knot_class {
-// KNOT_CLASS_IN = 1, /* Class IN */
-// KNOT_CLASS_CS = 2, /* Class CS */
-// KNOT_CLASS_CH = 3, /* Class CHAOS */
-// KNOT_CLASS_HS = 4, /* Class HS */
-// KNOT_CLASS_NONE = 254, /* Class NONE rfc2136 */
-// KNOT_CLASS_ANY = 255 /* Class ANY */
-//} knot_class_t;
-
-/*
- * Other
- */
-typedef enum knot_const {
- KNOT_MAX_DNAME_LENGTH = 255,
- KNOT_MAX_DNAME_LABELS = 127 // 1-char labels
-} knot_const_t;
+/*!
+ * \brief Lengths of TSIG algorithm digests.
+ */
+typedef enum {
+ KNOT_TSIG_ALG_DIG_LENGTH_GSS_TSIG = 0,
+ KNOT_TSIG_ALG_DIG_LENGTH_HMAC_MD5 = 16,
+ KNOT_TSIG_ALG_DIG_LENGTH_SHA1 = 20,
+ KNOT_TSIG_ALG_DIG_LENGTH_SHA224 = 28,
+ KNOT_TSIG_ALG_DIG_LENGTH_SHA256 = 32,
+ KNOT_TSIG_ALG_DIG_LENGTH_SHA384 = 48,
+ KNOT_TSIG_ALG_DIG_LENGTH_SHA512 = 64
+} knot_tsig_algorithm_digest_length_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 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 DNS operation code names.
+ */
+extern knot_lookup_table_t knot_opcode_names[];
+
+/*!
+ * \brief DNS reply code names.
+ */
+extern knot_lookup_table_t knot_rcode_names[];
+
+/*!
+ * \brief TSIG key algorithm names.
+ */
+extern knot_lookup_table_t knot_tsig_alg_names[];
+
+/*!
+ * \brief TSIG key algorithm names in a domain form.
+ */
+extern knot_lookup_table_t knot_tsig_alg_domain_names[];
+
+/*!
+ * \brief Returns length of TSIG digest for given algorithm.
+ *
+ * \param algorithm Algorithm code to be used.
+ *
+ * \retval Digest length for given algorithm.
+ */
+size_t knot_tsig_digest_length(const uint8_t algorithm);
+
+/*!
+ * \brief Returns length of DS digest for given algorithm.
+ *
+ * \param algorithm Algorithm code to be used.
+ *
+ * \retval Digest length for given algorithm.
+ */
+size_t knot_ds_digest_length(const uint8_t algorithm);
#endif /* _KNOT_CONSTS_H_ */