summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-29 18:25:53 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-29 18:25:53 +0000
commita33fa65ed226ba6e40fdf51ad96e55670e799f51 (patch)
treed3f5196d0ed8c18817071d35da2adb92ddcdd22e /lib
parent36e031c7ab3edb9a631825a86f7f161f1797307d (diff)
fix alignment constraint in IPv6 routing header manipulation (ancillary data).
documented in RFC2292. from: shin@kame.net
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/rthdr.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c
index 2dff59668eb..5cd485889bd 100644
--- a/lib/libc/net/rthdr.c
+++ b/lib/libc/net/rthdr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthdr.c,v 1.1 1999/12/11 08:09:11 itojun Exp $ */
+/* $OpenBSD: rthdr.c,v 1.2 2000/02/29 18:25:52 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -63,7 +63,9 @@ inet6_rthdr_init(bp, type)
int type;
{
register struct cmsghdr *ch = (struct cmsghdr *)bp;
- register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(ch + 1);
+ register struct ip6_rthdr *rthdr;
+
+ rthdr = (struct ip6_rthdr *)CMSG_DATA(ch);
ch->cmsg_level = IPPROTO_IPV6;
ch->cmsg_type = IPV6_RTHDR;
@@ -88,7 +90,9 @@ inet6_rthdr_add(cmsg, addr, flags)
const struct in6_addr *addr;
u_int flags;
{
- register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1);
+ register struct ip6_rthdr *rthdr;
+
+ rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg);
switch(rthdr->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
@@ -135,7 +139,9 @@ inet6_rthdr_lasthop(cmsg, flags)
struct cmsghdr *cmsg;
unsigned int flags;
{
- register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1);
+ register struct ip6_rthdr *rthdr;
+
+ rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg);
switch(rthdr->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
@@ -189,7 +195,9 @@ int
inet6_rthdr_segments(cmsg)
const struct cmsghdr *cmsg;
{
- register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1);
+ register struct ip6_rthdr *rthdr;
+
+ rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg);
switch(rthdr->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
@@ -221,7 +229,9 @@ inet6_rthdr_getaddr(cmsg, index)
struct cmsghdr *cmsg;
int index;
{
- register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1);
+ register struct ip6_rthdr *rthdr;
+
+ rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg);
switch(rthdr->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
@@ -260,7 +270,9 @@ inet6_rthdr_getflags(cmsg, index)
const struct cmsghdr *cmsg;
int index;
{
- register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1);
+ register struct ip6_rthdr *rthdr;
+
+ rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg);
switch(rthdr->ip6r_type) {
case IPV6_RTHDR_TYPE_0: