Deleted Added
full compact
rrset.h (256281) rrset.h (269257)
1/*
2 * services/cache/rrset.h - Resource record set cache.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1/*
2 * services/cache/rrset.h - Resource record set cache.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file contains the rrset cache.
40 */
41

--- 84 unchanged lines hidden (view full) ---

126 * @param timenow: current time (to see if ttl in cache is expired).
127 * @return: true if the passed reference is updated, false if it is unchanged.
128 * 0: reference unchanged, inserted in cache.
129 * 1: reference updated, item is inserted in cache.
130 * 2: reference updated, item in cache is considered superior.
131 * also the rdata is equal (but other parameters in cache are superior).
132 */
133int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
34 */
35
36/**
37 * \file
38 *
39 * This file contains the rrset cache.
40 */
41

--- 84 unchanged lines hidden (view full) ---

126 * @param timenow: current time (to see if ttl in cache is expired).
127 * @return: true if the passed reference is updated, false if it is unchanged.
128 * 0: reference unchanged, inserted in cache.
129 * 1: reference updated, item is inserted in cache.
130 * 2: reference updated, item in cache is considered superior.
131 * also the rdata is equal (but other parameters in cache are superior).
132 */
133int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
134 struct alloc_cache* alloc, uint32_t timenow);
134 struct alloc_cache* alloc, time_t timenow);
135
136/**
137 * Lookup rrset. You obtain read/write lock. You must unlock before lookup
138 * anything of else.
139 * @param r: the rrset cache.
140 * @param qname: name of rrset to lookup.
141 * @param qnamelen: length of name of rrset to lookup.
142 * @param qtype: type of rrset to lookup (host order).
143 * @param qclass: class of rrset to lookup (host order).
144 * @param flags: rrset flags, or 0.
145 * @param timenow: used to compare with TTL.
146 * @param wr: set true to get writelock.
147 * @return packed rrset key pointer. Remember to unlock the key.entry.lock.
148 * or NULL if could not be found or it was timed out.
149 */
150struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r,
151 uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
135
136/**
137 * Lookup rrset. You obtain read/write lock. You must unlock before lookup
138 * anything of else.
139 * @param r: the rrset cache.
140 * @param qname: name of rrset to lookup.
141 * @param qnamelen: length of name of rrset to lookup.
142 * @param qtype: type of rrset to lookup (host order).
143 * @param qclass: class of rrset to lookup (host order).
144 * @param flags: rrset flags, or 0.
145 * @param timenow: used to compare with TTL.
146 * @param wr: set true to get writelock.
147 * @return packed rrset key pointer. Remember to unlock the key.entry.lock.
148 * or NULL if could not be found or it was timed out.
149 */
150struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r,
151 uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
152 uint32_t flags, uint32_t timenow, int wr);
152 uint32_t flags, time_t timenow, int wr);
153
154/**
155 * Obtain readlock on a (sorted) list of rrset references.
156 * Checks TTLs and IDs of the rrsets and rollbacks locking if not Ok.
157 * @param ref: array of rrset references (key pointer and ID value).
158 * duplicate references are allowed and handled.
159 * @param count: size of array.
160 * @param timenow: used to compare with TTL.
161 * @return true on success, false on a failure, which can be that some
162 * RRsets have timed out, or that they do not exist any more, the
163 * RRsets have been purged from the cache.
164 * If true, you hold readlocks on all the ref items.
165 */
153
154/**
155 * Obtain readlock on a (sorted) list of rrset references.
156 * Checks TTLs and IDs of the rrsets and rollbacks locking if not Ok.
157 * @param ref: array of rrset references (key pointer and ID value).
158 * duplicate references are allowed and handled.
159 * @param count: size of array.
160 * @param timenow: used to compare with TTL.
161 * @return true on success, false on a failure, which can be that some
162 * RRsets have timed out, or that they do not exist any more, the
163 * RRsets have been purged from the cache.
164 * If true, you hold readlocks on all the ref items.
165 */
166int rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow);
166int rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow);
167
168/**
169 * Unlock array (sorted) of rrset references.
170 * @param ref: array of rrset references (key pointer and ID value).
171 * duplicate references are allowed and handled.
172 * @param count: size of array.
173 */
174void rrset_array_unlock(struct rrset_ref* ref, size_t count);

--- 19 unchanged lines hidden (view full) ---

194 * If so, it will update the security, trust and rrset-ttl values.
195 * The values are only updated if security is increased (towards secure).
196 * @param r: the rrset cache.
197 * @param rrset: which rrset to attempt to update. This rrset is left
198 * untouched. The rrset in the cache is updated in-place.
199 * @param now: current time.
200 */
201void rrset_update_sec_status(struct rrset_cache* r,
167
168/**
169 * Unlock array (sorted) of rrset references.
170 * @param ref: array of rrset references (key pointer and ID value).
171 * duplicate references are allowed and handled.
172 * @param count: size of array.
173 */
174void rrset_array_unlock(struct rrset_ref* ref, size_t count);

--- 19 unchanged lines hidden (view full) ---

194 * If so, it will update the security, trust and rrset-ttl values.
195 * The values are only updated if security is increased (towards secure).
196 * @param r: the rrset cache.
197 * @param rrset: which rrset to attempt to update. This rrset is left
198 * untouched. The rrset in the cache is updated in-place.
199 * @param now: current time.
200 */
201void rrset_update_sec_status(struct rrset_cache* r,
202 struct ub_packed_rrset_key* rrset, uint32_t now);
202 struct ub_packed_rrset_key* rrset, time_t now);
203
204/**
205 * Looks up security status of an rrset. Looks up the rrset.
206 * If found, checks if rdata is equal, and entry did not expire.
207 * If so, it will update the security, trust and rrset-ttl values.
208 * @param r: the rrset cache.
209 * @param rrset: This rrset may change security status due to the cache.
210 * But its status will only improve, towards secure.
211 * @param now: current time.
212 */
213void rrset_check_sec_status(struct rrset_cache* r,
203
204/**
205 * Looks up security status of an rrset. Looks up the rrset.
206 * If found, checks if rdata is equal, and entry did not expire.
207 * If so, it will update the security, trust and rrset-ttl values.
208 * @param r: the rrset cache.
209 * @param rrset: This rrset may change security status due to the cache.
210 * But its status will only improve, towards secure.
211 * @param now: current time.
212 */
213void rrset_check_sec_status(struct rrset_cache* r,
214 struct ub_packed_rrset_key* rrset, uint32_t now);
214 struct ub_packed_rrset_key* rrset, time_t now);
215
216/**
217 * Remove an rrset from the cache, by name and type and flags
218 * @param r: rrset cache
219 * @param nm: name of rrset
220 * @param nmlen: length of name
221 * @param type: type of rrset
222 * @param dclass: class of rrset, host order
223 * @param flags: flags of rrset, host order
224 */
225void rrset_cache_remove(struct rrset_cache* r, uint8_t* nm, size_t nmlen,
226 uint16_t type, uint16_t dclass, uint32_t flags);
227
228/** mark rrset to be deleted, set id=0 */
229void rrset_markdel(void* key);
230
231#endif /* SERVICES_CACHE_RRSET_H */
215
216/**
217 * Remove an rrset from the cache, by name and type and flags
218 * @param r: rrset cache
219 * @param nm: name of rrset
220 * @param nmlen: length of name
221 * @param type: type of rrset
222 * @param dclass: class of rrset, host order
223 * @param flags: flags of rrset, host order
224 */
225void rrset_cache_remove(struct rrset_cache* r, uint8_t* nm, size_t nmlen,
226 uint16_t type, uint16_t dclass, uint32_t flags);
227
228/** mark rrset to be deleted, set id=0 */
229void rrset_markdel(void* key);
230
231#endif /* SERVICES_CACHE_RRSET_H */