Lines Matching refs:prefix

95 static NDiscPrefix *ndisc_prefix_unref(NDiscPrefix *prefix) {
97 if (!prefix)
100 assert(prefix->n_ref > 0);
101 prefix->n_ref--;
103 if (prefix->n_ref > 0)
106 if (prefix->nd)
107 LIST_REMOVE(prefixes, prefix->nd->prefixes, prefix);
109 free(prefix);
115 NDiscPrefix *prefix;
119 prefix = new0(NDiscPrefix, 1);
120 if (!prefix)
123 prefix->n_ref = 1;
124 LIST_INIT(prefixes, prefix);
125 prefix->nd = nd;
127 *ret = prefix;
224 NDiscPrefix *prefix, *p;
238 LIST_FOREACH_SAFE(prefixes, prefix, p, nd->prefixes)
239 prefix = ndisc_prefix_unref(prefix);
280 static int prefix_match(const struct in6_addr *prefix, uint8_t prefixlen,
285 assert_return(prefix, -EINVAL);
293 if (memcmp(prefix, addr, bytes) != 0 ||
294 (prefix->s6_addr[bytes] & mask) != (addr->s6_addr[bytes] & mask))
302 NDiscPrefix *prefix, *p;
312 LIST_FOREACH_SAFE(prefixes, prefix, p, nd->prefixes) {
313 if (prefix->valid_until < time_now) {
314 prefix = ndisc_prefix_unref(prefix);
318 if (prefix_match(&prefix->addr, prefix->len, addr, addr_len) >= 0) {
319 *result = prefix;
329 NDiscPrefix *prefix;
354 prefix_opt->nd_opt_pi_prefix_len, &prefix);
359 /* if router advertisment prefix valid timeout is zero, the timeout
360 callback will be called immediately to clean up the prefix */
362 r = ndisc_prefix_new(nd, &prefix);
366 prefix->len = prefix_opt->nd_opt_pi_prefix_len;
368 memcpy(&prefix->addr, &prefix_opt->nd_opt_pi_prefix,
369 sizeof(prefix->addr));
371 log_ndisc(nd, "New prefix "SD_NDISC_ADDRESS_FORMAT_STR"/%d lifetime %d expires in %s",
372 SD_NDISC_ADDRESS_FORMAT_VAL(prefix->addr),
373 prefix->len, lifetime_valid,
376 LIST_PREPEND(prefixes, nd->prefixes, prefix);
379 if (prefix->len != prefix_opt->nd_opt_pi_prefix_len) {
382 prefixlen = MIN(prefix->len, prefix_opt->nd_opt_pi_prefix_len);
385 prefix->len,
389 prefix->len = prefixlen;
392 log_ndisc(nd, "Update prefix "SD_NDISC_ADDRESS_FORMAT_STR"/%d lifetime %d expires in %s",
393 SD_NDISC_ADDRESS_FORMAT_VAL(prefix->addr),
394 prefix->len, lifetime_valid,
402 prefix->valid_until = time_now + lifetime_valid * USEC_PER_SEC;
405 nd->prefix_onlink_callback(nd, &prefix->addr, prefix->len, prefix->valid_until, nd->userdata);
408 nd->prefix_autonomous_callback(nd, &prefix->addr, prefix->len, lifetime_preferred, lifetime_valid,