summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2013-05-31 15:04:23 +0000
committerbluhm <bluhm@openbsd.org>2013-05-31 15:04:23 +0000
commitc3c564961c0dd99b8d90e5661db2d29823d78ec0 (patch)
tree44a7d669d22007fa698a8d8e9374d3046a4afd17
parentUnbreak after recent shutdown-hook removal. (diff)
downloadwireguard-openbsd-c3c564961c0dd99b8d90e5661db2d29823d78ec0.tar.xz
wireguard-openbsd-c3c564961c0dd99b8d90e5661db2d29823d78ec0.zip
Remove a bunch of sockaddr_in6 pointer casts and replace others
with sin6tosa() or satosin6() inline functions. This allows the compiler to check the types more strictly. OK mpi@
-rw-r--r--sys/netinet6/frag6.c4
-rw-r--r--sys/netinet6/icmp6.c33
-rw-r--r--sys/netinet6/in6.c44
-rw-r--r--sys/netinet6/in6_gif.c8
-rw-r--r--sys/netinet6/in6_ifattach.c4
-rw-r--r--sys/netinet6/in6_pcb.c6
-rw-r--r--sys/netinet6/in6_src.c11
-rw-r--r--sys/netinet6/ip6_divert.c8
-rw-r--r--sys/netinet6/ip6_forward.c6
-rw-r--r--sys/netinet6/ip6_mroute.c13
-rw-r--r--sys/netinet6/ip6_output.c20
-rw-r--r--sys/netinet6/nd6.c45
-rw-r--r--sys/netinet6/nd6_nbr.c9
-rw-r--r--sys/netinet6/nd6_rtr.c32
-rw-r--r--sys/netinet6/raw_ip6.c8
15 files changed, 113 insertions, 138 deletions
diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c
index a506078c95f..982fd4976fe 100644
--- a/sys/netinet6/frag6.c
+++ b/sys/netinet6/frag6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frag6.c,v 1.45 2013/03/22 01:41:12 tedu Exp $ */
+/* $OpenBSD: frag6.c,v 1.46 2013/05/31 15:04:23 bluhm Exp $ */
/* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */
/*
@@ -189,7 +189,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
#ifdef IN6_IFSTAT_STRICT
/* find the destination interface of the packet. */
bzero(&ro, sizeof(ro));
- dst = (struct sockaddr_in6 *)&ro.ro_dst;
+ dst = &ro.ro_dst;
dst->sin6_family = AF_INET6;
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_addr = ip6->ip6_dst;
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 163f8305573..99d76239011 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.126 2013/04/24 10:17:08 mpi Exp $ */
+/* $OpenBSD: icmp6.c,v 1.127 2013/05/31 15:04:23 bluhm Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -1064,10 +1064,8 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
ctlfunc = (void (*)(int, struct sockaddr *, void *))
(inet6sw[ip6_protox[nxt]].pr_ctlinput);
- if (ctlfunc) {
- (void) (*ctlfunc)(code, (struct sockaddr *)&icmp6dst,
- &ip6cp);
- }
+ if (ctlfunc)
+ (void) (*ctlfunc)(code, sin6tosa(&icmp6dst), &ip6cp);
}
return (0);
@@ -1124,7 +1122,7 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
htons(m->m_pkthdr.rcvif->if_index);
}
/* sin6.sin6_scope_id = XXX: should be set if DST is a scoped addr */
- rt = icmp6_mtudisc_clone((struct sockaddr *)&sin6, m->m_pkthdr.rdomain);
+ rt = icmp6_mtudisc_clone(sin6tosa(&sin6), m->m_pkthdr.rdomain);
if (rt && (rt->rt_flags & RTF_HOST) &&
!(rt->rt_rmx.rmx_locks & RTV_MTU) &&
@@ -1194,7 +1192,7 @@ ni6_input(struct mbuf *m, int off)
sin6.sin6_len = sizeof(struct sockaddr_in6);
bcopy(&ip6->ip6_dst, &sin6.sin6_addr, sizeof(sin6.sin6_addr));
/* XXX scopeid */
- if (ifa_ifwithaddr((struct sockaddr *)&sin6, m->m_pkthdr.rdomain))
+ if (ifa_ifwithaddr(sin6tosa(&sin6), m->m_pkthdr.rdomain))
; /* unicast/anycast, fine */
else if (IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr))
; /* link-local multicast, fine */
@@ -1904,8 +1902,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
/* strip intermediate headers */
m_adj(n, off);
if (sbappendaddr(&last->in6p_socket->so_rcv,
- (struct sockaddr *)&rip6src,
- n, opts) == 0) {
+ sin6tosa(&rip6src), n, opts) == 0) {
/* should notify about lost packet */
m_freem(n);
if (opts)
@@ -1923,8 +1920,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
/* strip intermediate headers */
m_adj(m, off);
if (sbappendaddr(&last->in6p_socket->so_rcv,
- (struct sockaddr *)&rip6src,
- m, opts) == 0) {
+ sin6tosa(&rip6src), m, opts) == 0) {
m_freem(m);
if (opts)
m_freem(opts);
@@ -2209,7 +2205,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
sin6.sin6_family = AF_INET6;
sin6.sin6_len = sizeof(struct sockaddr_in6);
bcopy(&reddst6, &sin6.sin6_addr, sizeof(reddst6));
- rt = rtalloc1((struct sockaddr *)&sin6, 0, m->m_pkthdr.rdomain);
+ rt = rtalloc1(sin6tosa(&sin6), 0, m->m_pkthdr.rdomain);
if (rt) {
if (rt->rt_gateway == NULL ||
rt->rt_gateway->sa_family != AF_INET6) {
@@ -2221,7 +2217,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
goto bad;
}
- gw6 = &(((struct sockaddr_in6 *)rt->rt_gateway)->sin6_addr);
+ gw6 = &(satosin6(rt->rt_gateway)->sin6_addr);
if (bcmp(&src6, gw6, sizeof(struct in6_addr)) != 0) {
nd6log((LOG_ERR,
"ICMP6 redirect rejected; "
@@ -2318,10 +2314,9 @@ icmp6_redirect_input(struct mbuf *m, int off)
bcopy(&redtgt6, &sgw.sin6_addr, sizeof(struct in6_addr));
bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr));
bcopy(&src6, &ssrc.sin6_addr, sizeof(struct in6_addr));
- rtredirect((struct sockaddr *)&sdst, (struct sockaddr *)&sgw,
- (struct sockaddr *)NULL, RTF_GATEWAY | RTF_HOST,
- (struct sockaddr *)&ssrc,
- &newrt, /* XXX */ 0);
+ rtredirect(sin6tosa(&sdst), sin6tosa(&sgw), NULL,
+ RTF_GATEWAY | RTF_HOST, sin6tosa(&ssrc),
+ &newrt, /* XXX */ 0);
if (newrt) {
(void)rt_timer_add(newrt, icmp6_redirect_timeout,
@@ -2337,7 +2332,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
sdst.sin6_family = AF_INET6;
sdst.sin6_len = sizeof(struct sockaddr_in6);
bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr));
- pfctlinput(PRC_REDIRECT_HOST, (struct sockaddr *)&sdst);
+ pfctlinput(PRC_REDIRECT_HOST, sin6tosa(&sdst));
}
freeit:
@@ -2431,7 +2426,7 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
/* get ip6 linklocal address for the router. */
if (rt->rt_gateway && (rt->rt_flags & RTF_GATEWAY)) {
struct sockaddr_in6 *sin6;
- sin6 = (struct sockaddr_in6 *)rt->rt_gateway;
+ sin6 = satosin6(rt->rt_gateway);
nexthop = &sin6->sin6_addr;
if (!IN6_IS_ADDR_LINKLOCAL(nexthop))
nexthop = NULL;
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 17f7253ceb7..f2e4b41730e 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6.c,v 1.111 2013/05/30 15:23:38 claudio Exp $ */
+/* $OpenBSD: in6.c,v 1.112 2013/05/31 15:04:23 bluhm Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@@ -175,7 +175,7 @@ in6_ifloop_request(int cmd, struct ifaddr *ifa)
info.rti_info[RTAX_DST] = ifa->ifa_addr;
if (cmd != RTM_DELETE)
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&all1_sa;
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&all1_sa);
e = rtrequest1(cmd, &info, RTP_CONNECTED, &nrt,
ifa->ifa_ifp->if_rdomain);
if (e != 0) {
@@ -885,7 +885,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
ia = malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO);
LIST_INIT(&ia->ia6_memberships);
/* Initialize the address and masks, and put time stamp */
- ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
+ ia->ia_ifa.ifa_addr = sin6tosa(&ia->ia_addr);
ia->ia_addr.sin6_family = AF_INET6;
ia->ia_addr.sin6_len = sizeof(ia->ia_addr);
ia->ia6_createtime = ia->ia6_updatetime = time_second;
@@ -894,13 +894,11 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
* XXX: some functions expect that ifa_dstaddr is not
* NULL for p2p interfaces.
*/
- ia->ia_ifa.ifa_dstaddr =
- (struct sockaddr *)&ia->ia_dstaddr;
+ ia->ia_ifa.ifa_dstaddr = sin6tosa(&ia->ia_dstaddr);
} else {
ia->ia_ifa.ifa_dstaddr = NULL;
}
- ia->ia_ifa.ifa_netmask =
- (struct sockaddr *)&ia->ia_prefixmask;
+ ia->ia_ifa.ifa_netmask = sin6tosa(&ia->ia_prefixmask);
ia->ia_ifp = ifp;
TAILQ_INSERT_TAIL(&in6_ifaddr, ia, ia_list);
@@ -1048,13 +1046,13 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
* actually do not need the routes, since they usually specify
* the outgoing interface.
*/
- rt = rtalloc1((struct sockaddr *)&mltaddr, 0, ifp->if_rdomain);
+ rt = rtalloc1(sin6tosa(&mltaddr), 0, ifp->if_rdomain);
if (rt) {
/*
* 32bit came from "mltmask"
*/
if (memcmp(&mltaddr.sin6_addr,
- &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
+ &satosin6(rt_key(rt))->sin6_addr,
32 / 8)) {
RTFREE(rt);
rt = NULL;
@@ -1064,13 +1062,10 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
struct rt_addrinfo info;
bzero(&info, sizeof(info));
- info.rti_info[RTAX_DST] = (struct sockaddr *)&mltaddr;
- info.rti_info[RTAX_GATEWAY] =
- (struct sockaddr *)&ia->ia_addr;
- info.rti_info[RTAX_NETMASK] =
- (struct sockaddr *)&mltmask;
- info.rti_info[RTAX_IFA] =
- (struct sockaddr *)&ia->ia_addr;
+ info.rti_info[RTAX_DST] = sin6tosa(&mltaddr);
+ info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia->ia_addr);
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&mltmask);
+ info.rti_info[RTAX_IFA] = sin6tosa(&ia->ia_addr);
/* XXX: we need RTF_CLONING to fake nd6_rtrequest */
info.rti_flags = RTF_UP | RTF_CLONING;
error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, NULL,
@@ -1120,11 +1115,11 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
mltaddr.sin6_scope_id = 0;
/* XXX: again, do we really need the route? */
- rt = rtalloc1((struct sockaddr *)&mltaddr, 0, ifp->if_rdomain);
+ rt = rtalloc1(sin6tosa(&mltaddr), 0, ifp->if_rdomain);
if (rt) {
/* 32bit came from "mltmask" */
if (memcmp(&mltaddr.sin6_addr,
- &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
+ &satosin6(rt_key(rt))->sin6_addr,
32 / 8)) {
RTFREE(rt);
rt = NULL;
@@ -1134,13 +1129,10 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
struct rt_addrinfo info;
bzero(&info, sizeof(info));
- info.rti_info[RTAX_DST] = (struct sockaddr *)&mltaddr;
- info.rti_info[RTAX_GATEWAY] =
- (struct sockaddr *)&ia->ia_addr;
- info.rti_info[RTAX_NETMASK] =
- (struct sockaddr *)&mltmask;
- info.rti_info[RTAX_IFA] =
- (struct sockaddr *)&ia->ia_addr;
+ info.rti_info[RTAX_DST] = sin6tosa(&mltaddr);
+ info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia->ia_addr);
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&mltmask);
+ info.rti_info[RTAX_IFA] = sin6tosa(&ia->ia_addr);
info.rti_flags = RTF_UP | RTF_CLONING;
error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED,
NULL, ifp->if_rdomain);
@@ -1885,7 +1877,7 @@ in6_ifpprefix(const struct ifnet *ifp, const struct in6_addr *addr)
dst.sin6_len = sizeof(struct sockaddr_in6);
dst.sin6_family = AF_INET6;
dst.sin6_addr = *addr;
- rt = rtalloc1((struct sockaddr *)&dst, RT_NOCLONING, tableid);
+ rt = rtalloc1(sin6tosa(&dst), RT_NOCLONING, tableid);
if (rt == NULL)
return (0);
diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c
index 2078021ceab..b3ca430538e 100644
--- a/sys/netinet6/in6_gif.c
+++ b/sys/netinet6/in6_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_gif.c,v 1.30 2011/04/03 13:54:21 stsp Exp $ */
+/* $OpenBSD: in6_gif.c,v 1.31 2013/05/31 15:04:23 bluhm Exp $ */
/* $KAME: in6_gif.c,v 1.43 2001/01/22 07:27:17 itojun Exp $ */
/*
@@ -76,8 +76,8 @@ int
in6_gif_output(struct ifnet *ifp, int family, struct mbuf **m0)
{
struct gif_softc *sc = (struct gif_softc*)ifp;
- struct sockaddr_in6 *sin6_src = (struct sockaddr_in6 *)sc->gif_psrc;
- struct sockaddr_in6 *sin6_dst = (struct sockaddr_in6 *)sc->gif_pdst;
+ struct sockaddr_in6 *sin6_src = satosin6(sc->gif_psrc);
+ struct sockaddr_in6 *sin6_dst = satosin6(sc->gif_pdst);
struct tdb tdb;
struct xformsw xfs;
int error;
@@ -167,7 +167,7 @@ int in6_gif_input(struct mbuf **mp, int *offp, int proto)
ip6 = mtod(m, struct ip6_hdr *);
-#define satoin6(sa) (((struct sockaddr_in6 *)(sa))->sin6_addr)
+#define satoin6(sa) (satosin6(sa)->sin6_addr)
LIST_FOREACH(sc, &gif_softc_list, gif_list) {
if (sc->gif_psrc == NULL || sc->gif_pdst == NULL ||
sc->gif_psrc->sa_family != AF_INET6 ||
diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 90e2df4e641..8982b1dddf9 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_ifattach.c,v 1.60 2013/03/26 00:14:18 bluhm Exp $ */
+/* $OpenBSD: in6_ifattach.c,v 1.61 2013/05/31 15:04:23 bluhm Exp $ */
/* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */
/*
@@ -691,7 +691,7 @@ in6_ifdetach(struct ifnet *ifp)
sin6.sin6_family = AF_INET6;
sin6.sin6_addr = in6addr_linklocal_allnodes;
sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
- rt = rtalloc1((struct sockaddr *)&sin6, 0, ifp->if_rdomain);
+ rt = rtalloc1(sin6tosa(&sin6), 0, ifp->if_rdomain);
if (rt && rt->rt_ifp == ifp) {
struct rt_addrinfo info;
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 7d283bc92ff..14828324d45 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_pcb.c,v 1.55 2013/05/31 13:15:53 bluhm Exp $ */
+/* $OpenBSD: in6_pcb.c,v 1.56 2013/05/31 15:04:24 bluhm Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -228,7 +228,7 @@ in6_pcbbind(struct inpcb *inp, struct mbuf *nam, struct proc *p)
*/
sin6->sin6_flowinfo = 0;
if (!(so->so_options & SO_BINDANY) &&
- (ia = ifa_ifwithaddr((struct sockaddr *)sin6,
+ (ia = ifa_ifwithaddr(sin6tosa(sin6),
inp->inp_rtableid)) == NULL)
return EADDRNOTAVAIL;
@@ -569,7 +569,7 @@ in6_pcbnotify(struct inpcbtable *head, struct sockaddr_in6 *dst,
!(inp->inp_route.ro_rt->rt_flags & RTF_HOST)) {
struct sockaddr_in6 *dst6;
- dst6 = (struct sockaddr_in6 *)&inp->inp_route.ro_dst;
+ dst6 = satosin6(&inp->inp_route.ro_dst);
if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr,
&dst->sin6_addr))
goto do_notify;
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index e604e902001..ef889d92628 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_src.c,v 1.31 2013/03/28 16:45:16 tedu Exp $ */
+/* $OpenBSD: in6_src.c,v 1.32 2013/05/31 15:04:24 bluhm Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@@ -133,8 +133,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
if (ifp && IN6_IS_SCOPE_EMBED(&sa6.sin6_addr))
sa6.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
- ia6 = ifatoia6(
- ifa_ifwithaddr((struct sockaddr *)&sa6, rtableid));
+ ia6 = ifatoia6(ifa_ifwithaddr(sin6tosa(&sa6), rtableid));
if (ia6 == NULL ||
(ia6->ia6_flags & (IN6_IFF_ANYCAST | IN6_IFF_NOTREADY))) {
*errorp = EADDRNOTAVAIL;
@@ -261,7 +260,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
/* No route yet, so try to acquire one */
bzero(&ro->ro_dst, sizeof(struct sockaddr_in6));
- sa6 = (struct sockaddr_in6 *)&ro->ro_dst;
+ sa6 = &ro->ro_dst;
sa6->sin6_family = AF_INET6;
sa6->sin6_len = sizeof(struct sockaddr_in6);
sa6->sin6_addr = *dst;
@@ -437,7 +436,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
if (ro) {
if (ro->ro_rt &&
(!(ro->ro_rt->rt_flags & RTF_UP) ||
- ((struct sockaddr *)(&ro->ro_dst))->sa_family != AF_INET6 ||
+ sin6tosa(&ro->ro_dst)->sa_family != AF_INET6 ||
!IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst))) {
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)NULL;
@@ -447,7 +446,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
/* No route yet, so try to acquire one */
bzero(&ro->ro_dst, sizeof(struct sockaddr_in6));
- sa6 = (struct sockaddr_in6 *)&ro->ro_dst;
+ sa6 = &ro->ro_dst;
*sa6 = *dstsock;
sa6->sin6_scope_id = 0;
ro->ro_tableid = rtableid;
diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c
index c96205516bf..0caa0ce92ef 100644
--- a/sys/netinet6/ip6_divert.c
+++ b/sys/netinet6/ip6_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.c,v 1.11 2013/04/08 15:32:23 lteo Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.12 2013/05/31 15:04:24 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -242,16 +242,14 @@ divert6_packet(struct mbuf *m, int dir)
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
- addr.sin6_addr = ((struct sockaddr_in6 *)
- ifa->ifa_addr)->sin6_addr;
+ addr.sin6_addr = satosin6(ifa->ifa_addr)->sin6_addr;
break;
}
}
if (inp != CIRCLEQ_END(&divb6table.inpt_queue)) {
sa = inp->inp_socket;
- if (sbappendaddr(&sa->so_rcv, (struct sockaddr *)&addr,
- m, NULL) == 0) {
+ if (sbappendaddr(&sa->so_rcv, sin6tosa(&addr), m, NULL) == 0) {
div6stat.divs_fullsock++;
m_freem(m);
return (0);
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index caa67d3099d..60ab8caab96 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_forward.c,v 1.57 2012/11/06 12:32:42 henning Exp $ */
+/* $OpenBSD: ip6_forward.c,v 1.58 2013/05/31 15:04:24 bluhm Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
@@ -382,7 +382,7 @@ reroute:
#endif /* IPSEC */
if (rt->rt_flags & RTF_GATEWAY)
- dst = (struct sockaddr_in6 *)rt->rt_gateway;
+ dst = satosin6(rt->rt_gateway);
/*
* If we are to forward the packet using the same interface
@@ -396,7 +396,7 @@ reroute:
if (rt->rt_ifp == m->m_pkthdr.rcvif && !srcrt && ip6_sendredirects &&
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0) {
if ((rt->rt_ifp->if_flags & IFF_POINTOPOINT) &&
- nd6_is_addr_neighbor((struct sockaddr_in6 *)&ip6_forward_rt.ro_dst, rt->rt_ifp)) {
+ nd6_is_addr_neighbor(&ip6_forward_rt.ro_dst, rt->rt_ifp)) {
/*
* If the incoming interface is equal to the outgoing
* one, the link attached to the interface is
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index f386278cc03..117b824f261 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -941,9 +941,7 @@ int
socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in6 *src)
{
if (s) {
- if (sbappendaddr(&s->so_rcv,
- (struct sockaddr *)src,
- mm, (struct mbuf *)0) != 0) {
+ if (sbappendaddr(&s->so_rcv, sin6tosa(src), mm, NULL) != 0) {
sorwakeup(s);
return 0;
}
@@ -1515,13 +1513,13 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
* If we belong to the destination multicast group
* on the outgoing interface, loop back a copy.
*/
- dst6 = (struct sockaddr_in6 *)&ro.ro_dst;
+ dst6 = &ro.ro_dst;
IN6_LOOKUP_MULTI(ip6->ip6_dst, ifp, in6m);
if (in6m != NULL) {
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_family = AF_INET6;
dst6->sin6_addr = ip6->ip6_dst;
- ip6_mloopback(ifp, m, (struct sockaddr_in6 *)&ro.ro_dst);
+ ip6_mloopback(ifp, m, &ro.ro_dst);
}
/*
* Put the packet into the sending queue of the outgoing interface
@@ -1537,7 +1535,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
* we need no ND for a multicast forwarded packet...right?
*/
error = (*ifp->if_output)(ifp, mb_copy,
- (struct sockaddr *)&ro.ro_dst, NULL);
+ sin6tosa(&ro.ro_dst), NULL);
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_XMIT)
log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
@@ -1835,8 +1833,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
#endif
looutput(mif6table[reg_mif_num].m6_ifp, m,
- (struct sockaddr *) &dst,
- (struct rtentry *) NULL);
+ sin6tosa(&dst), NULL);
/* prepare the register head to send to the mrouting daemon */
m = mcp;
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index d77c6b8aac5..6cc8f2ec004 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.139 2013/04/11 12:06:25 mpi Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.140 2013/05/31 15:04:24 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -461,7 +461,7 @@ reroute:
ro_pmtu = ro;
if (opt && opt->ip6po_rthdr)
ro = &opt->ip6po_route;
- dst = (struct sockaddr_in6 *)&ro->ro_dst;
+ dst = &ro->ro_dst;
/*
* if specified, try to fill in the traffic class field.
@@ -606,9 +606,9 @@ reroute:
* application. We assume the next hop is an IPv6
* address.
*/
- dst = (struct sockaddr_in6 *)opt->ip6po_nexthop;
+ dst = satosin6(opt->ip6po_nexthop);
} else if ((rt->rt_flags & RTF_GATEWAY))
- dst = (struct sockaddr_in6 *)rt->rt_gateway;
+ dst = satosin6(rt->rt_gateway);
}
if (!IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
@@ -855,7 +855,7 @@ reroute:
mtu32 = (u_int32_t)mtu;
bzero(&ip6cp, sizeof(ip6cp));
ip6cp.ip6c_cmdarg = (void *)&mtu32;
- pfctlinput2(PRC_MSGSIZE, (struct sockaddr *)&ro_pmtu->ro_dst,
+ pfctlinput2(PRC_MSGSIZE, sin6tosa(&ro_pmtu->ro_dst),
(void *)&ip6cp);
#endif
@@ -905,7 +905,7 @@ reroute:
mtu32 = (u_int32_t)mtu;
bzero(&ip6cp, sizeof(ip6cp));
ip6cp.ip6c_cmdarg = (void *)&mtu32;
- pfctlinput2(PRC_MSGSIZE, (struct sockaddr *)&ro_pmtu->ro_dst,
+ pfctlinput2(PRC_MSGSIZE, sin6tosa(&ro_pmtu->ro_dst),
(void *)&ip6cp);
#endif
@@ -1220,8 +1220,8 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro,
if (ro_pmtu != ro) {
/* The first hop and the final destination may differ. */
- struct sockaddr_in6 *sa6_dst =
- (struct sockaddr_in6 *)&ro_pmtu->ro_dst;
+ struct sockaddr_in6 *sa6_dst = &ro_pmtu->ro_dst;
+
if (ro_pmtu->ro_rt &&
((ro_pmtu->ro_rt->rt_flags & RTF_UP) == 0 ||
!IN6_ARE_ADDR_EQUAL(&sa6_dst->sin6_addr, dst))) {
@@ -2458,7 +2458,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m)
* XXX: is it a good approach?
*/
bzero(&ro, sizeof(ro));
- dst = (struct sockaddr_in6 *)&ro.ro_dst;
+ dst = &ro.ro_dst;
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_family = AF_INET6;
dst->sin6_addr = mreq->ipv6mr_multiaddr;
@@ -3139,7 +3139,7 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst)
if (IN6_IS_SCOPE_EMBED(&ip6->ip6_dst))
ip6->ip6_dst.s6_addr16[1] = 0;
- (void)looutput(ifp, copym, (struct sockaddr *)dst, NULL);
+ (void)looutput(ifp, copym, sin6tosa(dst), NULL);
}
/*
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 5b7af801348..732dd7d2be3 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.98 2013/04/10 08:50:59 mpi Exp $ */
+/* $OpenBSD: nd6.c,v 1.99 2013/05/31 15:04:24 bluhm Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -65,7 +65,6 @@
#define ND6_SLOWTIMER_INTERVAL (60 * 60) /* 1 hour */
#define ND6_RECALC_REACHTM_INTERVAL (60 * 120) /* 2 hours */
-#define SIN6(s) ((struct sockaddr_in6 *)s)
#define SDL(s) ((struct sockaddr_dl *)s)
/* timer values */
@@ -414,7 +413,7 @@ nd6_llinfo_timer(void *arg)
if ((ifp = rt->rt_ifp) == NULL)
panic("ln->ln_rt->rt_ifp == NULL");
ndi = ND_IFINFO(ifp);
- dst = (struct sockaddr_in6 *)rt_key(rt);
+ dst = satosin6(rt_key(rt));
/* sanity check */
if (rt->rt_llinfo && (struct llinfo_nd6 *)rt->rt_llinfo != ln)
@@ -653,7 +652,7 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
sin6.sin6_family = AF_INET6;
sin6.sin6_addr = *addr6;
- rt = rtalloc1((struct sockaddr *)&sin6, create, ifp->if_rdomain);
+ rt = rtalloc1(sin6tosa(&sin6), create, ifp->if_rdomain);
if (rt && (rt->rt_flags & RTF_LLINFO) == 0) {
/*
* This is the case for the default route.
@@ -679,7 +678,7 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
* be covered by our own prefix.
*/
struct ifaddr *ifa =
- ifaof_ifpforaddr((struct sockaddr *)&sin6, ifp);
+ ifaof_ifpforaddr(sin6tosa(&sin6), ifp);
if (ifa == NULL)
return (NULL);
@@ -692,10 +691,9 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
bzero(&info, sizeof(info));
info.rti_flags = (ifa->ifa_flags | RTF_HOST |
RTF_LLINFO) & ~RTF_CLONING;
- info.rti_info[RTAX_DST] = (struct sockaddr *)&sin6;
+ info.rti_info[RTAX_DST] = sin6tosa(&sin6);
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_NETMASK] =
- (struct sockaddr *)&all1_sa;
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&all1_sa);
if ((e = rtrequest1(RTM_ADD, &info, RTP_CONNECTED,
&rt, ifp->if_rdomain)) != 0) {
#if 0
@@ -800,7 +798,7 @@ nd6_free(struct rtentry *rt, int gc)
{
struct rt_addrinfo info;
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next;
- struct in6_addr in6 = ((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
+ struct in6_addr in6 = satosin6(rt_key(rt))->sin6_addr;
struct nd_defrouter *dr;
/*
@@ -811,7 +809,7 @@ nd6_free(struct rtentry *rt, int gc)
if (!ip6_forwarding) {
int s;
s = splsoftnet();
- dr = defrouter_lookup(&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
+ dr = defrouter_lookup(&satosin6(rt_key(rt))->sin6_addr,
rt->rt_ifp);
if (dr != NULL && dr->expire &&
@@ -969,7 +967,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
&in6addr_any) && rt_mask(rt) && (rt_mask(rt)->sa_len == 0 ||
IN6_ARE_ADDR_EQUAL(&(satosin6(rt_mask(rt)))->sin6_addr,
&in6addr_any)))) {
- dr = defrouter_lookup(&SIN6(gate)->sin6_addr, ifp);
+ dr = defrouter_lookup(&satosin6(gate)->sin6_addr, ifp);
if (dr)
dr->installed = 0;
}
@@ -1056,8 +1054,8 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
/* XXX it does not work */
if (rt->rt_flags & RTF_ANNOUNCE)
nd6_na_output(ifp,
- &SIN6(rt_key(rt))->sin6_addr,
- &SIN6(rt_key(rt))->sin6_addr,
+ &satosin6(rt_key(rt))->sin6_addr,
+ &satosin6(rt_key(rt))->sin6_addr,
ip6_forwarding ? ND_NA_FLAG_ROUTER : 0,
1, NULL);
#endif
@@ -1152,7 +1150,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
* to the interface.
*/
ifa = &in6ifa_ifpwithaddr(rt->rt_ifp,
- &SIN6(rt_key(rt))->sin6_addr)->ia_ifa;
+ &satosin6(rt_key(rt))->sin6_addr)->ia_ifa;
if (ifa) {
caddr_t macp = nd6_ifptomac(ifp);
nd6_llinfo_settimer(ln, -1);
@@ -1188,7 +1186,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
struct in6_addr llsol;
int error;
- llsol = SIN6(rt_key(rt))->sin6_addr;
+ llsol = satosin6(rt_key(rt))->sin6_addr;
llsol.s6_addr16[0] = htons(0xff02);
llsol.s6_addr16[1] = htons(ifp->if_index);
llsol.s6_addr32[1] = 0;
@@ -1213,7 +1211,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
struct in6_addr llsol;
struct in6_multi *in6m;
- llsol = SIN6(rt_key(rt))->sin6_addr;
+ llsol = satosin6(rt_key(rt))->sin6_addr;
llsol.s6_addr16[0] = htons(0xff02);
llsol.s6_addr16[1] = htons(ifp->if_index);
llsol.s6_addr32[1] = 0;
@@ -1584,7 +1582,7 @@ fail:
* set the 2nd argument as the 1st one.
*/
nd6_output(ifp, ifp, n,
- (struct sockaddr_in6 *)rt_key(rt), rt);
+ satosin6(rt_key(rt)), rt);
if (ln->ln_hold == n) {
/* n is back in ln_hold. Discard. */
m_freem(ln->ln_hold);
@@ -1734,7 +1732,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
*/
if (rt) {
if ((rt->rt_flags & RTF_UP) == 0) {
- if ((rt0 = rt = rtalloc1((struct sockaddr *)dst,
+ if ((rt0 = rt = rtalloc1(sin6tosa(dst),
RT_REPORT, m->m_pkthdr.rdomain)) != NULL)
{
rt->rt_refcnt--;
@@ -1745,7 +1743,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
}
if (rt->rt_flags & RTF_GATEWAY) {
- gw6 = (struct sockaddr_in6 *)rt->rt_gateway;
+ gw6 = satosin6(rt->rt_gateway);
/*
* We skip link-layer address resolution and NUD
@@ -1889,8 +1887,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
goto bad;
}
#endif /* IPSEC */
- return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst,
- rt));
+ return ((*ifp->if_output)(origifp, m, sin6tosa(dst), rt));
}
#ifdef IPSEC
if (mtag != NULL) {
@@ -1900,7 +1897,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
goto bad;
}
#endif /* IPSEC */
- return ((*ifp->if_output)(ifp, m, (struct sockaddr *)dst, rt));
+ return ((*ifp->if_output)(ifp, m, sin6tosa(dst), rt));
bad:
if (m)
@@ -1944,7 +1941,7 @@ nd6_storelladdr(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
switch (ifp->if_type) {
case IFT_ETHER:
case IFT_FDDI:
- ETHER_MAP_IPV6_MULTICAST(&SIN6(dst)->sin6_addr,
+ ETHER_MAP_IPV6_MULTICAST(&satosin6(dst)->sin6_addr,
desten);
return (1);
break;
@@ -1968,7 +1965,7 @@ nd6_storelladdr(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
if (sdl->sdl_alen == 0) {
/* this should be impossible, but we bark here for debugging */
printf("nd6_storelladdr: sdl_alen == 0, dst=%s, if=%s\n",
- ip6_sprintf(&SIN6(dst)->sin6_addr), ifp->if_xname);
+ ip6_sprintf(&satosin6(dst)->sin6_addr), ifp->if_xname);
m_freem(m);
return (0);
}
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 16b771588bb..c0a3d2e8e17 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_nbr.c,v 1.66 2013/03/07 09:03:16 mpi Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.67 2013/05/31 15:04:24 bluhm Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -217,8 +217,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
tsin6.sin6_family = AF_INET6;
tsin6.sin6_addr = taddr6;
- rt = rtalloc1((struct sockaddr *)&tsin6, 0,
- m->m_pkthdr.rdomain);
+ rt = rtalloc1(sin6tosa(&tsin6), 0, m->m_pkthdr.rdomain);
if (rt && (rt->rt_flags & RTF_ANNOUNCE) != 0 &&
rt->rt_gateway->sa_family == AF_LINK) {
/*
@@ -801,7 +800,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
struct in6_addr *in6;
int s;
- in6 = &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
+ in6 = &satosin6(rt_key(rt))->sin6_addr;
/*
* Lock to protect the default router list.
@@ -836,7 +835,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
* we assume ifp is not a loopback here, so just set the 2nd
* argument as the 1st one.
*/
- nd6_output(ifp, ifp, n, (struct sockaddr_in6 *)rt_key(rt), rt);
+ nd6_output(ifp, ifp, n, satosin6(rt_key(rt)), rt);
if (ln->ln_hold == n) {
/* n is back in ln_hold. Discard. */
m_freem(ln->ln_hold);
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index a5cd36f1a19..00e6f136a3a 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.69 2013/03/25 14:40:57 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.70 2013/05/31 15:04:25 bluhm Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -101,8 +101,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
char *lladdr = NULL;
int lladdrlen = 0;
#if 0
- struct sockaddr_dl *sdl = (struct sockaddr_dl *)NULL;
- struct llinfo_nd6 *ln = (struct llinfo_nd6 *)NULL;
+ struct sockaddr_dl *sdl = NULL;
+ struct llinfo_nd6 *ln = NULL;
struct rtentry *rt = NULL;
int is_newentry;
#endif
@@ -451,9 +451,9 @@ defrouter_addreq(struct nd_defrouter *new)
gate.sin6_scope_id = 0; /* XXX */
info.rti_flags = RTF_GATEWAY;
- info.rti_info[RTAX_DST] = (struct sockaddr *)&def;
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&gate;
- info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask;
+ info.rti_info[RTAX_DST] = sin6tosa(&def);
+ info.rti_info[RTAX_GATEWAY] = sin6tosa(&gate);
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&mask);
s = splsoftnet();
error = rtrequest1(RTM_ADD, &info, RTP_DEFAULT, &newrt,
@@ -556,9 +556,9 @@ defrouter_delreq(struct nd_defrouter *dr)
gw.sin6_scope_id = 0; /* XXX */
info.rti_flags = RTF_GATEWAY;
- info.rti_info[RTAX_DST] = (struct sockaddr *)&def;
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&gw;
- info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask;
+ info.rti_info[RTAX_DST] = sin6tosa(&def);
+ info.rti_info[RTAX_GATEWAY] = sin6tosa(&gw);
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&mask);
rtrequest1(RTM_DELETE, &info, RTP_DEFAULT, &oldrt,
dr->ifp->if_rdomain);
@@ -1637,9 +1637,9 @@ nd6_prefix_onlink(struct nd_prefix *pr)
bzero(&info, sizeof(info));
info.rti_flags = rtflags;
- info.rti_info[RTAX_DST] = (struct sockaddr *)&pr->ndpr_prefix;
+ info.rti_info[RTAX_DST] = sin6tosa(&pr->ndpr_prefix);
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask6;
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&mask6);
error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, &rt, ifp->if_rdomain);
if (error == 0) {
@@ -1652,7 +1652,7 @@ nd6_prefix_onlink(struct nd_prefix *pr)
"errno = %d\n",
ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
pr->ndpr_plen, ifp->if_xname,
- ip6_sprintf(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr),
+ ip6_sprintf(&satosin6(ifa->ifa_addr)->sin6_addr),
ip6_sprintf(&mask6.sin6_addr), rtflags, error));
}
@@ -1690,8 +1690,8 @@ nd6_prefix_offlink(struct nd_prefix *pr)
mask6.sin6_len = sizeof(sa6);
bcopy(&pr->ndpr_mask, &mask6.sin6_addr, sizeof(struct in6_addr));
bzero(&info, sizeof(info));
- info.rti_info[RTAX_DST] = (struct sockaddr *)&sa6;
- info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask6;
+ info.rti_info[RTAX_DST] = sin6tosa(&sa6);
+ info.rti_info[RTAX_NETMASK] = sin6tosa(&mask6);
error = rtrequest1(RTM_DELETE, &info, RTP_CONNECTED, &rt,
ifp->if_rdomain);
if (error == 0) {
@@ -1972,7 +1972,6 @@ rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
int
rt6_deleteroute(struct radix_node *rn, void *arg, u_int id)
{
-#define SIN6(s) ((struct sockaddr_in6 *)s)
struct rt_addrinfo info;
struct rtentry *rt = (struct rtentry *)rn;
struct in6_addr *gate = (struct in6_addr *)arg;
@@ -1980,7 +1979,7 @@ rt6_deleteroute(struct radix_node *rn, void *arg, u_int id)
if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)
return (0);
- if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr))
+ if (!IN6_ARE_ADDR_EQUAL(gate, &satosin6(rt->rt_gateway)->sin6_addr))
return (0);
/*
@@ -2004,5 +2003,4 @@ rt6_deleteroute(struct radix_node *rn, void *arg, u_int id)
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
return (rtrequest1(RTM_DELETE, &info, RTP_ANY, NULL, id));
-#undef SIN6
}
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 9b4936184cb..6866ebea562 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.55 2013/05/31 13:15:53 bluhm Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.56 2013/05/31 15:04:25 bluhm Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -191,7 +191,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
/* strip intermediate headers */
m_adj(n, *offp);
if (sbappendaddr(&last->in6p_socket->so_rcv,
- (struct sockaddr *)&rip6src, n, opts) == 0) {
+ sin6tosa(&rip6src), n, opts) == 0) {
/* should notify about lost packet */
m_freem(n);
if (opts)
@@ -210,7 +210,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
/* strip intermediate headers */
m_adj(m, *offp);
if (sbappendaddr(&last->in6p_socket->so_rcv,
- (struct sockaddr *)&rip6src, m, opts) == 0) {
+ sin6tosa(&rip6src), m, opts) == 0) {
m_freem(m);
if (opts)
m_freem(opts);
@@ -691,7 +691,7 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
*/
if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) &&
!(so->so_options & SO_BINDANY) &&
- (ia = ifa_ifwithaddr((struct sockaddr *)addr,
+ (ia = ifa_ifwithaddr(sin6tosa(addr),
in6p->inp_rtableid)) == 0) {
error = EADDRNOTAVAIL;
break;