1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/* Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "knot/zone/node.h"
#include "knot/zone/contents.h"
typedef enum {
SEMCHECK_MANDATORY_ONLY,
SEMCHECK_NO_DNSSEC,
SEMCHECK_AUTO_DNSSEC,
SEMCHECK_DNSSEC,
} semcheck_optional_t;
/*!
*\brief Internal error constants.
*/
typedef enum {
// Mandatory checks.
SEM_ERR_SOA_NONE,
SEM_ERR_CNAME_EXTRA_RECORDS,
SEM_ERR_CNAME_MULTIPLE,
SEM_ERR_DNAME_CHILDREN,
SEM_ERR_DNAME_MULTIPLE,
SEM_ERR_DNAME_EXTRA_NS,
// Optional checks.
SEM_ERR_NS_APEX,
SEM_ERR_NS_GLUE,
SEM_ERR_RRSIG_RDATA_TYPE_COVERED,
SEM_ERR_RRSIG_RDATA_TTL,
SEM_ERR_RRSIG_RDATA_EXPIRATION,
SEM_ERR_RRSIG_RDATA_INCEPTION,
SEM_ERR_RRSIG_RDATA_LABELS,
SEM_ERR_RRSIG_RDATA_OWNER,
SEM_ERR_RRSIG_NO_RRSIG,
SEM_ERR_RRSIG_SIGNED,
SEM_ERR_RRSIG_TTL,
SEM_ERR_RRSIG_UNVERIFIABLE,
SEM_ERR_NSEC_NONE,
SEM_ERR_NSEC_RDATA_BITMAP,
SEM_ERR_NSEC_RDATA_MULTIPLE,
SEM_ERR_NSEC_RDATA_CHAIN,
SEM_ERR_NSEC3_NONE,
SEM_ERR_NSEC3_INSECURE_DELEGATION_OPT,
SEM_ERR_NSEC3_EXTRA_RECORD,
SEM_ERR_NSEC3_RDATA_TTL,
SEM_ERR_NSEC3_RDATA_CHAIN,
SEM_ERR_NSEC3_RDATA_BITMAP,
SEM_ERR_NSEC3_RDATA_FLAGS,
SEM_ERR_NSEC3_RDATA_SALT,
SEM_ERR_NSEC3_RDATA_ALG,
SEM_ERR_NSEC3_RDATA_ITERS,
SEM_ERR_NSEC3PARAM_RDATA_FLAGS,
SEM_ERR_NSEC3PARAM_RDATA_ALG,
SEM_ERR_DS_RDATA_ALG,
SEM_ERR_DS_RDATA_DIGLEN,
SEM_ERR_DNSKEY_NONE,
SEM_ERR_DNSKEY_INVALID,
SEM_ERR_DNSKEY_RDATA_PROTOCOL,
SEM_ERR_CDS_NONE,
SEM_ERR_CDS_NOT_MATCH,
SEM_ERR_CDNSKEY_NONE,
SEM_ERR_CDNSKEY_NO_DNSKEY,
SEM_ERR_CDNSKEY_NO_CDS,
SEM_ERR_CDNSKEY_INVALID_DELETE,
// General error!
SEM_ERR_UNKNOWN
} sem_error_t;
const char *sem_error_msg(sem_error_t code);
/*!
* \brief Structure for handling semantic errors.
*/
typedef struct sem_handler sem_handler_t;
/*!
* \brief Callback for handle error.
*
* Return KNOT_EOK to continue in semantic checks.
* Return other KNOT_E* to stop semantic check with error.
*/
typedef void (*sem_callback) (sem_handler_t *ctx, const zone_contents_t *zone,
const zone_node_t *node, sem_error_t error, const char *data);
struct sem_handler {
sem_callback cb;
bool fatal_error; /* Error(s) in the zonefile. */
bool warning; /* Warning(s) in the zonefile. */
bool error; /* An error in the current check. */
};
/*!
* \brief Check zone for semantic errors.
*
* Errors are logged in error handler.
*
* \param zone Zone to be searched / checked.
* \param optional To do also optional check.
* \param handler Semantic error handler.
* \param time Check zone at given time (rrsig expiration).
*
* \retval KNOT_EOK no error found
* \retval KNOT_ESEMCHECK found semantic error
* \retval KNOT_EINVAL or other error
*/
int sem_checks_process(zone_contents_t *zone, semcheck_optional_t optional, sem_handler_t *handler,
time_t time);
|