2 * host2wire.h - 2wire conversion routines
4 * a Net::DNS like library for C
6 * (c) NLnet Labs, 2005-2006
8 * See the file LICENSE for the license
14 * Contains all functions to translate the main structures to wire format
17 #ifndef LDNS_HOST2WIRE_H
18 #define LDNS_HOST2WIRE_H
20 #include <ldns/common.h>
21 #include <ldns/error.h>
23 #include <ldns/rdata.h>
24 #include <ldns/packet.h>
25 #include <ldns/buffer.h>
28 #include "ldns/util.h"
31 * Copies the dname data to the buffer in wire format
32 * \param[out] *buffer buffer to append the result to
33 * \param[in] *name rdata dname to convert
36 ldns_status ldns_dname2buffer_wire(ldns_buffer *buffer, const ldns_rdf *name);
39 * Copies the rdata data to the buffer in wire format
40 * \param[out] *output buffer to append the result to
41 * \param[in] *rdf rdata to convert
44 ldns_status ldns_rdf2buffer_wire(ldns_buffer *output, const ldns_rdf *rdf);
47 * Copies the rdata data to the buffer in wire format
48 * If the rdata is a dname, the letters will be lowercased
49 * during the conversion
50 * \param[out] *output buffer to append the result to
51 * \param[in] *rdf rdata to convert
54 ldns_status ldns_rdf2buffer_wire_canonical(ldns_buffer *output,
58 * Copies the rr data to the buffer in wire format
59 * \param[out] *output buffer to append the result to
60 * \param[in] *rr resource record to convert
61 * \param[in] section the section in the packet this rr is supposed to be in
62 * (to determine whether to add rdata or not)
65 ldns_status ldns_rr2buffer_wire(ldns_buffer *output,
70 * Copies the rr data to the buffer in wire format, in canonical format
71 * according to RFC3597 (every dname in rdata fields of RR's mentioned in
72 * that RFC will be lowercased)
73 * \param[out] *output buffer to append the result to
74 * \param[in] *rr resource record to convert
75 * \param[in] section the section in the packet this rr is supposed to be in
76 * (to determine whether to add rdata or not)
79 ldns_status ldns_rr2buffer_wire_canonical(ldns_buffer *output,
85 * Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata
86 * This is needed in DNSSEC verification
87 * \param[out] output buffer to append the result to
88 * \param[in] sigrr signature rr to operate on
91 ldns_status ldns_rrsig2buffer_wire(ldns_buffer *output, const ldns_rr *sigrr);
94 * Converts an rr's rdata to wireformat, while excluding
95 * the ownername and all the stuff before the rdata.
96 * This is needed in DNSSEC keytag calculation, the ds
97 * calcalution from the key and maybe elsewhere.
99 * \param[out] *output buffer where to put the result
100 * \param[in] *rr rr to operate on
101 * \return ldns_status
103 ldns_status ldns_rr_rdata2buffer_wire(ldns_buffer *output, const ldns_rr *rr);
106 * Copies the packet data to the buffer in wire format
107 * \param[out] *output buffer to append the result to
108 * \param[in] *pkt packet to convert
109 * \return ldns_status
111 ldns_status ldns_pkt2buffer_wire(ldns_buffer *output, const ldns_pkt *pkt);
114 * Copies the rr_list data to the buffer in wire format
115 * \param[out] *output buffer to append the result to
116 * \param[in] *rrlist rr_list to to convert
117 * \return ldns_status
119 ldns_status ldns_rr_list2buffer_wire(ldns_buffer *output, const ldns_rr_list *rrlist);
122 * Allocates an array of uint8_t at dest, and puts the wireformat of the
123 * given rdf in that array. The result_size value contains the
124 * length of the array, if it succeeds, and 0 otherwise (in which case
125 * the function also returns NULL)
127 * \param[out] dest pointer to the array of bytes to be created
128 * \param[in] rdf the rdata field to convert
129 * \param[out] size the size of the converted result
131 ldns_status ldns_rdf2wire(uint8_t **dest, const ldns_rdf *rdf, size_t *size);
134 * Allocates an array of uint8_t at dest, and puts the wireformat of the
135 * given rr in that array. The result_size value contains the
136 * length of the array, if it succeeds, and 0 otherwise (in which case
137 * the function also returns NULL)
139 * If the section argument is LDNS_SECTION_QUESTION, data like ttl and rdata
140 * are not put into the result
142 * \param[out] dest pointer to the array of bytes to be created
143 * \param[in] rr the rr to convert
144 * \param[out] size the size of the converted result
146 ldns_status ldns_rr2wire(uint8_t **dest, const ldns_rr *rr, int, size_t *size);
149 * Allocates an array of uint8_t at dest, and puts the wireformat of the
150 * given packet in that array. The result_size value contains the
151 * length of the array, if it succeeds, and 0 otherwise (in which case
152 * the function also returns NULL)
154 ldns_status ldns_pkt2wire(uint8_t **dest, const ldns_pkt *p, size_t *size);
156 #endif /* LDNS_HOST2WIRE_H */