Lines Matching defs:keytable
9 /* $Id: keytable.c,v 1.41 2010/06/25 23:46:51 tbox Exp $ */
22 #include <dns/keytable.h>
62 dns_keytable_t *keytable;
66 * Create a keytable.
71 keytable = isc_mem_get(mctx, sizeof(*keytable));
72 if (keytable == NULL) {
76 keytable->table = NULL;
77 result = dns_rbt_create(mctx, free_keynode, mctx, &keytable->table);
82 result = isc_rwlock_init(&keytable->rwlock, 0, 0);
87 result = isc_refcount_init(&keytable->active_nodes, 0);
92 result = isc_refcount_init(&keytable->references, 1);
97 keytable->mctx = NULL;
98 isc_mem_attach(mctx, &keytable->mctx);
99 keytable->magic = KEYTABLE_MAGIC;
100 *keytablep = keytable;
105 isc_refcount_destroy(&keytable->active_nodes);
108 isc_rwlock_destroy(&keytable->rwlock);
111 dns_rbt_destroy(&keytable->table);
114 isc_mem_putanddetach(&mctx, keytable, sizeof(*keytable));
136 dns_keytable_t *keytable;
140 * Detach *keytablep from its keytable.
145 keytable = *keytablep;
148 isc_refcount_decrement(&keytable->references, &refs);
150 INSIST(isc_refcount_current(&keytable->active_nodes) == 0);
151 isc_refcount_destroy(&keytable->active_nodes);
152 isc_refcount_destroy(&keytable->references);
153 dns_rbt_destroy(&keytable->table);
154 isc_rwlock_destroy(&keytable->rwlock);
155 keytable->magic = 0;
156 isc_mem_putanddetach(&keytable->mctx,
157 keytable, sizeof(*keytable));
162 insert(dns_keytable_t *keytable, isc_boolean_t managed,
170 REQUIRE(VALID_KEYTABLE(keytable));
172 result = dns_keynode_create(keytable->mctx, &knode);
178 RWLOCK(&keytable->rwlock, isc_rwlocktype_write);
181 result = dns_rbt_addnode(keytable->table, keyname, &node);
219 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_write);
222 dns_keynode_detach(keytable->mctx, &knode);
228 dns_keytable_add(dns_keytable_t *keytable, isc_boolean_t managed,
232 return (insert(keytable, managed, dst_key_name(*keyp), keyp));
236 dns_keytable_marksecure(dns_keytable_t *keytable, dns_name_t *name) {
237 return (insert(keytable, ISC_TRUE, name, NULL));
241 dns_keytable_delete(dns_keytable_t *keytable, dns_name_t *keyname) {
245 REQUIRE(VALID_KEYTABLE(keytable));
248 RWLOCK(&keytable->rwlock, isc_rwlocktype_write);
249 result = dns_rbt_findnode(keytable->table, keyname, NULL, &node, NULL,
253 result = dns_rbt_deletenode(keytable->table,
259 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_write);
265 dns_keytable_deletekeynode(dns_keytable_t *keytable, dst_key_t *dstkey) {
271 REQUIRE(VALID_KEYTABLE(keytable));
276 RWLOCK(&keytable->rwlock, isc_rwlocktype_write);
277 result = dns_rbt_findnode(keytable->table, keyname, NULL, &node, NULL,
294 result = dns_rbt_deletenode(keytable->table, node, ISC_FALSE);
319 dns_keynode_detach(keytable->mctx, &knode);
323 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_write);
328 dns_keytable_find(dns_keytable_t *keytable, dns_name_t *keyname,
334 REQUIRE(VALID_KEYTABLE(keytable));
338 RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
339 result = dns_rbt_findnode(keytable->table, keyname, NULL, &node, NULL,
343 isc_refcount_increment0(&keytable->active_nodes, NULL);
349 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read);
355 dns_keytable_nextkeynode(dns_keytable_t *keytable, dns_keynode_t *keynode,
363 REQUIRE(VALID_KEYTABLE(keytable));
371 isc_refcount_increment(&keytable->active_nodes, NULL);
377 dns_keytable_findkeynode(dns_keytable_t *keytable, dns_name_t *name,
387 * 'keytable'.
390 REQUIRE(VALID_KEYTABLE(keytable));
394 RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
405 result = dns_rbt_findname(keytable->table, name, 0, NULL, &data);
419 isc_refcount_increment0(&keytable->active_nodes, NULL);
426 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read);
432 dns_keytable_findnextkeynode(dns_keytable_t *keytable, dns_keynode_t *keynode,
440 * 'keytable'.
443 REQUIRE(VALID_KEYTABLE(keytable));
457 isc_refcount_increment(&keytable->active_nodes, NULL);
467 dns_keytable_finddeepestmatch(dns_keytable_t *keytable, dns_name_t *name,
474 * Search for the deepest match in 'keytable'.
477 REQUIRE(VALID_KEYTABLE(keytable));
481 RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
484 result = dns_rbt_findname(keytable->table, name, 0, foundname, &data);
489 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read);
495 dns_keytable_attachkeynode(dns_keytable_t *keytable, dns_keynode_t *source,
502 REQUIRE(VALID_KEYTABLE(keytable));
506 isc_refcount_increment(&keytable->active_nodes, NULL);
512 dns_keytable_detachkeynode(dns_keytable_t *keytable, dns_keynode_t **keynodep)
518 REQUIRE(VALID_KEYTABLE(keytable));
521 isc_refcount_decrement(&keytable->active_nodes, NULL);
522 dns_keynode_detach(keytable->mctx, keynodep);
526 dns_keytable_issecuredomain(dns_keytable_t *keytable, dns_name_t *name,
536 REQUIRE(VALID_KEYTABLE(keytable));
540 RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
542 result = dns_rbt_findnode(keytable->table, name, foundname, &node,
553 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read);
571 dns_keytable_dump(dns_keytable_t *keytable, FILE *fp) {
575 REQUIRE(VALID_KEYTABLE(keytable));
578 result = isc_buffer_allocate(keytable->mctx, &text, 4096);
582 result = dns_keytable_totext(keytable, &text);
601 dns_keytable_totext(dns_keytable_t *keytable, isc_buffer_t **text) {
607 REQUIRE(VALID_KEYTABLE(keytable));
610 RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
611 dns_rbtnodechain_init(&chain, keytable->mctx);
612 result = dns_rbtnodechain_first(&chain, keytable->table, NULL, NULL);
643 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read);
648 dns_keytable_forall(dns_keytable_t *keytable,
656 REQUIRE(VALID_KEYTABLE(keytable));
658 RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
659 dns_rbtnodechain_init(&chain, keytable->mctx);
660 result = dns_rbtnodechain_first(&chain, keytable->table, NULL, NULL);
666 isc_refcount_increment0(&keytable->active_nodes, NULL);
670 (*func)(keytable, node->data, arg);
678 isc_refcount_decrement(&keytable->active_nodes, NULL);
682 RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read);