From 863a5899822e4bd058212457941e234db8ab8bc1 Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Fri, 7 Jun 2002 15:27:59 +0000 Subject: just for consistency/compatibility, have net.inet6.ip6.v6only sysctl MIB, as well as set/getsockopt(IPV6_V6ONLY). --- sys/netinet6/in6.h | 9 +++++---- sys/netinet6/in6_proto.c | 3 ++- sys/netinet6/ip6_input.c | 4 +++- sys/netinet6/ip6_output.c | 29 ++++++++++++++++++----------- sys/netinet6/ip6_var.h | 3 ++- 5 files changed, 30 insertions(+), 18 deletions(-) (limited to 'sys') diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index f19719db76d..2f8fefe91d9 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.27 2002/05/28 03:04:38 itojun Exp $ */ +/* $OpenBSD: in6.h,v 1.28 2002/06/07 15:27:58 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_BINDV6ONLY 27 /* bool; only bind INET6 at null bind */ +#define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */ #if 0 /*KAME IPSEC*/ #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ @@ -531,7 +531,8 @@ struct in6_pktinfo { #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ #define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ /*#define IPV6CTL_MAPPED_ADDR 23 not for openbsd */ -/* 24 to 40: resrved */ +#define IPV6CTL_V6ONLY 24 +/* 25 to 40: resrved */ #define IPV6CTL_MAXFRAGS 41 /* max fragments */ /* New entries should be added here from current IPV6CTL_MAXID value. */ /* to define items, should talk with KAME guys first, for *BSD compatibility */ @@ -562,7 +563,7 @@ struct in6_pktinfo { { "use_deprecated", CTLTYPE_INT }, \ { "rr_prune", CTLTYPE_INT }, \ { 0, 0 }, \ - { 0, 0 }, \ + { "v6only", CTLTYPE_INT }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 83c58e34803..78fdd828cd6 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.34 2002/05/29 02:59:12 itojun Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.35 2002/06/07 15:27:58 itojun Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -261,6 +261,7 @@ int ip6_auto_flowlabel = 1; int ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */ int ip6_rr_prune = 5; /* router renumbering prefix * walk list every 5 sec. */ +const int ip6_v6only = 1; u_int32_t ip6_id = 0UL; int ip6_keepfaith = 0; time_t ip6_log_time = (time_t)0L; diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 2062a97d23a..f8834b95f9e 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.42 2002/05/28 03:04:38 itojun Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.43 2002/06/07 15:27:58 itojun Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -1473,6 +1473,8 @@ ip6_sysctl(name, namelen, oldp, oldlenp, newp, newlen) &ip6_use_deprecated); case IPV6CTL_RR_PRUNE: return sysctl_int(oldp, oldlenp, newp, newlen, &ip6_rr_prune); + case IPV6CTL_V6ONLY: + return sysctl_rdint(oldp, oldlenp, newp, ip6_v6only); case IPV6CTL_MAXFRAGS: return sysctl_int(oldp, oldlenp, newp, newlen, &ip6_maxfrags); default: diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 1bfaed82643..d91106adde3 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.63 2002/06/07 15:00:55 itojun Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.64 2002/06/07 15:27:58 itojun Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -1234,6 +1234,7 @@ ip6_ctloutput(op, so, level, optname, mp) case IPV6_RTHDR: case IPV6_CHECKSUM: case IPV6_FAITH: + case IPV6_V6ONLY: if (optlen != sizeof(int)) { error = EINVAL; break; @@ -1295,6 +1296,11 @@ do { \ case IPV6_FAITH: OPTSET(IN6P_FAITH); break; + + case IPV6_V6ONLY: + if (!optval) + error = EINVAL; + break; } break; #undef OPTSET @@ -1311,30 +1317,26 @@ do { \ case IPV6_PORTRANGE: optval = *mtod(m, int *); -# define in6p inp -# define in6p_flags inp_flags switch (optval) { case IPV6_PORTRANGE_DEFAULT: - in6p->in6p_flags &= ~(IN6P_LOWPORT); - in6p->in6p_flags &= ~(IN6P_HIGHPORT); + inp->inp_flags &= ~(IN6P_LOWPORT); + inp->inp_flags &= ~(IN6P_HIGHPORT); break; case IPV6_PORTRANGE_HIGH: - in6p->in6p_flags &= ~(IN6P_LOWPORT); - in6p->in6p_flags |= IN6P_HIGHPORT; + inp->inp_flags &= ~(IN6P_LOWPORT); + inp->inp_flags |= IN6P_HIGHPORT; break; case IPV6_PORTRANGE_LOW: - in6p->in6p_flags &= ~(IN6P_HIGHPORT); - in6p->in6p_flags |= IN6P_LOWPORT; + inp->inp_flags &= ~(IN6P_HIGHPORT); + inp->inp_flags |= IN6P_LOWPORT; break; default: error = EINVAL; break; } -# undef in6p -# undef in6p_flags break; case IPSEC6_OUTSA: @@ -1461,6 +1463,7 @@ do { \ case IPV6_RTHDR: case IPV6_CHECKSUM: case IPV6_FAITH: + case IPV6_V6ONLY: case IPV6_PORTRANGE: switch (optname) { @@ -1510,6 +1513,10 @@ do { \ optval = OPTBIT(IN6P_FAITH); break; + case IPV6_V6ONLY: + optval = (ip6_v6only != 0); /* XXX */ + break; + case IPV6_PORTRANGE: { int flags; diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index f2179bde1c2..22592543b0c 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_var.h,v 1.16 2002/05/29 23:38:58 itojun Exp $ */ +/* $OpenBSD: ip6_var.h,v 1.17 2002/06/07 15:27:58 itojun Exp $ */ /* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ /* @@ -215,6 +215,7 @@ extern int ip6_forward_srcrt; /* forward src-routed? */ extern int ip6_use_deprecated; /* allow deprecated addr as source */ extern int ip6_rr_prune; /* router renumbering prefix * walk list every 5 sec. */ +extern const int ip6_v6only; extern struct socket *ip6_mrouter; /* multicast routing daemon */ extern int ip6_sendredirects; /* send IP redirects when forwarding? */ extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */ -- cgit v1.2.3