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"
35 * Copies the dname data to the buffer in wire format
36 * \param[out] *buffer buffer to append the result to
37 * \param[in] *name rdata dname to convert
40 ldns_status ldns_dname2buffer_wire(ldns_buffer *buffer, const ldns_rdf *name);
43 * Copies the rdata data to the buffer in wire format
44 * \param[out] *output buffer to append the result to
45 * \param[in] *rdf rdata to convert
48 ldns_status ldns_rdf2buffer_wire(ldns_buffer *output, const ldns_rdf *rdf);
51 * Copies the rdata data to the buffer in wire format
52 * If the rdata is a dname, the letters will be lowercased
53 * during the conversion
54 * \param[out] *output buffer to append the result to
55 * \param[in] *rdf rdata to convert
58 ldns_status ldns_rdf2buffer_wire_canonical(ldns_buffer *output,
62 * Copies the rr data to the buffer in wire format
63 * \param[out] *output buffer to append the result to
64 * \param[in] *rr resource record to convert
65 * \param[in] section the section in the packet this rr is supposed to be in
66 * (to determine whether to add rdata or not)
69 ldns_status ldns_rr2buffer_wire(ldns_buffer *output,
74 * Copies the rr data to the buffer in wire format, in canonical format
75 * according to RFC3597 (every dname in rdata fields of RR's mentioned in
76 * that RFC will be lowercased)
77 * \param[out] *output buffer to append the result to
78 * \param[in] *rr resource record to convert
79 * \param[in] section the section in the packet this rr is supposed to be in
80 * (to determine whether to add rdata or not)
83 ldns_status ldns_rr2buffer_wire_canonical(ldns_buffer *output,
89 * Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata
90 * This is needed in DNSSEC verification
91 * \param[out] output buffer to append the result to
92 * \param[in] sigrr signature rr to operate on
95 ldns_status ldns_rrsig2buffer_wire(ldns_buffer *output, const ldns_rr *sigrr);
98 * Converts an rr's rdata to wireformat, while excluding
99 * the ownername and all the stuff before the rdata.
100 * This is needed in DNSSEC keytag calculation, the ds
101 * calcalution from the key and maybe elsewhere.
103 * \param[out] *output buffer where to put the result
104 * \param[in] *rr rr to operate on
105 * \return ldns_status
107 ldns_status ldns_rr_rdata2buffer_wire(ldns_buffer *output, const ldns_rr *rr);
110 * Copies the packet data to the buffer in wire format
111 * \param[out] *output buffer to append the result to
112 * \param[in] *pkt packet to convert
113 * \return ldns_status
115 ldns_status ldns_pkt2buffer_wire(ldns_buffer *output, const ldns_pkt *pkt);
118 * Copies the rr_list data to the buffer in wire format
119 * \param[out] *output buffer to append the result to
120 * \param[in] *rrlist rr_list to to convert
121 * \return ldns_status
123 ldns_status ldns_rr_list2buffer_wire(ldns_buffer *output, const ldns_rr_list *rrlist);
126 * Allocates an array of uint8_t at dest, and puts the wireformat of the
127 * given rdf in that array. The result_size value contains the
128 * length of the array, if it succeeds, and 0 otherwise (in which case
129 * the function also returns NULL)
131 * \param[out] dest pointer to the array of bytes to be created
132 * \param[in] rdf the rdata field to convert
133 * \param[out] size the size of the converted result
135 ldns_status ldns_rdf2wire(uint8_t **dest, const ldns_rdf *rdf, size_t *size);
138 * Allocates an array of uint8_t at dest, and puts the wireformat of the
139 * given rr in that array. The result_size value contains the
140 * length of the array, if it succeeds, and 0 otherwise (in which case
141 * the function also returns NULL)
143 * If the section argument is LDNS_SECTION_QUESTION, data like ttl and rdata
144 * are not put into the result
146 * \param[out] dest pointer to the array of bytes to be created
147 * \param[in] rr the rr to convert
148 * \param[out] size the size of the converted result
150 ldns_status ldns_rr2wire(uint8_t **dest, const ldns_rr *rr, int, size_t *size);
153 * Allocates an array of uint8_t at dest, and puts the wireformat of the
154 * given packet in that array. The result_size value contains the
155 * length of the array, if it succeeds, and 0 otherwise (in which case
156 * the function also returns NULL)
158 ldns_status ldns_pkt2wire(uint8_t **dest, const ldns_pkt *p, size_t *size);
164 #endif /* LDNS_HOST2WIRE_H */