diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-06-11 02:54:03 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-06-11 02:54:03 +0000 |
commit | 7f93664b229028f63dd25d327e7dca5392f41ed1 (patch) | |
tree | 6a1660b85d181dcf04c344ff15ce09332ffbbf3a /lib/libc/net/rthdr.c | |
parent | 7ea94b99c24b51b034e1a8f6c7f29fa713eb9c17 (diff) |
- sync up MLD declaration with RFC3542 (s/MLD6/MLD/)
- routing header declaration with RFC3542
(note: sizeof(ip6_rthdr0) has changed!)
also, sync up with RFC2460 routing header definition (no "strict" source
routing mode any more)
part of advanced API update (RFC2292 -> 3542).
markus, todd, millert, henning ok
Diffstat (limited to 'lib/libc/net/rthdr.c')
-rw-r--r-- | lib/libc/net/rthdr.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c index 904d61c8bc8..366ca9e6ba0 100644 --- a/lib/libc/net/rthdr.c +++ b/lib/libc/net/rthdr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthdr.c,v 1.5 2003/06/06 07:27:52 itojun Exp $ */ +/* $OpenBSD: rthdr.c,v 1.6 2003/06/11 02:54:02 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -47,7 +47,7 @@ inet6_rthdr_space(type, seg) case IPV6_RTHDR_TYPE_0: if (seg < 1 || seg > 23) return (0); - return (CMSG_SPACE(sizeof(struct in6_addr) * (seg - 1) + + return (CMSG_SPACE(sizeof(struct in6_addr) * seg + sizeof(struct ip6_rthdr0))); default: return (0); @@ -69,8 +69,7 @@ inet6_rthdr_init(bp, type) switch (type) { case IPV6_RTHDR_TYPE_0: - ch->cmsg_len = CMSG_LEN(sizeof(struct ip6_rthdr0) - - sizeof(struct in6_addr)); + ch->cmsg_len = CMSG_LEN(sizeof(struct ip6_rthdr0)); bzero(rthdr, sizeof(struct ip6_rthdr0)); rthdr->ip6r_type = IPV6_RTHDR_TYPE_0; return (ch); @@ -93,16 +92,10 @@ inet6_rthdr_add(cmsg, addr, flags) case IPV6_RTHDR_TYPE_0: { struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)rthdr; - if (flags != IPV6_RTHDR_LOOSE && flags != IPV6_RTHDR_STRICT) + if (flags != IPV6_RTHDR_LOOSE) return (-1); if (rt0->ip6r0_segleft == 23) return (-1); - if (flags == IPV6_RTHDR_STRICT) { - int c, b; - c = rt0->ip6r0_segleft / 8; - b = rt0->ip6r0_segleft % 8; - rt0->ip6r0_slmap[c] |= (1 << (7 - b)); - } rt0->ip6r0_segleft++; bcopy(addr, (caddr_t)rt0 + ((rt0->ip6r0_len + 1) << 3), sizeof(struct in6_addr)); @@ -130,16 +123,10 @@ inet6_rthdr_lasthop(cmsg, flags) case IPV6_RTHDR_TYPE_0: { struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)rthdr; - if (flags != IPV6_RTHDR_LOOSE && flags != IPV6_RTHDR_STRICT) + if (flags != IPV6_RTHDR_LOOSE) return (-1); if (rt0->ip6r0_segleft > 23) return (-1); - if (flags == IPV6_RTHDR_STRICT) { - int c, b; - c = rt0->ip6r0_segleft / 8; - b = rt0->ip6r0_segleft % 8; - rt0->ip6r0_slmap[c] |= (1 << (7 - b)); - } break; } default: @@ -204,7 +191,7 @@ inet6_rthdr_getaddr(cmsg, index) naddr = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr); if (index <= 0 || naddr < index) return NULL; - return &rt0->ip6r0_addr[index - 1]; + return ((struct in6_addr *)(rt0 + 1)) + index; } default: @@ -232,10 +219,7 @@ inet6_rthdr_getflags(cmsg, index) naddr = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr); if (index < 0 || naddr < index) return (-1); - if (rt0->ip6r0_slmap[index / 8] & (0x80 >> (index % 8))) - return IPV6_RTHDR_STRICT; - else - return IPV6_RTHDR_LOOSE; + return IPV6_RTHDR_LOOSE; } default: |