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
|
/* Copyright (C) 2022 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 <time.h>
#include "knot/conf/schema.h"
#include "knot/zone/contents.h"
typedef enum {
SEMCHECK_MANDATORY_ONLY = SEMCHECKS_OFF,
SEMCHECK_DNSSEC_AUTO = SEMCHECKS_ON,
SEMCHECK_MANDATORY_SOFT = SEMCHECKS_SOFT,
SEMCHECK_DNSSEC_OFF,
SEMCHECK_DNSSEC_ON,
} 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,
// DNSSEC checks.
SEM_ERR_RRSIG_UNVERIFIABLE,
SEM_ERR_NSEC_NONE,
SEM_ERR_NSEC_RDATA_BITMAP,
SEM_ERR_NSEC_RDATA_CHAIN,
SEM_ERR_NSEC3_INSECURE_DELEGATION_OPT,
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_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.
*/
typedef void (*sem_callback) (sem_handler_t *ctx, const zone_contents_t *zone,
const knot_dname_t *node, sem_error_t error, const char *data);
struct sem_handler {
sem_callback cb;
bool soft_check;
bool error; /* An error in the current check. */
bool fatal_error; /* The checks detected at least one error. */
bool warning; /* The checks detected at least one warning. */
};
/*!
* \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_EEMPTYZONE the zone is empty
* \retval KNOT_EINVAL another error
*/
int sem_checks_process(zone_contents_t *zone, semcheck_optional_t optional, sem_handler_t *handler,
time_t time);
|