reduce diffs with kame (mostly cosmetic).

move IPV6_CHECKSUM processing to sys/netinet6/raw_ip6.c.
constify a couple of places.
This commit is contained in:
itojun 2001-10-18 07:44:33 +00:00
parent dcd30fd216
commit ae5499819c
10 changed files with 95 additions and 74 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: frag6.c,v 1.14 2001/05/17 14:01:37 itojun Exp $ */
/* $NetBSD: frag6.c,v 1.15 2001/10/18 07:44:33 itojun Exp $ */
/* $KAME: frag6.c,v 1.31 2001/05/17 13:45:34 jinmei Exp $ */
/*
@ -634,9 +634,6 @@ frag6_slowtimo()
{
struct ip6q *q6;
int s = splsoftnet();
#if 0
extern struct route_in6 ip6_forward_rt;
#endif
frag6_doing_reass = 1;
q6 = ip6q.ip6q_next;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.c,v 1.47 2001/07/25 06:59:51 itojun Exp $ */
/* $NetBSD: in6.c,v 1.48 2001/10/18 07:44:33 itojun Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@ -1588,7 +1588,7 @@ static char digits[] = "0123456789abcdef";
static int ip6round = 0;
char *
ip6_sprintf(addr)
struct in6_addr *addr;
const struct in6_addr *addr;
{
static char ip6buf[8][48];
int i;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.h,v 1.29 2001/10/16 04:17:54 itojun Exp $ */
/* $NetBSD: in6.h,v 1.30 2001/10/18 07:44:34 itojun Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@ -395,7 +395,7 @@ struct route_in6 {
#define IPV6_RTHDR 24 /* bool; routing header */
#define IPV6_PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */
#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
#define IPV6_V6ONLY 27 /* bool; only bind INET6 at null bind */
#define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */
#if 1 /*IPSEC*/
#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_var.h,v 1.20 2001/10/16 06:24:44 itojun Exp $ */
/* $NetBSD: in6_var.h,v 1.21 2001/10/18 07:44:34 itojun Exp $ */
/* $KAME: in6_var.h,v 1.53 2001/02/10 02:44:27 itojun Exp $ */
/*
@ -576,7 +576,7 @@ void in6_purgemkludge __P((struct ifnet *));
struct in6_ifaddr *in6ifa_ifpforlinklocal __P((struct ifnet *, int));
struct in6_ifaddr *in6ifa_ifpwithaddr __P((struct ifnet *,
struct in6_addr *));
char *ip6_sprintf __P((struct in6_addr *));
char *ip6_sprintf __P((const struct in6_addr *));
int in6_addr2scopeid __P((struct ifnet *, struct in6_addr *));
int in6_matchlen __P((struct in6_addr *, struct in6_addr *));
int in6_are_prefix_equal __P((struct in6_addr *p1, struct in6_addr *p2,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_output.c,v 1.38 2001/10/17 08:23:06 itojun Exp $ */
/* $NetBSD: ip6_output.c,v 1.39 2001/10/18 07:44:34 itojun Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@ -1244,7 +1244,6 @@ ip6_ctloutput(op, so, level, optname, mp)
case IPV6_PKTINFO:
case IPV6_HOPLIMIT:
case IPV6_RTHDR:
case IPV6_CHECKSUM:
case IPV6_FAITH:
case IPV6_V6ONLY:
if (!m || m->m_len != sizeof(int)) {
@ -1300,10 +1299,6 @@ else \
OPTSET(IN6P_RTHDR);
break;
case IPV6_CHECKSUM:
in6p->in6p_cksum = optval;
break;
case IPV6_FAITH:
OPTSET(IN6P_FAITH);
break;
@ -1438,7 +1433,6 @@ else \
case IPV6_PKTINFO:
case IPV6_HOPLIMIT:
case IPV6_RTHDR:
case IPV6_CHECKSUM:
case IPV6_FAITH:
case IPV6_V6ONLY:
*mp = m = m_get(M_WAIT, MT_SOOPTS);
@ -1496,10 +1490,6 @@ else \
optval = OPTBIT(IN6P_RTHDR);
break;
case IPV6_CHECKSUM:
optval = in6p->in6p_cksum;
break;
case IPV6_FAITH:
optval = OPTBIT(IN6P_FAITH);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.h,v 1.22 2001/10/17 10:55:09 itojun Exp $ */
/* $NetBSD: nd6.h,v 1.23 2001/10/18 07:44:35 itojun Exp $ */
/* $KAME: nd6.h,v 1.52 2001/02/19 04:40:37 itojun Exp $ */
/*
@ -308,11 +308,11 @@ int nd6_need_cache __P((struct ifnet *));
/* nd6_nbr.c */
void nd6_na_input __P((struct mbuf *, int, int));
void nd6_na_output __P((struct ifnet *, struct in6_addr *,
struct in6_addr *, u_long, int, struct sockaddr *));
void nd6_na_output __P((struct ifnet *, const struct in6_addr *,
const struct in6_addr *, u_long, int, struct sockaddr *));
void nd6_ns_input __P((struct mbuf *, int, int));
void nd6_ns_output __P((struct ifnet *, struct in6_addr *,
struct in6_addr *, struct llinfo_nd6 *, int));
void nd6_ns_output __P((struct ifnet *, const struct in6_addr *,
const struct in6_addr *, struct llinfo_nd6 *, int));
caddr_t nd6_ifptomac __P((struct ifnet *));
void nd6_dad_start __P((struct ifaddr *, int *));
void nd6_dad_stop __P((struct ifaddr *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_nbr.c,v 1.31 2001/10/17 10:55:09 itojun Exp $ */
/* $NetBSD: nd6_nbr.c,v 1.32 2001/10/18 07:44:35 itojun Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@ -331,7 +331,7 @@ nd6_ns_input(m, off, icmp6len)
void
nd6_ns_output(ifp, daddr6, taddr6, ln, dad)
struct ifnet *ifp;
struct in6_addr *daddr6, *taddr6;
const struct in6_addr *daddr6, *taddr6;
struct llinfo_nd6 *ln; /* for source address determination */
int dad; /* duplicated address detection */
{
@ -343,7 +343,6 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad)
int icmp6len;
int maxlen;
caddr_t mac;
struct ifnet *outif = NULL;
if (IN6_IS_ADDR_MULTICAST(taddr6))
return;
@ -491,12 +490,18 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad)
/* Don't lookup socket */
(void)ipsec_setsocket(m, NULL);
#endif
ip6_output(m, NULL, NULL, dad ? IPV6_DADOUTPUT : 0, &im6o, &outif);
if (outif) {
icmp6_ifstat_inc(outif, ifs6_out_msg);
icmp6_ifstat_inc(outif, ifs6_out_neighborsolicit);
}
ip6_output(m, NULL, NULL, 0, &im6o, NULL);
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]++;
return;
#if 0
bad:
m_freem(m);
return;
#endif
}
/*
@ -809,7 +814,7 @@ nd6_na_input(m, off, icmp6len)
void
nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0)
struct ifnet *ifp;
struct in6_addr *daddr6, *taddr6;
const struct in6_addr *daddr6, *taddr6;
u_long flags;
int tlladdr; /* 1 if include target link-layer address */
struct sockaddr *sdl0; /* sockaddr_dl (= proxy NA) or NULL */
@ -822,7 +827,6 @@ nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0)
int icmp6len;
int maxlen;
caddr_t mac;
struct ifnet *outif = NULL;
/* estimate the size of message */
maxlen = sizeof(*ip6) + sizeof(*nd_na);
@ -942,11 +946,10 @@ nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0)
/* Don't lookup socket */
(void)ipsec_setsocket(m, NULL);
#endif
ip6_output(m, NULL, NULL, 0, &im6o, &outif);
if (outif) {
icmp6_ifstat_inc(outif, ifs6_out_msg);
icmp6_ifstat_inc(outif, ifs6_out_neighboradvert);
}
ip6_output(m, NULL, NULL, 0, &im6o, NULL);
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]++;
}
@ -1322,7 +1325,7 @@ nd6_dad_ns_input(ifa)
{
struct in6_ifaddr *ia;
struct ifnet *ifp;
struct in6_addr *taddr6;
const struct in6_addr *taddr6;
struct dadq *dp;
int duplicate;

View File

@ -1,4 +1,4 @@
/* $NetBSD: raw_ip6.c,v 1.35 2001/07/25 23:28:03 itojun Exp $ */
/* $NetBSD: raw_ip6.c,v 1.36 2001/10/18 07:44:35 itojun Exp $ */
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
/*
@ -157,7 +157,7 @@ rip6_input(mp, offp, proto)
bzero(&rip6src, sizeof(rip6src));
rip6src.sin6_len = sizeof(struct sockaddr_in6);
rip6src.sin6_family = AF_INET6;
#if 0 /*XXX inbound flowlabel */
#if 0 /* XXX inbound flowlabel */
rip6src.sin6_flowinfo = ip6->ip6_flow & IPV6_FLOWINFO_MASK;
#endif
/* KAME hack: recover scopeid */
@ -527,17 +527,21 @@ rip6_output(m, va_alist)
return(error);
}
/*
/*
* Raw IPv6 socket option processing.
*/
*/
int
rip6_ctloutput(op, so, level, optname, m)
rip6_ctloutput(op, so, level, optname, mp)
int op;
struct socket *so;
int level, optname;
struct mbuf **m;
struct mbuf **mp;
{
int error = 0;
int optval;
struct in6pcb *in6p;
struct mbuf *m;
const int icmp6off = offsetof(struct icmp6_hdr, icmp6_cksum);
switch (level) {
case IPPROTO_IPV6:
@ -550,29 +554,62 @@ rip6_ctloutput(op, so, level, optname, m)
case MRT6_DEL_MFC:
case MRT6_PIM:
if (op == PRCO_SETOPT) {
error = ip6_mrouter_set(optname, so, *m);
if (*m)
(void)m_free(*m);
} else if (op == PRCO_GETOPT) {
error = ip6_mrouter_get(optname, so, m);
} else
error = ip6_mrouter_set(optname, so, *mp);
if (*mp)
(void)m_free(*mp);
} else if (op == PRCO_GETOPT)
error = ip6_mrouter_get(optname, so, mp);
else
error = EINVAL;
return (error);
case IPV6_CHECKSUM:
/*
* for ICMPv6 sockets, no modification allowed for
* checksum offset, permit "no change" values to
* help existing apps.
*/
in6p = sotoin6pcb(so);
error = 0;
if (op == PRCO_SETOPT) {
m = *mp;
if (m && m->m_len == sizeof(int)) {
optval = *mtod(m, int *);
if (so->so_proto->pr_protocol ==
IPPROTO_ICMPV6) {
if (optval != icmp6off)
error = EINVAL;
} else
in6p->in6p_cksum = optval;
} else
error = EINVAL;
if (m)
m_free(m);
} else if (op == PRCO_GETOPT) {
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
optval = icmp6off;
else
optval = in6p->in6p_cksum;
*mp = m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = sizeof(int);
*mtod(m, int *) = optval;
} else
error = EINVAL;
return error;
default:
return (ip6_ctloutput(op, so, level, optname, mp));
}
return (ip6_ctloutput(op, so, level, optname, m));
/* NOTREACHED */
case IPPROTO_ICMPV6:
/*
* XXX: is it better to call icmp6_ctloutput() directly
* from protosw?
*/
return(icmp6_ctloutput(op, so, level, optname, m));
return(icmp6_ctloutput(op, so, level, optname, mp));
default:
if (op == PRCO_SETOPT && *m)
(void)m_free(*m);
return(EINVAL);
if (op == PRCO_SETOPT && *mp)
m_free(*mp);
return EINVAL;
}
}
@ -698,13 +735,6 @@ rip6_usrreq(so, req, m, nam, control, p)
error = EADDRNOTAVAIL;
break;
}
/*
* Currently, ifa_ifwithaddr tends to fail for a link-local
* address, since it implicitly expects that the link ID
* for the address is embedded in the sin6_addr part.
* For now, we'd rather keep this "as is". We'll eventually fix
* this in a more natural way.
*/
if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) &&
(ia = ifa_ifwithaddr((struct sockaddr *)addr)) == 0) {
error = EADDRNOTAVAIL;
@ -720,7 +750,7 @@ rip6_usrreq(so, req, m, nam, control, p)
in6p->in6p_laddr = addr->sin6_addr;
break;
}
case PRU_CONNECT:
{
struct sockaddr_in6 *addr = mtod(nam, struct sockaddr_in6 *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp6_output.c,v 1.2 2001/10/15 09:51:17 itojun Exp $ */
/* $NetBSD: udp6_output.c,v 1.3 2001/10/18 07:44:36 itojun Exp $ */
/* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
/*
@ -134,7 +134,7 @@ udp6_output(in6p, m, addr6, control, p)
struct ip *ip;
struct udpiphdr *ui;
#endif
int flags;
int flags = 0;
struct sockaddr_in6 tmp;
priv = 0;
@ -341,7 +341,6 @@ udp6_output(in6p, m, addr6, control, p)
udp6->uh_sum = 0xffff;
}
flags = 0;
#ifdef IN6P_MINMTU
if (in6p->in6p_flags & IN6P_MINMTU)
flags |= IPV6_MINMTU;

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp6_usrreq.c,v 1.46 2001/10/15 09:51:17 itojun Exp $ */
/* $NetBSD: udp6_usrreq.c,v 1.47 2001/10/18 07:44:36 itojun Exp $ */
/* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */
/*
@ -493,8 +493,10 @@ udp6_ctlinput(cmd, sa, d)
notify = in6_rtchange, d = NULL;
else if (cmd == PRC_HOSTDEAD)
d = NULL;
else if (cmd == PRC_MSGSIZE)
; /* special code is present, see below */
else if (cmd == PRC_MSGSIZE) {
/* special code is present, see below */
notify = in6_rtchange;
}
else if (inet6ctlerrmap[cmd] == 0)
return;