summaryrefslogtreecommitdiff
path: root/sys/netinet6/icmp6.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2013-05-31 15:04:26 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2013-05-31 15:04:26 +0000
commit9e211909ec1753490770ac0dc071e1df1e0e9674 (patch)
treeb48f653d4fa64d38a86e2d862a7af1e3714a7119 /sys/netinet6/icmp6.c
parent174bd522e81a30b9d2786d0700494e0065a3937c (diff)
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@
Diffstat (limited to 'sys/netinet6/icmp6.c')
-rw-r--r--sys/netinet6/icmp6.c33
1 files changed, 14 insertions, 19 deletions
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;