1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * SPDX-License-Identifier: MPL-2.0
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 DNS_SOA_H
15 #define DNS_SOA_H 1
16 
17 /*****
18 ***** Module Info
19 *****/
20 
21 /*! \file dns/soa.h
22  * \brief
23  * SOA utilities.
24  */
25 
26 /***
27  *** Imports
28  ***/
29 
30 #include <inttypes.h>
31 
32 #include <isc/lang.h>
33 #include <isc/types.h>
34 
35 #include <dns/types.h>
36 
37 ISC_LANG_BEGINDECLS
38 
39 #define DNS_SOA_BUFFERSIZE ((2 * DNS_NAME_MAXWIRE) + (4 * 5))
40 
41 isc_result_t
42 dns_soa_buildrdata(const dns_name_t *origin, const dns_name_t *contact,
43 		   dns_rdataclass_t rdclass, uint32_t serial, uint32_t refresh,
44 		   uint32_t retry, uint32_t expire, uint32_t minimum,
45 		   unsigned char *buffer, dns_rdata_t *rdata);
46 /*%<
47  * Build the rdata of an SOA record.
48  *
49  * Requires:
50  *\li   buffer  Points to a temporary buffer of at least
51  *              DNS_SOA_BUFFERSIZE bytes.
52  *\li   rdata   Points to an initialized dns_rdata_t.
53  *
54  * Ensures:
55  *  \li    *rdata       Contains a valid SOA rdata.  The 'data' member
56  *  			refers to 'buffer'.
57  */
58 
59 uint32_t
60 dns_soa_getserial(dns_rdata_t *rdata);
61 uint32_t
62 dns_soa_getrefresh(dns_rdata_t *rdata);
63 uint32_t
64 dns_soa_getretry(dns_rdata_t *rdata);
65 uint32_t
66 dns_soa_getexpire(dns_rdata_t *rdata);
67 uint32_t
68 dns_soa_getminimum(dns_rdata_t *rdata);
69 /*
70  * Extract an integer field from the rdata of a SOA record.
71  *
72  * Requires:
73  *	rdata refers to the rdata of a well-formed SOA record.
74  */
75 
76 void
77 dns_soa_setserial(uint32_t val, dns_rdata_t *rdata);
78 void
79 dns_soa_setrefresh(uint32_t val, dns_rdata_t *rdata);
80 void
81 dns_soa_setretry(uint32_t val, dns_rdata_t *rdata);
82 void
83 dns_soa_setexpire(uint32_t val, dns_rdata_t *rdata);
84 void
85 dns_soa_setminimum(uint32_t val, dns_rdata_t *rdata);
86 /*
87  * Change an integer field of a SOA record by modifying the
88  * rdata in-place.
89  *
90  * Requires:
91  *	rdata refers to the rdata of a well-formed SOA record.
92  */
93 
94 ISC_LANG_ENDDECLS
95 
96 #endif /* DNS_SOA_H */
97