4 * the .h file with defs for the per rr
7 * a Net::DNS like library for C
9 * (c) NLnet Labs, 2005-2006
11 * See the file LICENSE for the license
13 #ifndef LDNS_RR_FUNCTIONS_H
14 #define LDNS_RR_FUNCTIONS_H
19 * Defines some extra convenience functions for ldns_rr structures
24 * returns the address of a LDNS_RR_TYPE_A rr
25 * \param[in] r the resource record
26 * \return a ldns_rdf* with the address or NULL on failure
28 ldns_rdf* ldns_rr_a_address(const ldns_rr *r);
31 * sets the address of a LDNS_RR_TYPE_A rr
32 * \param[in] r the rr to use
33 * \param[in] f the address to set
34 * \return true on success, false otherwise
36 bool ldns_rr_a_set_address(ldns_rr *r, ldns_rdf *f);
40 * returns the name of a LDNS_RR_TYPE_NS rr
41 * \param[in] r the resource record
42 * \return a ldns_rdf* with the name or NULL on failure
44 ldns_rdf* ldns_rr_ns_nsdname(const ldns_rr *r);
48 * returns the mx pref. of a LDNS_RR_TYPE_MX rr
49 * \param[in] r the resource record
50 * \return a ldns_rdf* with the preference or NULL on failure
52 ldns_rdf* ldns_rr_mx_preference(const ldns_rr *r);
54 * returns the mx host of a LDNS_RR_TYPE_MX rr
55 * \param[in] r the resource record
56 * \return a ldns_rdf* with the name of the MX host or NULL on failure
58 ldns_rdf* ldns_rr_mx_exchange(const ldns_rr *r);
62 * returns the type covered of a LDNS_RR_TYPE_RRSIG rr
63 * \param[in] r the resource record
64 * \return a ldns_rdf* with the type covered or NULL on failure
66 ldns_rdf* ldns_rr_rrsig_typecovered(const ldns_rr *r);
68 * sets the typecovered of a LDNS_RR_TYPE_RRSIG rr
69 * \param[in] r the rr to use
70 * \param[in] f the typecovered to set
71 * \return true on success, false otherwise
73 bool ldns_rr_rrsig_set_typecovered(ldns_rr *r, ldns_rdf *f);
75 * returns the algorithm of a LDNS_RR_TYPE_RRSIG RR
76 * \param[in] r the resource record
77 * \return a ldns_rdf* with the algorithm or NULL on failure
79 ldns_rdf* ldns_rr_rrsig_algorithm(const ldns_rr *r);
81 * sets the algorithm of a LDNS_RR_TYPE_RRSIG rr
82 * \param[in] r the rr to use
83 * \param[in] f the algorithm to set
84 * \return true on success, false otherwise
86 bool ldns_rr_rrsig_set_algorithm(ldns_rr *r, ldns_rdf *f);
88 * returns the number of labels of a LDNS_RR_TYPE_RRSIG RR
89 * \param[in] r the resource record
90 * \return a ldns_rdf* with the number of labels or NULL on failure
92 ldns_rdf *ldns_rr_rrsig_labels(const ldns_rr *r);
94 * sets the number of labels of a LDNS_RR_TYPE_RRSIG rr
95 * \param[in] r the rr to use
96 * \param[in] f the number of labels to set
97 * \return true on success, false otherwise
99 bool ldns_rr_rrsig_set_labels(ldns_rr *r, ldns_rdf *f);
101 * returns the original TTL of a LDNS_RR_TYPE_RRSIG RR
102 * \param[in] r the resource record
103 * \return a ldns_rdf* with the original TTL or NULL on failure
105 ldns_rdf* ldns_rr_rrsig_origttl(const ldns_rr *r);
107 * sets the original TTL of a LDNS_RR_TYPE_RRSIG rr
108 * \param[in] r the rr to use
109 * \param[in] f the original TTL to set
110 * \return true on success, false otherwise
112 bool ldns_rr_rrsig_set_origttl(ldns_rr *r, ldns_rdf *f);
114 * returns the expiration time of a LDNS_RR_TYPE_RRSIG RR
115 * \param[in] r the resource record
116 * \return a ldns_rdf* with the expiration time or NULL on failure
118 ldns_rdf* ldns_rr_rrsig_expiration(const ldns_rr *r);
120 * sets the expireation date of a LDNS_RR_TYPE_RRSIG rr
121 * \param[in] r the rr to use
122 * \param[in] f the expireation date to set
123 * \return true on success, false otherwise
125 bool ldns_rr_rrsig_set_expiration(ldns_rr *r, ldns_rdf *f);
127 * returns the inception time of a LDNS_RR_TYPE_RRSIG RR
128 * \param[in] r the resource record
129 * \return a ldns_rdf* with the inception time or NULL on failure
131 ldns_rdf* ldns_rr_rrsig_inception(const ldns_rr *r);
133 * sets the inception date of a LDNS_RR_TYPE_RRSIG rr
134 * \param[in] r the rr to use
135 * \param[in] f the inception date to set
136 * \return true on success, false otherwise
138 bool ldns_rr_rrsig_set_inception(ldns_rr *r, ldns_rdf *f);
140 * returns the keytag of a LDNS_RR_TYPE_RRSIG RR
141 * \param[in] r the resource record
142 * \return a ldns_rdf* with the keytag or NULL on failure
144 ldns_rdf* ldns_rr_rrsig_keytag(const ldns_rr *r);
146 * sets the keytag of a LDNS_RR_TYPE_RRSIG rr
147 * \param[in] r the rr to use
148 * \param[in] f the keytag to set
149 * \return true on success, false otherwise
151 bool ldns_rr_rrsig_set_keytag(ldns_rr *r, ldns_rdf *f);
153 * returns the signers name of a LDNS_RR_TYPE_RRSIG RR
154 * \param[in] r the resource record
155 * \return a ldns_rdf* with the signers name or NULL on failure
157 ldns_rdf* ldns_rr_rrsig_signame(const ldns_rr *r);
159 * sets the signers name of a LDNS_RR_TYPE_RRSIG rr
160 * \param[in] r the rr to use
161 * \param[in] f the signers name to set
162 * \return true on success, false otherwise
164 bool ldns_rr_rrsig_set_signame(ldns_rr *r, ldns_rdf *f);
166 * returns the signature data of a LDNS_RR_TYPE_RRSIG RR
167 * \param[in] r the resource record
168 * \return a ldns_rdf* with the signature data or NULL on failure
170 ldns_rdf* ldns_rr_rrsig_sig(const ldns_rr *r);
172 * sets the signature data of a LDNS_RR_TYPE_RRSIG rr
173 * \param[in] r the rr to use
174 * \param[in] f the signature data to set
175 * \return true on success, false otherwise
177 bool ldns_rr_rrsig_set_sig(ldns_rr *r, ldns_rdf *f);
181 * returns the flags of a LDNS_RR_TYPE_DNSKEY rr
182 * \param[in] r the resource record
183 * \return a ldns_rdf* with the flags or NULL on failure
185 ldns_rdf* ldns_rr_dnskey_flags(const ldns_rr *r);
187 * sets the flags of a LDNS_RR_TYPE_DNSKEY rr
188 * \param[in] r the rr to use
189 * \param[in] f the flags to set
190 * \return true on success, false otherwise
192 bool ldns_rr_dnskey_set_flags(ldns_rr *r, ldns_rdf *f);
194 * returns the protocol of a LDNS_RR_TYPE_DNSKEY rr
195 * \param[in] r the resource record
196 * \return a ldns_rdf* with the protocol or NULL on failure
198 ldns_rdf* ldns_rr_dnskey_protocol(const ldns_rr *r);
200 * sets the protocol of a LDNS_RR_TYPE_DNSKEY rr
201 * \param[in] r the rr to use
202 * \param[in] f the protocol to set
203 * \return true on success, false otherwise
205 bool ldns_rr_dnskey_set_protocol(ldns_rr *r, ldns_rdf *f);
207 * returns the algorithm of a LDNS_RR_TYPE_DNSKEY rr
208 * \param[in] r the resource record
209 * \return a ldns_rdf* with the algorithm or NULL on failure
211 ldns_rdf* ldns_rr_dnskey_algorithm(const ldns_rr *r);
213 * sets the algorithm of a LDNS_RR_TYPE_DNSKEY rr
214 * \param[in] r the rr to use
215 * \param[in] f the algorithm to set
216 * \return true on success, false otherwise
218 bool ldns_rr_dnskey_set_algorithm(ldns_rr *r, ldns_rdf *f);
220 * returns the key data of a LDNS_RR_TYPE_DNSKEY rr
221 * \param[in] r the resource record
222 * \return a ldns_rdf* with the key data or NULL on failure
224 ldns_rdf* ldns_rr_dnskey_key(const ldns_rr *r);
226 * sets the key data of a LDNS_RR_TYPE_DNSKEY rr
227 * \param[in] r the rr to use
228 * \param[in] f the key data to set
229 * \return true on success, false otherwise
231 bool ldns_rr_dnskey_set_key(ldns_rr *r, ldns_rdf *f);
234 * get the length of the keydata in bits
235 * \param[in] keydata the raw key data
236 * \param[in] len the length of the keydata
237 * \param[in] alg the cryptographic algorithm this is a key for
238 * \return the keysize in bits, or 0 on error
240 size_t ldns_rr_dnskey_key_size_raw(const unsigned char *keydata,
242 const ldns_algorithm alg);
245 * get the length of the keydata in bits
246 * \param[in] key the key rr to use
247 * \return the keysize in bits
249 size_t ldns_rr_dnskey_key_size(const ldns_rr *key);
251 #endif /* LDNS_RR_FUNCTIONS_H */