Lines Matching refs:prefix
22 * Id: prefix.c,v 1.37.2.9 2000/03/10 02:53:19 labovit Exp
37 _deref_prefix(isc_mem_t *mctx, isc_prefix_t *prefix);
40 _ref_prefix(isc_mem_t *mctx, isc_prefix_t **target, isc_prefix_t *prefix);
52 isc_prefix_t *prefix;
59 prefix = isc_mem_get(mctx, sizeof(isc_prefix_t));
60 if (prefix == NULL)
64 prefix->bitlen = (bitlen >= 0) ? bitlen : 128;
65 memmove(&prefix->add.sin6, dest, 16);
68 prefix->bitlen = (bitlen >= 0) ? bitlen : 32;
69 memmove(&prefix->add.sin, dest, 4);
72 prefix->family = family;
74 isc_refcount_init(&prefix->refcount, 1);
76 *target = prefix;
81 _deref_prefix(isc_mem_t *mctx, isc_prefix_t *prefix) {
84 if (prefix == NULL)
87 isc_refcount_decrement(&prefix->refcount, &refs);
90 isc_refcount_destroy(&prefix->refcount);
91 isc_mem_put(mctx, prefix, sizeof(isc_prefix_t));
96 _ref_prefix(isc_mem_t *mctx, isc_prefix_t **target, isc_prefix_t *prefix) {
97 INSIST(prefix != NULL);
98 INSIST((prefix->family == AF_INET && prefix->bitlen <= 32) ||
99 (prefix->family == AF_INET6 && prefix->bitlen <= 128) ||
100 (prefix->family == AF_UNSPEC && prefix->bitlen == 0));
104 * If this prefix is a static allocation, copy it into new memory.
108 if (isc_refcount_current(&prefix->refcount) == 0) {
110 ret = _new_prefix(mctx, target, prefix->family,
111 &prefix->add, prefix->bitlen);
115 isc_refcount_increment(&prefix->refcount, NULL);
117 *target = prefix;
180 if (Xrn->prefix != NULL) {
181 _deref_prefix(radix->mctx, Xrn->prefix);
221 * func will be called as func(node->prefix, node->data)
231 func(node->prefix, node->data);
238 isc_prefix_t *prefix)
248 REQUIRE(prefix != NULL);
250 RUNTIME_CHECK(prefix->bitlen <= radix->maxbits);
259 addr = isc_prefix_touchar(prefix);
260 bitlen = prefix->bitlen;
263 if (node->prefix)
275 if (node && node->prefix)
281 if (_comp_with_mask(isc_prefix_tochar(node->prefix),
282 isc_prefix_tochar(prefix),
283 node->prefix->bitlen)) {
284 if (node->node_num[ISC_IS6(prefix->family)] != -1 &&
287 node->node_num[ISC_IS6(prefix->family)])) {
289 tfamily = prefix->family;
303 isc_radix_node_t *source, isc_prefix_t *prefix)
313 REQUIRE(prefix != NULL || (source != NULL && source->prefix != NULL));
314 RUNTIME_CHECK(prefix == NULL || prefix->bitlen <= radix->maxbits);
316 if (prefix == NULL)
317 prefix = source->prefix;
319 INSIST(prefix != NULL);
321 bitlen = prefix->bitlen;
322 fam = prefix->family;
330 node->prefix = NULL;
331 result = _ref_prefix(radix->mctx, &node->prefix, prefix);
374 addr = isc_prefix_touchar(prefix);
377 while (node->bit < bitlen || node->prefix == NULL) {
393 INSIST(node->prefix != NULL);
395 test_addr = isc_prefix_touchar(node->prefix);
425 if (node->prefix != NULL) {
465 _ref_prefix(radix->mctx, &node->prefix, prefix);
509 new_node->prefix = NULL;
510 result = _ref_prefix(radix->mctx, &new_node->prefix, prefix);
583 glue->prefix = NULL;
623 * make sure there is a prefix associated with it!
625 if (node->prefix != NULL)
626 _deref_prefix(radix->mctx, node->prefix);
628 node->prefix = NULL;
635 _deref_prefix(radix->mctx, node->prefix);
654 if (parent->prefix)
683 _deref_prefix(radix->mctx, node->prefix);