Lines Matching refs:prefix
14 * Id: prefix.c,v 1.37.2.9 2000/03/10 02:53:19 labovit Exp
29 _deref_prefix(isc_prefix_t *prefix);
32 _ref_prefix(isc_mem_t *mctx, isc_prefix_t **target, isc_prefix_t *prefix);
44 isc_prefix_t *prefix;
51 prefix = isc_mem_get(mctx, sizeof(isc_prefix_t));
52 if (prefix == NULL)
56 prefix->bitlen = (bitlen >= 0) ? bitlen : 128;
57 memmove(&prefix->add.sin6, dest, 16);
60 prefix->bitlen = (bitlen >= 0) ? bitlen : 32;
61 memmove(&prefix->add.sin, dest, 4);
64 prefix->family = family;
65 prefix->ecs = ISC_FALSE;
66 prefix->mctx = NULL;
67 isc_mem_attach(mctx, &prefix->mctx);
69 isc_refcount_init(&prefix->refcount, 1);
71 *target = prefix;
76 _deref_prefix(isc_prefix_t *prefix) {
79 if (prefix == NULL)
82 isc_refcount_decrement(&prefix->refcount, &refs);
85 isc_refcount_destroy(&prefix->refcount);
86 isc_mem_putanddetach(&prefix->mctx, prefix,
92 _ref_prefix(isc_mem_t *mctx, isc_prefix_t **target, isc_prefix_t *prefix) {
93 INSIST(prefix != NULL);
94 INSIST((prefix->family == AF_INET && prefix->bitlen <= 32) ||
95 (prefix->family == AF_INET6 && prefix->bitlen <= 128) ||
96 (prefix->family == AF_UNSPEC && prefix->bitlen == 0));
100 * If this prefix is a static allocation, copy it into new memory.
104 if (isc_refcount_current(&prefix->refcount) == 0) {
106 ret = _new_prefix(mctx, target, prefix->family,
107 &prefix->add, prefix->bitlen);
111 isc_refcount_increment(&prefix->refcount, NULL);
113 *target = prefix;
176 if (Xrn->prefix != NULL) {
177 _deref_prefix(Xrn->prefix);
217 * func will be called as func(node->prefix, node->data)
226 func(node->prefix, node->data);
233 isc_prefix_t *prefix)
242 REQUIRE(prefix != NULL);
244 RUNTIME_CHECK(prefix->bitlen <= radix->maxbits);
253 addr = isc_prefix_touchar(prefix);
254 bitlen = prefix->bitlen;
257 if (node->prefix)
269 if (node && node->prefix)
275 if (prefix->bitlen < node->bit)
278 if (_comp_with_mask(isc_prefix_tochar(node->prefix),
279 isc_prefix_tochar(prefix),
280 node->prefix->bitlen))
282 int off = ISC_RADIX_OFF(prefix);
302 isc_radix_node_t *source, isc_prefix_t *prefix)
312 REQUIRE(prefix != NULL || (source != NULL && source->prefix != NULL));
313 RUNTIME_CHECK(prefix == NULL || prefix->bitlen <= radix->maxbits);
315 if (prefix == NULL)
316 prefix = source->prefix;
318 INSIST(prefix != NULL);
320 bitlen = prefix->bitlen;
321 fam = prefix->family;
330 node->prefix = NULL;
331 result = _ref_prefix(radix->mctx, &node->prefix, prefix);
362 node->node_num[ISC_RADIX_OFF(prefix)] = next;
373 addr = isc_prefix_touchar(prefix);
376 while (node->bit < bitlen || node->prefix == NULL) {
392 INSIST(node->prefix != NULL);
394 test_addr = isc_prefix_touchar(node->prefix);
424 if (node->prefix != NULL) {
450 int off = ISC_RADIX_OFF(prefix);
460 &node->prefix, prefix);
485 node->node_num[ISC_RADIX_OFF(prefix)] = next;
504 new_node->prefix = NULL;
505 result = _ref_prefix(radix->mctx, &new_node->prefix, prefix);
538 new_node->node_num[ISC_RADIX_OFF(prefix)] = next;
580 glue->prefix = NULL;
622 * make sure there is a prefix associated with it!
624 if (node->prefix != NULL)
625 _deref_prefix(node->prefix);
627 node->prefix = NULL;
634 _deref_prefix(node->prefix);
656 if (parent->prefix)
686 _deref_prefix(node->prefix);