based on the assigned address.
const uint8_t *p;
struct in6_addr in6;
struct ipv6_addr *a;
- const struct ipv6_addr *pa;
char iabuf[INET6_ADDRSTRLEN];
const char *ia;
int i;
memcpy(&a->addr.s6_addr, &in6.s6_addr,
sizeof(in6.s6_addr));
}
- pa = ipv6nd_findprefix(a);
- if (pa) {
- memcpy(&a->prefix, &pa->prefix,
- sizeof(a->prefix));
- a->prefix_len = pa->prefix_len;
- } else {
- a->prefix_len = 64;
- if (ipv6_makeprefix(&a->prefix, &a->addr, 64) == -1) {
- syslog(LOG_ERR, "%s: %m", __func__);
- free(a);
- continue;
- }
+ /*
+ * RFC 5942 Section 5
+ * We cannot assume any prefix length, nor tie the address
+ * to an existing one as it could expire before the address.
+ * As such we just give it a 128 prefix.
+ */
+ a->prefix_len = 128;
+ if (ipv6_makeprefix(&a->prefix, &a->addr, a->prefix_len) == -1)
+ {
+ syslog(LOG_ERR, "%s: %m", __func__);
+ free(a);
+ continue;
}
memcpy(&u32, p, sizeof(u32));
a->prefix_pltime = ntohl(u32);
RFC\ 951 RFC\ 1534 RFC\ 2131, RFC\ 2132, RFC\ 2855, RFC\ 3004, RFC\ 3315,
RFC\ 3361, RFC\ 3633, RFC\ 3396, RFC\ 3397, RFC\ 3442, RFC\ 3927, RFC\ 4039
RFC\ 4075, RFC\ 4361, RFC\ 4390, RFC\ 4702, RFC\ 4704, RFC\ 4861, RFC\ 4833,
-RFC\ 5227, RFC\ 5969, RFC\ 6106.
+RFC\ 5227, RFC\ 5942, RFC\ 5969, RFC\ 6106.
.Sh AUTHORS
.An Roy Marples Aq Mt roy@marples.name
.Sh BUGS
return l;
}
-const struct ipv6_addr *
-ipv6nd_findprefix(const struct ipv6_addr *a)
-{
- const struct ra *rap;
- const struct ipv6_addr *ap;
- const struct in6_addr *p1, *p2;
- int bytelen, bitlen;
-
- p1 = &a->addr;
- TAILQ_FOREACH(rap, &ipv6_routers, next) {
- TAILQ_FOREACH(ap, &rap->addrs, next) {
- p2 = & ap->prefix;
- bytelen = ap->prefix_len / NBBY;
- bitlen = ap->prefix_len % NBBY;
- if (memcmp(&p1->s6_addr, &p2->s6_addr, bytelen))
- continue;
- if (bitlen != 0) {
- bitlen = NBBY - bitlen;
- if (p1->s6_addr[bytelen] >> bitlen !=
- p2->s6_addr[bytelen] >> bitlen)
- continue;
- }
- return ap;
- }
- }
- return NULL;
-}
-
void
ipv6nd_handleifa(int cmd, const char *ifname,
const struct in6_addr *addr, int flags)
#ifdef INET6
int ipv6nd_startrs(struct interface *);
ssize_t ipv6nd_env(char **, const char *, const struct interface *);
-const struct ipv6_addr * ipv6nd_findprefix(const struct ipv6_addr *);
int ipv6nd_addrexists(const struct ipv6_addr *);
void ipv6nd_freedrop_ra(struct ra *, int);
#define ipv6nd_free_ra(ra) ipv6nd_freedrop_ra((ra), 0)