xref: /openbsd-src/usr.sbin/nsd/rdata.h (revision 3efee2e132f9af6db74577d714f3304be2b3af74)
162ac0c33Sjakob /*
262ac0c33Sjakob  * rdata.h -- RDATA conversion functions.
362ac0c33Sjakob  *
4d3fecca9Ssthen  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
562ac0c33Sjakob  *
662ac0c33Sjakob  * See LICENSE for the license.
762ac0c33Sjakob  *
862ac0c33Sjakob  */
962ac0c33Sjakob 
10*3efee2e1Sflorian #ifndef RDATA_H
11*3efee2e1Sflorian #define RDATA_H
1262ac0c33Sjakob 
1362ac0c33Sjakob #include "dns.h"
1462ac0c33Sjakob #include "namedb.h"
1562ac0c33Sjakob 
1662ac0c33Sjakob /* High bit of the APL length field is the negation bit.  */
1762ac0c33Sjakob #define APL_NEGATION_MASK      0x80U
1862ac0c33Sjakob #define APL_LENGTH_MASK	       (~APL_NEGATION_MASK)
1962ac0c33Sjakob 
2062ac0c33Sjakob extern lookup_table_type dns_certificate_types[];
2162ac0c33Sjakob extern lookup_table_type dns_algorithms[];
22063644e9Sflorian extern const char *svcparamkey_strs[];
2362ac0c33Sjakob 
2462ac0c33Sjakob int rdata_atom_to_string(buffer_type *output, rdata_zoneformat_type type,
2562ac0c33Sjakob 			 rdata_atom_type rdata, rr_type *rr);
2662ac0c33Sjakob 
2762ac0c33Sjakob /*
2862ac0c33Sjakob  * Split the wireformat RDATA into an array of rdata atoms. Domain
2962ac0c33Sjakob  * names are inserted into the OWNERS table. The number of rdata atoms
3062ac0c33Sjakob  * is returned and the array itself is allocated in REGION and stored
3162ac0c33Sjakob  * in RDATAS.
3262ac0c33Sjakob  *
3362ac0c33Sjakob  * Returns -1 on failure.
3462ac0c33Sjakob  */
3562ac0c33Sjakob ssize_t rdata_wireformat_to_rdata_atoms(region_type *region,
3662ac0c33Sjakob 					domain_table_type *owners,
3762ac0c33Sjakob 					uint16_t rrtype,
3862ac0c33Sjakob 					uint16_t rdata_size,
3962ac0c33Sjakob 					buffer_type *packet,
4062ac0c33Sjakob 					rdata_atom_type **rdatas);
4162ac0c33Sjakob 
4262ac0c33Sjakob /*
4362ac0c33Sjakob  * Calculate the maximum size of the rdata assuming domain names are
4462ac0c33Sjakob  * not compressed.
4562ac0c33Sjakob  */
4662ac0c33Sjakob size_t rdata_maximum_wireformat_size(rrtype_descriptor_type *descriptor,
4762ac0c33Sjakob 				     size_t rdata_count,
4862ac0c33Sjakob 				     rdata_atom_type *rdatas);
4962ac0c33Sjakob 
5062ac0c33Sjakob int rdata_atoms_to_unknown_string(buffer_type *out,
5162ac0c33Sjakob 				  rrtype_descriptor_type *descriptor,
5262ac0c33Sjakob 				  size_t rdata_count,
5362ac0c33Sjakob 				  rdata_atom_type *rdatas);
5462ac0c33Sjakob 
5562ac0c33Sjakob /* print rdata to a text string (as for a zone file) returns 0
5662ac0c33Sjakob   on a failure (bufpos is reset to original position).
5762ac0c33Sjakob   returns 1 on success, bufpos is moved. */
5862ac0c33Sjakob int print_rdata(buffer_type *output, rrtype_descriptor_type *descriptor,
5962ac0c33Sjakob             rr_type *record);
6062ac0c33Sjakob 
61*3efee2e1Sflorian #endif /* RDATA_H */
62