Initial vendor import of ldns-1.6.4 into contrib.
[dragonfly.git] / contrib / ldns / ldns / rr_functions.h
1 /*
2  * rr_functions.h
3  *
4  * the .h file with defs for the per rr
5  * functions
6  *
7  * a Net::DNS like library for C
8  * 
9  * (c) NLnet Labs, 2005-2006
10  * 
11  * See the file LICENSE for the license
12  */
13 #ifndef LDNS_RR_FUNCTIONS_H
14 #define LDNS_RR_FUNCTIONS_H
15
16 /**
17  * \file
18  *
19  * Defines some extra convenience functions for ldns_rr structures
20  */
21
22 /* A / AAAA */
23 /**
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
27  */
28 ldns_rdf* ldns_rr_a_address(const ldns_rr *r);
29
30 /**
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
35  */
36 bool ldns_rr_a_set_address(ldns_rr *r, ldns_rdf *f);
37
38 /* NS */
39 /**
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
43  */
44 ldns_rdf* ldns_rr_ns_nsdname(const ldns_rr *r);
45
46 /* MX */
47 /**
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
51  */
52 ldns_rdf* ldns_rr_mx_preference(const ldns_rr *r);
53 /**
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
57  */
58 ldns_rdf* ldns_rr_mx_exchange(const ldns_rr *r);
59
60 /* RRSIG */
61 /**
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
65  */
66 ldns_rdf* ldns_rr_rrsig_typecovered(const ldns_rr *r);
67 /**
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
72  */
73 bool ldns_rr_rrsig_set_typecovered(ldns_rr *r, ldns_rdf *f);
74 /**
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
78  */
79 ldns_rdf* ldns_rr_rrsig_algorithm(const ldns_rr *r);
80 /**
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
85  */
86 bool ldns_rr_rrsig_set_algorithm(ldns_rr *r, ldns_rdf *f);
87 /**
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
91  */
92 ldns_rdf *ldns_rr_rrsig_labels(const ldns_rr *r);
93 /**
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
98  */
99 bool ldns_rr_rrsig_set_labels(ldns_rr *r, ldns_rdf *f);
100 /**
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
104  */
105 ldns_rdf* ldns_rr_rrsig_origttl(const ldns_rr *r);
106 /**
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
111  */
112 bool ldns_rr_rrsig_set_origttl(ldns_rr *r, ldns_rdf *f);
113 /**
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
117  */
118 ldns_rdf* ldns_rr_rrsig_expiration(const ldns_rr *r);
119 /**
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
124  */
125 bool ldns_rr_rrsig_set_expiration(ldns_rr *r, ldns_rdf *f);
126 /**
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
130  */
131 ldns_rdf* ldns_rr_rrsig_inception(const ldns_rr *r);
132 /**
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
137  */
138 bool ldns_rr_rrsig_set_inception(ldns_rr *r, ldns_rdf *f);
139 /**
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
143  */
144 ldns_rdf* ldns_rr_rrsig_keytag(const ldns_rr *r);
145 /**
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
150  */
151 bool ldns_rr_rrsig_set_keytag(ldns_rr *r, ldns_rdf *f);
152 /**
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
156  */
157 ldns_rdf* ldns_rr_rrsig_signame(const ldns_rr *r);
158 /**
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
163  */
164 bool ldns_rr_rrsig_set_signame(ldns_rr *r, ldns_rdf *f);
165 /**
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
169  */
170 ldns_rdf* ldns_rr_rrsig_sig(const ldns_rr *r);
171 /**
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
176  */
177 bool ldns_rr_rrsig_set_sig(ldns_rr *r, ldns_rdf *f);
178
179 /* DNSKEY */
180 /**
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
184  */
185 ldns_rdf* ldns_rr_dnskey_flags(const ldns_rr *r);
186 /**
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
191  */
192 bool ldns_rr_dnskey_set_flags(ldns_rr *r, ldns_rdf *f);
193 /**
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
197  */
198 ldns_rdf* ldns_rr_dnskey_protocol(const ldns_rr *r);
199 /**
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
204  */
205 bool ldns_rr_dnskey_set_protocol(ldns_rr *r, ldns_rdf *f);
206 /**
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
210  */
211 ldns_rdf* ldns_rr_dnskey_algorithm(const ldns_rr *r);
212 /**
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
217  */
218 bool ldns_rr_dnskey_set_algorithm(ldns_rr *r, ldns_rdf *f);
219 /**
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
223  */
224 ldns_rdf* ldns_rr_dnskey_key(const ldns_rr *r);
225 /**
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
230  */
231 bool ldns_rr_dnskey_set_key(ldns_rr *r, ldns_rdf *f);
232
233 /**
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
239  */
240 size_t ldns_rr_dnskey_key_size_raw(const unsigned char *keydata,
241                                    const size_t len,
242                                    const ldns_algorithm alg);
243
244 /**
245  * get the length of the keydata in bits
246  * \param[in] key the key rr to use
247  * \return the keysize in bits
248  */
249 size_t ldns_rr_dnskey_key_size(const ldns_rr *key);
250
251 #endif /* LDNS_RR_FUNCTIONS_H */