Home | History | Annotate | Line # | Download | only in dist
      1      1.1  christos /*
      2      1.1  christos  * rdata.h -- RDATA conversion functions.
      3      1.1  christos  *
      4      1.1  christos  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
      5      1.1  christos  *
      6      1.1  christos  * See LICENSE for the license.
      7      1.1  christos  *
      8      1.1  christos  */
      9      1.1  christos 
     10  1.1.1.3  christos #ifndef RDATA_H
     11  1.1.1.3  christos #define RDATA_H
     12      1.1  christos 
     13      1.1  christos #include "dns.h"
     14      1.1  christos #include "namedb.h"
     15      1.1  christos 
     16      1.1  christos /* High bit of the APL length field is the negation bit.  */
     17      1.1  christos #define APL_NEGATION_MASK      0x80U
     18      1.1  christos #define APL_LENGTH_MASK	       (~APL_NEGATION_MASK)
     19      1.1  christos 
     20  1.1.1.4  christos /* High bit of the AMTRELAY Type byte in rdata[1] is the Discovery Optional
     21  1.1.1.4  christos  * flag, the D-bit. */
     22  1.1.1.4  christos #define AMTRELAY_DISCOVERY_OPTIONAL_MASK 0x80U
     23  1.1.1.4  christos #define AMTRELAY_TYPE_MASK		 0x7fU
     24  1.1.1.4  christos 
     25      1.1  christos extern lookup_table_type dns_certificate_types[];
     26      1.1  christos extern lookup_table_type dns_algorithms[];
     27      1.1  christos 
     28      1.1  christos /*
     29  1.1.1.4  christos  * Function signature for svcparam print. Input offset is at key uint16_t
     30  1.1.1.4  christos  * in rdata.
     31  1.1.1.4  christos  * @param output: the string is printed to the buffer.
     32  1.1.1.4  christos  * @param svcparamkey: the key that is printed.
     33  1.1.1.4  christos  * @param data: the data for the svcparam, from rdata.
     34  1.1.1.4  christos  * @param datalen: length of data in bytes.
     35  1.1.1.4  christos  * @return false on failure.
     36      1.1  christos  */
     37  1.1.1.4  christos typedef int(*nsd_print_svcparam_rdata_type)(
     38  1.1.1.4  christos 	struct buffer* output,
     39  1.1.1.4  christos 	uint16_t svcparamkey,
     40  1.1.1.4  christos 	const uint8_t* data,
     41  1.1.1.4  christos 	uint16_t datalen);
     42  1.1.1.4  christos 
     43  1.1.1.4  christos typedef struct nsd_svcparam_descriptor nsd_svcparam_descriptor_type;
     44  1.1.1.4  christos 
     45  1.1.1.4  christos /* Descriptor for svcparam rdata fields. With type, name and print func. */
     46  1.1.1.4  christos struct nsd_svcparam_descriptor {
     47  1.1.1.4  christos 	/* The svc param key */
     48  1.1.1.4  christos 	uint16_t key;
     49  1.1.1.4  christos 	/* The name of the key */
     50  1.1.1.4  christos 	const char *name;
     51  1.1.1.4  christos 	/* Print function that prints the key, from rdata. */
     52  1.1.1.4  christos 	nsd_print_svcparam_rdata_type print_rdata;
     53  1.1.1.4  christos };
     54  1.1.1.4  christos 
     55  1.1.1.4  christos int print_unknown_rdata_field(buffer_type *output,
     56  1.1.1.4  christos 	const nsd_type_descriptor_type *descriptor, const rr_type *rr);
     57  1.1.1.4  christos int print_unknown_rdata(buffer_type *output,
     58  1.1.1.4  christos 	const nsd_type_descriptor_type *descriptor, const rr_type *rr);
     59      1.1  christos 
     60      1.1  christos /* print rdata to a text string (as for a zone file) returns 0
     61      1.1  christos   on a failure (bufpos is reset to original position).
     62      1.1  christos   returns 1 on success, bufpos is moved. */
     63  1.1.1.4  christos int print_rdata(buffer_type *output, const nsd_type_descriptor_type *descriptor,
     64  1.1.1.4  christos 	const rr_type *rr);
     65  1.1.1.4  christos 
     66  1.1.1.4  christos /* Read rdata for an unknown RR type. */
     67  1.1.1.4  christos int32_t read_generic_rdata(struct domain_table *domains, uint16_t rdlength,
     68  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
     69  1.1.1.4  christos 
     70  1.1.1.4  christos /* Write rdata for an unknown RR type. */
     71  1.1.1.4  christos void write_generic_rdata(struct query *query, const struct rr *rr);
     72  1.1.1.4  christos 
     73  1.1.1.4  christos /* Print rdata for an unknown RR type. */
     74  1.1.1.4  christos int print_generic_rdata(struct buffer *output, const struct rr *rr);
     75  1.1.1.4  christos 
     76  1.1.1.4  christos /* Read rdata for an RR type with one compressed dname. */
     77  1.1.1.4  christos int32_t read_compressed_name_rdata(struct domain_table *domains,
     78  1.1.1.4  christos 	uint16_t rdlength, struct buffer *packet, struct rr **rr);
     79  1.1.1.4  christos 
     80  1.1.1.4  christos /* Write rdata for an RR type with one compressed dname. */
     81  1.1.1.4  christos void write_compressed_name_rdata(struct query *query, const struct rr *rr);
     82  1.1.1.4  christos 
     83  1.1.1.4  christos /* Print rdata for an RR type with one compressed or uncompressed dname.
     84  1.1.1.4  christos  * But not a dname type literal. */
     85  1.1.1.4  christos int print_name_rdata(struct buffer *output, const struct rr *rr);
     86  1.1.1.4  christos 
     87  1.1.1.4  christos /* Read rdata for an RR type with one uncompressed dname. */
     88  1.1.1.4  christos int32_t read_uncompressed_name_rdata(struct domain_table *domains,
     89  1.1.1.4  christos 	uint16_t rdlength, struct buffer *packet, struct rr **rr);
     90  1.1.1.4  christos 
     91  1.1.1.4  christos /* Write rdata for an RR type with one uncompressed dname. */
     92  1.1.1.4  christos void write_uncompressed_name_rdata(struct query *query, const struct rr *rr);
     93  1.1.1.4  christos 
     94  1.1.1.4  christos /* Read rdata for type A. */
     95  1.1.1.4  christos int32_t read_a_rdata(struct domain_table *domains, uint16_t rdlength,
     96  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
     97  1.1.1.4  christos 
     98  1.1.1.4  christos /* Print rdata for type A. */
     99  1.1.1.4  christos int print_a_rdata(struct buffer *output, const struct rr *rr);
    100  1.1.1.4  christos 
    101  1.1.1.4  christos /* Read rdata for type SOA. */
    102  1.1.1.4  christos int32_t read_soa_rdata(struct domain_table *domains, uint16_t rdlength,
    103  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    104  1.1.1.4  christos 
    105  1.1.1.4  christos /* Write rdata for type SOA. */
    106  1.1.1.4  christos void write_soa_rdata(struct query *query, const struct rr *rr);
    107  1.1.1.4  christos 
    108  1.1.1.4  christos /* Print rdata for type SOA. */
    109  1.1.1.4  christos int print_soa_rdata(struct buffer *output, const struct rr *rr);
    110  1.1.1.4  christos 
    111  1.1.1.4  christos /* Print rdata for type SOA, on two lines, with parentheses. */
    112  1.1.1.4  christos int print_soa_rdata_twoline(struct buffer *output, const struct rr *rr);
    113  1.1.1.4  christos 
    114  1.1.1.4  christos /* Read rdata for type WKS. */
    115  1.1.1.4  christos int32_t read_wks_rdata(struct domain_table *domains, uint16_t rdlength,
    116  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    117  1.1.1.4  christos 
    118  1.1.1.4  christos /* Print rdata for type WKS. */
    119  1.1.1.4  christos int print_wks_rdata(struct buffer *output, const struct rr *rr);
    120  1.1.1.4  christos 
    121  1.1.1.4  christos /* Read rdata for type HINFO. */
    122  1.1.1.4  christos int32_t read_hinfo_rdata(struct domain_table *domains, uint16_t rdlength,
    123  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    124  1.1.1.4  christos 
    125  1.1.1.4  christos /* Print rdata for type HINFO. */
    126  1.1.1.4  christos int print_hinfo_rdata(struct buffer *output, const struct rr *rr);
    127  1.1.1.4  christos 
    128  1.1.1.4  christos /* Read rdata for type MINFO. */
    129  1.1.1.4  christos int32_t read_minfo_rdata(struct domain_table *domains, uint16_t rdlength,
    130  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    131  1.1.1.4  christos 
    132  1.1.1.4  christos /* Write rdata for type MINFO. */
    133  1.1.1.4  christos void write_minfo_rdata(struct query *query, const struct rr *rr);
    134  1.1.1.4  christos 
    135  1.1.1.4  christos /* Print rdata for type MINFO. */
    136  1.1.1.4  christos int print_minfo_rdata(struct buffer *output, const struct rr *rr);
    137  1.1.1.4  christos 
    138  1.1.1.4  christos /* Read rdata for type MX. */
    139  1.1.1.4  christos int32_t read_mx_rdata(struct domain_table *domains, uint16_t rdlength,
    140  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    141  1.1.1.4  christos 
    142  1.1.1.4  christos /* Write rdata for type MX. */
    143  1.1.1.4  christos void write_mx_rdata(struct query *query, const struct rr *rr);
    144  1.1.1.4  christos 
    145  1.1.1.4  christos /* Print rdata for type MX. */
    146  1.1.1.4  christos int print_mx_rdata(struct buffer *output, const struct rr *rr);
    147  1.1.1.4  christos 
    148  1.1.1.4  christos /* Read rdata for type TXT. */
    149  1.1.1.4  christos int32_t read_txt_rdata(struct domain_table *domains, uint16_t rdlength,
    150  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    151  1.1.1.4  christos 
    152  1.1.1.4  christos /* Print rdata for type TXT. */
    153  1.1.1.4  christos int print_txt_rdata(struct buffer *output, const struct rr *rr);
    154  1.1.1.4  christos 
    155  1.1.1.4  christos /* Read rdata for type RP. */
    156  1.1.1.4  christos int32_t read_rp_rdata(struct domain_table *domains, uint16_t rdlength,
    157  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    158  1.1.1.4  christos 
    159  1.1.1.4  christos /* Write rdata for type RP. */
    160  1.1.1.4  christos void write_rp_rdata(struct query *query, const struct rr *rr);
    161  1.1.1.4  christos 
    162  1.1.1.4  christos /* Print rdata for type RP. */
    163  1.1.1.4  christos int print_rp_rdata(struct buffer *output, const struct rr *rr);
    164  1.1.1.4  christos 
    165  1.1.1.4  christos /* Read rdata for type AFSDB. */
    166  1.1.1.4  christos int32_t read_afsdb_rdata(struct domain_table *domains, uint16_t rdlength,
    167  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    168  1.1.1.4  christos 
    169  1.1.1.4  christos /* Write rdata for type AFSDB. */
    170  1.1.1.4  christos void write_afsdb_rdata(struct query *query, const struct rr *rr);
    171  1.1.1.4  christos 
    172  1.1.1.4  christos /* Print rdata for type AFSDB. */
    173  1.1.1.4  christos int print_afsdb_rdata(struct buffer *output, const struct rr *rr);
    174  1.1.1.4  christos 
    175  1.1.1.4  christos /* Read rdata for type X25. */
    176  1.1.1.4  christos int32_t read_x25_rdata(struct domain_table *domains, uint16_t rdlength,
    177  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    178  1.1.1.4  christos 
    179  1.1.1.4  christos /* Print rdata for type X25. */
    180  1.1.1.4  christos int print_x25_rdata(struct buffer *output, const struct rr *rr);
    181  1.1.1.4  christos 
    182  1.1.1.4  christos /* Read rdata for type ISDN. */
    183  1.1.1.4  christos int32_t read_isdn_rdata(struct domain_table *domains, uint16_t rdlength,
    184  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    185  1.1.1.4  christos 
    186  1.1.1.4  christos /* Print rdata for type ISDN. */
    187  1.1.1.4  christos int print_isdn_rdata(struct buffer *output, const struct rr *rr);
    188  1.1.1.4  christos 
    189  1.1.1.4  christos /* Read rdata for type RT. */
    190  1.1.1.4  christos int32_t read_rt_rdata(struct domain_table *domains, uint16_t rdlength,
    191  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    192  1.1.1.4  christos 
    193  1.1.1.4  christos /* Write rdata for type RT. */
    194  1.1.1.4  christos void write_rt_rdata(struct query *query, const struct rr *rr);
    195  1.1.1.4  christos 
    196  1.1.1.4  christos /* Print rdata for type NSAP. */
    197  1.1.1.4  christos int print_nsap_rdata(struct buffer *output, const struct rr *rr);
    198  1.1.1.4  christos 
    199  1.1.1.4  christos /* Print rdata for type NSAP-PTR. */
    200  1.1.1.4  christos int print_nsap_ptr_rdata(struct buffer *output, const struct rr *rr);
    201  1.1.1.4  christos 
    202  1.1.1.4  christos /* Print rdata for type KEY. */
    203  1.1.1.4  christos int print_key_rdata(struct buffer *output, const struct rr *rr);
    204  1.1.1.4  christos 
    205  1.1.1.4  christos /* Read rdata for type PX. */
    206  1.1.1.4  christos int32_t read_px_rdata(struct domain_table *domains, uint16_t rdlength,
    207  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    208  1.1.1.4  christos 
    209  1.1.1.4  christos /* Write rdata for type PX. */
    210  1.1.1.4  christos void write_px_rdata(struct query *query, const struct rr *rr);
    211  1.1.1.4  christos 
    212  1.1.1.4  christos /* Print rdata for type PX. */
    213  1.1.1.4  christos int print_px_rdata(struct buffer *output, const struct rr *rr);
    214  1.1.1.4  christos 
    215  1.1.1.4  christos /* Print rdata for type GPOS. */
    216  1.1.1.4  christos int print_gpos_rdata(struct buffer *output, const struct rr *rr);
    217  1.1.1.4  christos 
    218  1.1.1.4  christos /* Read rdata for type AAAA. */
    219  1.1.1.4  christos int32_t read_aaaa_rdata(struct domain_table *domains, uint16_t rdlength,
    220  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    221  1.1.1.4  christos 
    222  1.1.1.4  christos /* Print rdata for type AAAA. */
    223  1.1.1.4  christos int print_aaaa_rdata(struct buffer *output, const struct rr *rr);
    224  1.1.1.4  christos 
    225  1.1.1.4  christos /* Print rdata for type LOC. */
    226  1.1.1.4  christos int32_t read_loc_rdata(struct domain_table *domains, uint16_t rdlength,
    227  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    228  1.1.1.4  christos 
    229  1.1.1.4  christos /* Print rdata for type LOC. */
    230  1.1.1.4  christos int print_loc_rdata(struct buffer *output, const struct rr *rr);
    231  1.1.1.4  christos 
    232  1.1.1.4  christos /* Read rdata for type NXT. */
    233  1.1.1.4  christos int32_t read_nxt_rdata(struct domain_table *domains, uint16_t rdlength,
    234  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    235  1.1.1.4  christos 
    236  1.1.1.4  christos /* Write rdata for type NXT. */
    237  1.1.1.4  christos void write_nxt_rdata(struct query *query, const struct rr *rr);
    238  1.1.1.4  christos 
    239  1.1.1.4  christos /* Print rdata for type NXT. */
    240  1.1.1.4  christos int print_nxt_rdata(struct buffer *output, const struct rr *rr);
    241  1.1.1.4  christos 
    242  1.1.1.4  christos /* Print rdata for type EID. */
    243  1.1.1.4  christos int print_eid_rdata(struct buffer *output, const struct rr *rr);
    244  1.1.1.4  christos 
    245  1.1.1.4  christos /* Print rdata for type NIMLOC. */
    246  1.1.1.4  christos int print_nimloc_rdata(struct buffer *output, const struct rr *rr);
    247  1.1.1.4  christos 
    248  1.1.1.4  christos /* Read rdata for type SRV. */
    249  1.1.1.4  christos int32_t read_srv_rdata(struct domain_table *domains, uint16_t rdlength,
    250  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    251  1.1.1.4  christos 
    252  1.1.1.4  christos /* Write rdata for type SRV. */
    253  1.1.1.4  christos void write_srv_rdata(struct query *query, const struct rr *rr);
    254  1.1.1.4  christos 
    255  1.1.1.4  christos /* Print rdata for type SRV. */
    256  1.1.1.4  christos int print_srv_rdata(struct buffer *output, const struct rr *rr);
    257  1.1.1.4  christos 
    258  1.1.1.4  christos /* Print rdata for type ATMA. */
    259  1.1.1.4  christos int print_atma_rdata(struct buffer *output, const struct rr *rr);
    260  1.1.1.4  christos 
    261  1.1.1.4  christos /* Read rdata for type NAPTR. */
    262  1.1.1.4  christos int32_t read_naptr_rdata(struct domain_table *domains, uint16_t rdlength,
    263  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    264  1.1.1.4  christos 
    265  1.1.1.4  christos /* Write rdata for type NAPTR. */
    266  1.1.1.4  christos void write_naptr_rdata(struct query *query, const struct rr *rr);
    267  1.1.1.4  christos 
    268  1.1.1.4  christos /* Print rdata for type NAPTR. */
    269  1.1.1.4  christos int print_naptr_rdata(struct buffer *output, const struct rr *rr);
    270  1.1.1.4  christos 
    271  1.1.1.4  christos /* Read rdata for type KX. */
    272  1.1.1.4  christos int32_t read_kx_rdata(struct domain_table *domains, uint16_t rdlength,
    273  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    274  1.1.1.4  christos 
    275  1.1.1.4  christos /* Write rdata for type KX. */
    276  1.1.1.4  christos void write_kx_rdata(struct query *query, const struct rr *rr);
    277  1.1.1.4  christos 
    278  1.1.1.4  christos /* Read rdata for type CERT. */
    279  1.1.1.4  christos int32_t read_cert_rdata(struct domain_table *domains, uint16_t rdlength,
    280  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    281  1.1.1.4  christos 
    282  1.1.1.4  christos /* Print rdata for type CERT. */
    283  1.1.1.4  christos int print_cert_rdata(struct buffer *output, const struct rr *rr);
    284  1.1.1.4  christos 
    285  1.1.1.4  christos /* Print rdata for type SINK. */
    286  1.1.1.4  christos int print_sink_rdata(struct buffer *output, const struct rr *rr);
    287  1.1.1.4  christos 
    288  1.1.1.4  christos /* Read rdata for type APL. */
    289  1.1.1.4  christos int32_t read_apl_rdata(struct domain_table *domains, uint16_t rdlength,
    290  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    291  1.1.1.4  christos 
    292  1.1.1.4  christos /* Print rdata for type APL. */
    293  1.1.1.4  christos int print_apl_rdata(struct buffer *output, const struct rr *rr);
    294  1.1.1.4  christos 
    295  1.1.1.4  christos /* Read rdata for type DS. */
    296  1.1.1.4  christos int32_t read_ds_rdata(struct domain_table *domains, uint16_t rdlength,
    297  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    298  1.1.1.4  christos 
    299  1.1.1.4  christos /* Print rdata for type DS. */
    300  1.1.1.4  christos int print_ds_rdata(struct buffer *output, const struct rr *rr);
    301  1.1.1.4  christos 
    302  1.1.1.4  christos /* Read rdata for type SSHFP. */
    303  1.1.1.4  christos int32_t read_sshfp_rdata(struct domain_table *domains, uint16_t rdlength,
    304  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    305  1.1.1.4  christos 
    306  1.1.1.4  christos /* Print rdata for type SSHFP. */
    307  1.1.1.4  christos int print_sshfp_rdata(struct buffer *output, const struct rr *rr);
    308  1.1.1.4  christos 
    309  1.1.1.4  christos /* Read rdata for type IPSECKEY. */
    310  1.1.1.4  christos int32_t read_ipseckey_rdata(struct domain_table *domains, uint16_t rdlength,
    311  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    312  1.1.1.4  christos 
    313  1.1.1.4  christos /* Print rdata for type IPSECKEY. */
    314  1.1.1.4  christos int print_ipseckey_rdata(struct buffer *output, const struct rr *rr);
    315  1.1.1.4  christos 
    316  1.1.1.4  christos /* Determine length of IPSECKEY gateway field. */
    317  1.1.1.4  christos int32_t ipseckey_gateway_length(uint16_t rdlength, const uint8_t *rdata,
    318  1.1.1.4  christos 	uint16_t offset, struct domain** domain);
    319  1.1.1.4  christos 
    320  1.1.1.4  christos /* Read rdata for type RRSIG. */
    321  1.1.1.4  christos int32_t read_rrsig_rdata(struct domain_table *domains, uint16_t rdlength,
    322  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    323  1.1.1.4  christos 
    324  1.1.1.4  christos /* Print rdata for type RRSIG. */
    325  1.1.1.4  christos int print_rrsig_rdata(struct buffer *output, const struct rr *rr);
    326  1.1.1.4  christos 
    327  1.1.1.4  christos /* Read rdata for type NSEC. */
    328  1.1.1.4  christos int32_t read_nsec_rdata(struct domain_table *domains, uint16_t rdlength,
    329  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    330  1.1.1.4  christos 
    331  1.1.1.4  christos /* Print rdata for type NSEC. */
    332  1.1.1.4  christos int print_nsec_rdata(struct buffer *output, const struct rr *rr);
    333  1.1.1.4  christos 
    334  1.1.1.4  christos /* Read rdata for type DNSKEY. */
    335  1.1.1.4  christos int32_t read_dnskey_rdata(struct domain_table *domains, uint16_t rdlength,
    336  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    337  1.1.1.4  christos 
    338  1.1.1.4  christos /* Print rdata for type DNSKEY. */
    339  1.1.1.4  christos int print_dnskey_rdata(struct buffer *output, const struct rr *rr);
    340  1.1.1.4  christos 
    341  1.1.1.4  christos /* Read rdata for type DHCID. */
    342  1.1.1.4  christos int32_t read_dhcid_rdata(struct domain_table *domains, uint16_t rdlength,
    343  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    344  1.1.1.4  christos 
    345  1.1.1.4  christos /* Print rdata for type DHCID. */
    346  1.1.1.4  christos int print_dhcid_rdata(struct buffer *output, const struct rr *rr);
    347  1.1.1.4  christos 
    348  1.1.1.4  christos /* Read rdata for type NSEC3. */
    349  1.1.1.4  christos int32_t read_nsec3_rdata(struct domain_table *domains, uint16_t rdlength,
    350  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    351  1.1.1.4  christos 
    352  1.1.1.4  christos /* Print rdata for type NSEC3. */
    353  1.1.1.4  christos int print_nsec3_rdata(struct buffer *output, const struct rr *rr);
    354  1.1.1.4  christos 
    355  1.1.1.4  christos /* Read rdata for type NSEC3PARAM. */
    356  1.1.1.4  christos int32_t read_nsec3param_rdata(struct domain_table *domains, uint16_t rdlength,
    357  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    358  1.1.1.4  christos 
    359  1.1.1.4  christos /* Print rdata for type NSEC3PARAM. */
    360  1.1.1.4  christos int print_nsec3param_rdata(struct buffer *output, const struct rr *rr);
    361  1.1.1.4  christos 
    362  1.1.1.4  christos /* Read rdata for type TLSA. */
    363  1.1.1.4  christos int32_t read_tlsa_rdata(struct domain_table *domains, uint16_t rdlength,
    364  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    365  1.1.1.4  christos 
    366  1.1.1.4  christos /* Print rdata for type TLSA. */
    367  1.1.1.4  christos int print_tlsa_rdata(struct buffer *output, const struct rr *rr);
    368  1.1.1.4  christos 
    369  1.1.1.4  christos /* Read rdata for type HIP. */
    370  1.1.1.4  christos int32_t read_hip_rdata(struct domain_table *domains, uint16_t rdlength,
    371  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    372  1.1.1.4  christos 
    373  1.1.1.4  christos /* Print rdata for type HIP. */
    374  1.1.1.4  christos int print_hip_rdata(struct buffer *output, const struct rr *rr);
    375  1.1.1.4  christos 
    376  1.1.1.4  christos /* Read rdata for type RKEY. */
    377  1.1.1.4  christos int32_t read_rkey_rdata(struct domain_table *domains, uint16_t rdlength,
    378  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    379  1.1.1.4  christos 
    380  1.1.1.4  christos /* Print rdata for type RKEY. */
    381  1.1.1.4  christos int print_rkey_rdata(struct buffer *output, const struct rr *rr);
    382  1.1.1.4  christos 
    383  1.1.1.4  christos /* Read rdata for type TALINK. */
    384  1.1.1.4  christos int32_t read_talink_rdata(struct domain_table *domains, uint16_t rdlength,
    385  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    386  1.1.1.4  christos 
    387  1.1.1.4  christos /* Print rdata for type TALINK. */
    388  1.1.1.4  christos int print_talink_rdata(struct buffer *output, const struct rr *rr);
    389  1.1.1.4  christos 
    390  1.1.1.4  christos /* Print rdata for type OPENPGPKEY. */
    391  1.1.1.4  christos int print_openpgpkey_rdata(struct buffer *output, const struct rr *rr);
    392  1.1.1.4  christos 
    393  1.1.1.4  christos /* Read rdata for type CSYNC. */
    394  1.1.1.4  christos int32_t read_csync_rdata(struct domain_table *domains, uint16_t rdlength,
    395  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    396  1.1.1.4  christos 
    397  1.1.1.4  christos /* Print rdata for type CSYNC. */
    398  1.1.1.4  christos int print_csync_rdata(struct buffer *output, const struct rr *rr);
    399  1.1.1.4  christos 
    400  1.1.1.4  christos /* Read rdata for type ZONEMD. */
    401  1.1.1.4  christos int32_t read_zonemd_rdata(struct domain_table *domains, uint16_t rdlength,
    402  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    403  1.1.1.4  christos 
    404  1.1.1.4  christos /* Print rdata for type ZONEMD. */
    405  1.1.1.4  christos int print_zonemd_rdata(struct buffer *output, const struct rr *rr);
    406  1.1.1.4  christos 
    407  1.1.1.4  christos /* Read rdata for type SVCB. */
    408  1.1.1.4  christos int32_t read_svcb_rdata(struct domain_table *domains, uint16_t rdlength,
    409  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    410  1.1.1.4  christos 
    411  1.1.1.4  christos /* Write rdata for type SVCB. */
    412  1.1.1.4  christos void write_svcb_rdata(struct query *query, const struct rr *rr);
    413  1.1.1.4  christos 
    414  1.1.1.4  christos /* Print rdata for type SVCB. */
    415  1.1.1.4  christos int print_svcb_rdata(struct buffer *output, const struct rr *rr);
    416  1.1.1.4  christos 
    417  1.1.1.4  christos /* Read rdata for type DSYNC. */
    418  1.1.1.4  christos int32_t read_dsync_rdata(struct domain_table *domains, uint16_t rdlength,
    419  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    420  1.1.1.4  christos 
    421  1.1.1.4  christos /* Print rdata for type DSYNC. */
    422  1.1.1.4  christos int print_dsync_rdata(struct buffer *output, const struct rr *rr);
    423  1.1.1.4  christos 
    424  1.1.1.4  christos /* Read rdata for type NID. */
    425  1.1.1.4  christos int32_t read_nid_rdata(struct domain_table *domains, uint16_t rdlength,
    426  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    427  1.1.1.4  christos 
    428  1.1.1.4  christos /* Print rdata for type NID. */
    429  1.1.1.4  christos int print_nid_rdata(struct buffer *output, const struct rr *rr);
    430  1.1.1.4  christos 
    431  1.1.1.4  christos /* Read rdata for type L32. */
    432  1.1.1.4  christos int32_t read_l32_rdata(struct domain_table *domains, uint16_t rdlength,
    433  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    434  1.1.1.4  christos 
    435  1.1.1.4  christos /* Print rdata for type L32. */
    436  1.1.1.4  christos int print_l32_rdata(struct buffer *output, const struct rr *rr);
    437  1.1.1.4  christos 
    438  1.1.1.4  christos /* Read rdata for type L64. */
    439  1.1.1.4  christos int32_t read_l64_rdata(struct domain_table *domains, uint16_t rdlength,
    440  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    441  1.1.1.4  christos 
    442  1.1.1.4  christos /* Print rdata for type L64. */
    443  1.1.1.4  christos int print_l64_rdata(struct buffer *output, const struct rr *rr);
    444  1.1.1.4  christos 
    445  1.1.1.4  christos /* Read rdata for type LP. */
    446  1.1.1.4  christos int32_t read_lp_rdata(struct domain_table *domains, uint16_t rdlength,
    447  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    448  1.1.1.4  christos 
    449  1.1.1.4  christos /* Write rdata for type LP. */
    450  1.1.1.4  christos void write_lp_rdata(struct query *query, const struct rr *rr);
    451  1.1.1.4  christos 
    452  1.1.1.4  christos /* Print rdata for type LP. */
    453  1.1.1.4  christos int print_lp_rdata(struct buffer *output, const struct rr *rr);
    454  1.1.1.4  christos 
    455  1.1.1.4  christos /* Read rdata for type EUI48. */
    456  1.1.1.4  christos int32_t read_eui48_rdata(struct domain_table *domains, uint16_t rdlength,
    457  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    458  1.1.1.4  christos 
    459  1.1.1.4  christos /* Print rdata for type EUI48. */
    460  1.1.1.4  christos int print_eui48_rdata(struct buffer *output, const struct rr *rr);
    461  1.1.1.4  christos 
    462  1.1.1.4  christos /* Read rdata for type EUI64. */
    463  1.1.1.4  christos int32_t read_eui64_rdata(struct domain_table *domains, uint16_t rdlength,
    464  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    465  1.1.1.4  christos 
    466  1.1.1.4  christos /* Print rdata for type EUI64. */
    467  1.1.1.4  christos int print_eui64_rdata(struct buffer *output, const struct rr *rr);
    468  1.1.1.4  christos 
    469  1.1.1.4  christos /* Read rdata for type URI. */
    470  1.1.1.4  christos int32_t read_uri_rdata(struct domain_table *domains, uint16_t rdlength,
    471  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    472  1.1.1.4  christos 
    473  1.1.1.4  christos /* Print rdata for type URI. */
    474  1.1.1.4  christos int print_uri_rdata(struct buffer *output, const struct rr *rr);
    475  1.1.1.4  christos 
    476  1.1.1.4  christos /* Print rdata for type resinfo. */
    477  1.1.1.4  christos int print_resinfo_rdata(struct buffer *output, const struct rr *rr);
    478  1.1.1.4  christos 
    479  1.1.1.4  christos /* Read rdata for type CAA. */
    480  1.1.1.4  christos int32_t read_caa_rdata(struct domain_table *domains, uint16_t rdlength,
    481  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    482  1.1.1.4  christos 
    483  1.1.1.4  christos /* Print rdata for type CAA. */
    484  1.1.1.4  christos int print_caa_rdata(struct buffer *output, const struct rr *rr);
    485  1.1.1.4  christos 
    486  1.1.1.4  christos /* Print rdata for type DOA. */
    487  1.1.1.4  christos int print_doa_rdata(struct buffer *output, const struct rr *rr);
    488  1.1.1.4  christos 
    489  1.1.1.4  christos /* Read rdata for type AMTRELAY. */
    490  1.1.1.4  christos int32_t read_amtrelay_rdata(struct domain_table *domains, uint16_t rdlength,
    491  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    492  1.1.1.4  christos 
    493  1.1.1.4  christos /* Print rdata for type AMTRELAY. */
    494  1.1.1.4  christos int print_amtrelay_rdata(struct buffer *output, const struct rr *rr);
    495  1.1.1.4  christos 
    496  1.1.1.4  christos /* Determine length of AMTRELAY relay field. */
    497  1.1.1.4  christos int32_t amtrelay_relay_length(uint16_t rdlength, const uint8_t *rdata,
    498  1.1.1.4  christos 	uint16_t offset, struct domain** domain);
    499  1.1.1.4  christos 
    500  1.1.1.4  christos /* Print rdata for type IPN. */
    501  1.1.1.4  christos int print_ipn_rdata(struct buffer *output, const struct rr *rr);
    502  1.1.1.4  christos 
    503  1.1.1.4  christos /* Read rdata for type DLV. */
    504  1.1.1.4  christos int32_t read_dlv_rdata(struct domain_table *domains, uint16_t rdlength,
    505  1.1.1.4  christos 	struct buffer *packet, struct rr **rr);
    506  1.1.1.4  christos 
    507  1.1.1.4  christos /* Print rdata for type DLV. */
    508  1.1.1.4  christos int print_dlv_rdata(struct buffer *output, const struct rr *rr);
    509  1.1.1.4  christos 
    510  1.1.1.4  christos /*
    511  1.1.1.4  christos  * Look up the uncompressed wireformat length of the rdata.
    512  1.1.1.4  christos  * The pointer references in it are taking up the length of their uncompressed
    513  1.1.1.4  christos  * domain names. The length is without the RR's rdatalength uint16 preceding.
    514  1.1.1.4  christos  * @param rr: the rr, the RR type and rdata are used.
    515  1.1.1.4  christos  * @result -1 on failure, otherwise length in bytes.
    516  1.1.1.4  christos  */
    517  1.1.1.4  christos int32_t rr_calculate_uncompressed_rdata_length(const rr_type* rr);
    518  1.1.1.4  christos 
    519  1.1.1.4  christos /*
    520  1.1.1.4  christos  * Write uncompressed wireformat rdata to buffer. The pointer references
    521  1.1.1.4  christos  * and domains are uncompressed wireformat domain names. The uint16 rdlength
    522  1.1.1.4  christos  * is not written before it.
    523  1.1.1.4  christos  * @param rr: the rr, with RR type and rdata.
    524  1.1.1.4  christos  * @param buf: destination.
    525  1.1.1.4  christos  * @param len: length of buffer.
    526  1.1.1.4  christos  */
    527  1.1.1.4  christos void rr_write_uncompressed_rdata(const rr_type* rr, uint8_t* buf, size_t len);
    528  1.1.1.4  christos 
    529  1.1.1.4  christos /*
    530  1.1.1.4  christos  * Look up the field length. The field length is returned as a length
    531  1.1.1.4  christos  * in the rdata that is stored. For a reference, the pointer is returned too.
    532  1.1.1.4  christos  * Before calling it check if the field is_optional, and rdlength is
    533  1.1.1.4  christos  * reached by offset, then there are no more rdata fields.
    534  1.1.1.4  christos  * Also if the index has reached the rdata field length count, fields end.
    535  1.1.1.4  christos  * It checks if the field fits in the rdata buffer, failure if not.
    536  1.1.1.4  christos  * Then check for domain ptr or not, and handle the field at rr->rdata+offset.
    537  1.1.1.4  christos  * Continue the loop by incrementing offset with field_len, and index++.
    538  1.1.1.4  christos  *
    539  1.1.1.4  christos  * @param descriptor: type descriptor.
    540  1.1.1.4  christos  * @param index: field index.
    541  1.1.1.4  christos  * @param rr: the rr with the rdata.
    542  1.1.1.4  christos  * @param offset: current position in the rdata.
    543  1.1.1.4  christos  *	It is not updated, because the caller has to do that.
    544  1.1.1.4  christos  * @param field_len: the field length is returned.
    545  1.1.1.4  christos  * @param domain: the pointer is returned when the field is a reference.
    546  1.1.1.4  christos  * @return false on failure, when the rdata stored is badly formatted, like
    547  1.1.1.4  christos  *	the rdata buffer is too short.
    548  1.1.1.4  christos  */
    549  1.1.1.4  christos int lookup_rdata_field_entry(const nsd_type_descriptor_type* descriptor,
    550  1.1.1.4  christos 	size_t index, const rr_type* rr, uint16_t offset, uint16_t* field_len,
    551  1.1.1.4  christos 	struct domain** domain);
    552  1.1.1.4  christos 
    553  1.1.1.4  christos /* Look up the field length. Same as lookup_rdata_field_entry, but the rdata
    554  1.1.1.4  christos  * is uncompressed wireformat. The length returned skips the field in the
    555  1.1.1.4  christos  * uncompressed wireformat. */
    556  1.1.1.4  christos int lookup_rdata_field_entry_uncompressed_wire(
    557  1.1.1.4  christos 	const nsd_type_descriptor_type* descriptor, size_t index,
    558  1.1.1.4  christos 	const uint8_t* rdata, uint16_t rdlength, uint16_t offset,
    559  1.1.1.4  christos 	uint16_t* field_len, struct domain** domain);
    560  1.1.1.4  christos 
    561  1.1.1.4  christos /*
    562  1.1.1.4  christos  * Compare rdata for equality. This is easier than the sorted compare,
    563  1.1.1.4  christos  * it treats field types as a difference too, so a reference instead of
    564  1.1.1.4  christos  * a wireformat field makes for a different RR.
    565  1.1.1.4  christos  * The RRs have to be the same type already.
    566  1.1.1.4  christos  * It iterates over the RR type fields. The RRs and the rdatas are the
    567  1.1.1.4  christos  * namedb format, that is with references stored as pointers.
    568  1.1.1.4  christos  * @param rr1: RR to compare rdata 1. The rdata can contain pointers.
    569  1.1.1.4  christos  * @param rr2: RR to compare rdata 2. The rdata can contain pointers.
    570  1.1.1.4  christos  * @return true if rdata is equal.
    571  1.1.1.4  christos  */
    572  1.1.1.4  christos int equal_rr_rdata(const nsd_type_descriptor_type *descriptor,
    573  1.1.1.4  christos 	const struct rr *rr1, const struct rr *rr2);
    574  1.1.1.4  christos 
    575  1.1.1.4  christos /*
    576  1.1.1.4  christos  * Compare rdata for equality. Same as equal_rr_rdata, but the second
    577  1.1.1.4  christos  * rdata is passed as uncompressed wireformat, the first has the in-memory
    578  1.1.1.4  christos  * rdata format.
    579  1.1.1.4  christos  */
    580  1.1.1.4  christos int equal_rr_rdata_uncompressed_wire(const nsd_type_descriptor_type *descriptor,
    581  1.1.1.4  christos 	const struct rr *rr1, const uint8_t* rr2_rdata, uint16_t rr2_rdlen);
    582  1.1.1.4  christos 
    583  1.1.1.4  christos /*
    584  1.1.1.4  christos  * Retrieve domain ref at an offset in the rdata.
    585  1.1.1.4  christos  * @param rr: the RR to retrieve it for.
    586  1.1.1.4  christos  * @param offset: where in the rdata the reference pointer is.
    587  1.1.1.4  christos  * @return domain ptr.
    588  1.1.1.4  christos  */
    589  1.1.1.4  christos struct domain* retrieve_rdata_ref_domain_offset(const struct rr* rr,
    590  1.1.1.4  christos 	uint16_t offset);
    591  1.1.1.4  christos 
    592  1.1.1.4  christos /*
    593  1.1.1.4  christos  * Retrieve domain ref from rdata. No offset, rdata starts with ref.
    594  1.1.1.4  christos  * @param rr: the RR to retrieve it for.
    595  1.1.1.4  christos  * @return domain ptr.
    596  1.1.1.4  christos  */
    597  1.1.1.4  christos struct domain* retrieve_rdata_ref_domain(const struct rr* rr);
    598  1.1.1.4  christos 
    599  1.1.1.4  christos /*
    600  1.1.1.4  christos  * Accessor function to the domain in the rdata of the type.
    601  1.1.1.4  christos  * The RR must be of the type. The type must have references.
    602  1.1.1.4  christos  * @param rr: the rr with rdata
    603  1.1.1.4  christos  * @return domain pointer.
    604  1.1.1.4  christos  */
    605  1.1.1.4  christos typedef struct domain*(*nsd_rdata_ref_domain_type)(
    606  1.1.1.4  christos 	const struct rr* rr);
    607  1.1.1.4  christos 
    608  1.1.1.4  christos /* Access the domain reference for type NS */
    609  1.1.1.4  christos struct domain* retrieve_ns_ref_domain(const struct rr* rr);
    610  1.1.1.4  christos 
    611  1.1.1.4  christos /* Access the domain reference for type CNAME */
    612  1.1.1.4  christos struct domain* retrieve_cname_ref_domain(const struct rr* rr);
    613  1.1.1.4  christos 
    614  1.1.1.4  christos /* Access the domain reference for type DNAME */
    615  1.1.1.4  christos struct domain* retrieve_dname_ref_domain(const struct rr* rr);
    616  1.1.1.4  christos 
    617  1.1.1.4  christos /* Access the domain reference for type MB */
    618  1.1.1.4  christos struct domain* retrieve_mb_ref_domain(const struct rr* rr);
    619  1.1.1.4  christos 
    620  1.1.1.4  christos /* Access the domain reference for type MX */
    621  1.1.1.4  christos struct domain* retrieve_mx_ref_domain(const struct rr* rr);
    622  1.1.1.4  christos 
    623  1.1.1.4  christos /* Access the domain reference for type KX */
    624  1.1.1.4  christos struct domain* retrieve_kx_ref_domain(const struct rr* rr);
    625  1.1.1.4  christos 
    626  1.1.1.4  christos /* Access the domain reference for type RT */
    627  1.1.1.4  christos struct domain* retrieve_rt_ref_domain(const struct rr* rr);
    628  1.1.1.4  christos 
    629  1.1.1.4  christos /* Access the domain reference for type SRV */
    630  1.1.1.4  christos struct domain* retrieve_srv_ref_domain(const struct rr* rr);
    631  1.1.1.4  christos 
    632  1.1.1.4  christos /* Access the domain reference for type PTR */
    633  1.1.1.4  christos struct domain* retrieve_ptr_ref_domain(const struct rr* rr);
    634  1.1.1.4  christos 
    635  1.1.1.4  christos /* Access the serial number for type SOA, false if malformed. */
    636  1.1.1.4  christos int retrieve_soa_rdata_serial(const struct rr* rr, uint32_t* serial);
    637  1.1.1.4  christos 
    638  1.1.1.4  christos /* Access the minimum ttl for type SOA, false if malformed. */
    639  1.1.1.4  christos int retrieve_soa_rdata_minttl(const struct rr* rr, uint32_t* minttl);
    640  1.1.1.4  christos 
    641  1.1.1.4  christos /* Access the dname reference for type CNAME */
    642  1.1.1.4  christos struct dname* retrieve_cname_ref_dname(const struct rr* rr);
    643  1.1.1.4  christos 
    644  1.1.1.4  christos /*
    645  1.1.1.4  christos  * Access the domain name reference, that is stored as COMPRESSED_DNAME,
    646  1.1.1.4  christos  * or UNCOMPRESSED DNAME, at the start of the rdata, or only part of the rdata.
    647  1.1.1.4  christos  * Not for literal DNAMEs. This is similar to a pointer reference,
    648  1.1.1.4  christos  * but it may be stored unaligned.
    649  1.1.1.4  christos  * @param rr: the resource record.
    650  1.1.1.4  christos  * @return domain pointer.
    651  1.1.1.4  christos  */
    652  1.1.1.4  christos static inline struct domain* rdata_domain_ref(const struct rr* rr) {
    653  1.1.1.4  christos 	struct domain* domain;
    654  1.1.1.4  christos 	assert(rr->rdlength >= (uint16_t)sizeof(void*));
    655  1.1.1.4  christos 	memcpy(&domain, rr->rdata, sizeof(void*));
    656  1.1.1.4  christos 	return domain;
    657  1.1.1.4  christos }
    658  1.1.1.4  christos 
    659  1.1.1.4  christos /*
    660  1.1.1.4  christos  * Access the domain name reference, that is stored as COMPRESSED_DNAME,
    661  1.1.1.4  christos  * or UNCOMPRESSED DNAME, the reference is at an offset in the rdata.
    662  1.1.1.4  christos  * Not for literal DNAMEs. This is similar to a pointer reference,
    663  1.1.1.4  christos  * but it may be stored unaligned.
    664  1.1.1.4  christos  * @param rr: the resource record
    665  1.1.1.4  christos  * @param offset: where the reference is found in the rdata. Pass like 2,
    666  1.1.1.4  christos  *	for type MX, or sizeof(void*) to access the second domain pointer
    667  1.1.1.4  christos  *	of SOA.
    668  1.1.1.4  christos  * @return domain pointer.
    669  1.1.1.4  christos  */
    670  1.1.1.4  christos static inline struct domain* rdata_domain_ref_offset(const struct rr* rr,
    671  1.1.1.4  christos 	uint16_t offset) {
    672  1.1.1.4  christos 	struct domain* domain;
    673  1.1.1.4  christos 	assert(rr->rdlength >= offset+(uint16_t)sizeof(void*));
    674  1.1.1.4  christos 	memcpy(&domain, rr->rdata+offset, sizeof(void*));
    675  1.1.1.4  christos 	return domain;
    676  1.1.1.4  christos }
    677  1.1.1.4  christos 
    678  1.1.1.4  christos /* fixup usage lower for domain names in the rdata */
    679  1.1.1.4  christos void rr_lower_usage(namedb_type* db, rr_type* rr);
    680  1.1.1.4  christos 
    681  1.1.1.4  christos /* return error string for read_rdata return code that is < 0 */
    682  1.1.1.4  christos const char* read_rdata_fail_str(int32_t code);
    683      1.1  christos 
    684  1.1.1.3  christos #endif /* RDATA_H */
    685