dnssectool.h revision 1.5 1 /* $NetBSD: dnssectool.h,v 1.5 2021/02/19 16:42:10 christos Exp $ */
2
3 /*
4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * See the COPYRIGHT file distributed with this work for additional
11 * information regarding copyright ownership.
12 */
13
14 #ifndef DNSSECTOOL_H
15 #define DNSSECTOOL_H 1
16
17 #include <inttypes.h>
18 #include <stdbool.h>
19
20 #include <isc/log.h>
21 #include <isc/platform.h>
22 #include <isc/stdtime.h>
23
24 #include <dns/rdatastruct.h>
25
26 #include <dst/dst.h>
27
28 /*! verbosity: set by -v and -q option in each program, defined in dnssectool.c
29 */
30 extern int verbose;
31 extern bool quiet;
32
33 /*! program name, statically initialized in each program */
34 extern const char *program;
35
36 /*!
37 * List of DS digest types used by dnssec-cds and dnssec-dsfromkey,
38 * defined in dnssectool.c. Filled in by add_dtype() from -a
39 * arguments, sorted (so that DS records are in a canonical order) and
40 * terminated by a zero. The size of the array is an arbitrary limit
41 * which should be greater than the number of known digest types.
42 */
43 extern uint8_t dtype[8];
44
45 typedef void(fatalcallback_t)(void);
46
47 #ifndef CPPCHECK
48 ISC_PLATFORM_NORETURN_PRE void
49 fatal(const char *format, ...)
50 ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
51 #else /* CPPCHECK */
52 #define fatal(...) exit(1)
53 #endif
54
55 void
56 setfatalcallback(fatalcallback_t *callback);
57
58 void
59 check_result(isc_result_t result, const char *message);
60
61 void
62 vbprintf(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
63
64 ISC_PLATFORM_NORETURN_PRE void
65 version(const char *program) ISC_PLATFORM_NORETURN_POST;
66
67 void
68 sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size);
69 #define SIG_FORMATSIZE \
70 (DNS_NAME_FORMATSIZE + DNS_SECALG_FORMATSIZE + sizeof("65535"))
71
72 void
73 setup_logging(isc_mem_t *mctx, isc_log_t **logp);
74
75 void
76 cleanup_logging(isc_log_t **logp);
77
78 dns_ttl_t
79 strtottl(const char *str);
80
81 dst_key_state_t
82 strtokeystate(const char *str);
83
84 isc_stdtime_t
85 strtotime(const char *str, int64_t now, int64_t base, bool *setp);
86
87 dns_rdataclass_t
88 strtoclass(const char *str);
89
90 unsigned int
91 strtodsdigest(const char *str);
92
93 void
94 add_dtype(unsigned int dt);
95
96 isc_result_t
97 try_dir(const char *dirname);
98
99 void
100 check_keyversion(dst_key_t *key, char *keystr);
101
102 void
103 set_keyversion(dst_key_t *key);
104
105 bool
106 key_collision(dst_key_t *key, dns_name_t *name, const char *dir,
107 isc_mem_t *mctx, bool *exact);
108
109 bool
110 isoptarg(const char *arg, char **argv, void (*usage)(void));
111
112 #ifdef _WIN32
113 void
114 InitSockets(void);
115 void
116 DestroySockets(void);
117 #endif /* ifdef _WIN32 */
118
119 #endif /* DNSSEC_DNSSECTOOL_H */
120