xref: /netbsd/external/bsd/nsd/dist/rdata.h (revision 66a1527d)
1688d4060Schristos /*
2688d4060Schristos  * rdata.h -- RDATA conversion functions.
3688d4060Schristos  *
4688d4060Schristos  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
5688d4060Schristos  *
6688d4060Schristos  * See LICENSE for the license.
7688d4060Schristos  *
8688d4060Schristos  */
9688d4060Schristos 
10688d4060Schristos #ifndef _RDATA_H_
11688d4060Schristos #define _RDATA_H_
12688d4060Schristos 
13688d4060Schristos #include "dns.h"
14688d4060Schristos #include "namedb.h"
15688d4060Schristos 
16688d4060Schristos /* High bit of the APL length field is the negation bit.  */
17688d4060Schristos #define APL_NEGATION_MASK      0x80U
18688d4060Schristos #define APL_LENGTH_MASK	       (~APL_NEGATION_MASK)
19688d4060Schristos 
20688d4060Schristos extern lookup_table_type dns_certificate_types[];
21688d4060Schristos extern lookup_table_type dns_algorithms[];
22*66a1527dSchristos extern const char *svcparamkey_strs[];
23688d4060Schristos 
24688d4060Schristos int rdata_atom_to_string(buffer_type *output, rdata_zoneformat_type type,
25688d4060Schristos 			 rdata_atom_type rdata, rr_type *rr);
26688d4060Schristos 
27688d4060Schristos /*
28688d4060Schristos  * Split the wireformat RDATA into an array of rdata atoms. Domain
29688d4060Schristos  * names are inserted into the OWNERS table. The number of rdata atoms
30688d4060Schristos  * is returned and the array itself is allocated in REGION and stored
31688d4060Schristos  * in RDATAS.
32688d4060Schristos  *
33688d4060Schristos  * Returns -1 on failure.
34688d4060Schristos  */
35688d4060Schristos ssize_t rdata_wireformat_to_rdata_atoms(region_type *region,
36688d4060Schristos 					domain_table_type *owners,
37688d4060Schristos 					uint16_t rrtype,
38688d4060Schristos 					uint16_t rdata_size,
39688d4060Schristos 					buffer_type *packet,
40688d4060Schristos 					rdata_atom_type **rdatas);
41688d4060Schristos 
42688d4060Schristos /*
43688d4060Schristos  * Calculate the maximum size of the rdata assuming domain names are
44688d4060Schristos  * not compressed.
45688d4060Schristos  */
46688d4060Schristos size_t rdata_maximum_wireformat_size(rrtype_descriptor_type *descriptor,
47688d4060Schristos 				     size_t rdata_count,
48688d4060Schristos 				     rdata_atom_type *rdatas);
49688d4060Schristos 
50688d4060Schristos int rdata_atoms_to_unknown_string(buffer_type *out,
51688d4060Schristos 				  rrtype_descriptor_type *descriptor,
52688d4060Schristos 				  size_t rdata_count,
53688d4060Schristos 				  rdata_atom_type *rdatas);
54688d4060Schristos 
55688d4060Schristos /* print rdata to a text string (as for a zone file) returns 0
56688d4060Schristos   on a failure (bufpos is reset to original position).
57688d4060Schristos   returns 1 on success, bufpos is moved. */
58688d4060Schristos int print_rdata(buffer_type *output, rrtype_descriptor_type *descriptor,
59688d4060Schristos             rr_type *record);
60688d4060Schristos 
61688d4060Schristos #endif /* _DNS_H_ */
62