summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-06-11 02:54:03 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-06-11 02:54:03 +0000
commit7f93664b229028f63dd25d327e7dca5392f41ed1 (patch)
tree6a1660b85d181dcf04c344ff15ce09332ffbbf3a
parent7ea94b99c24b51b034e1a8f6c7f29fa713eb9c17 (diff)
- sync up MLD declaration with RFC3542 (s/MLD6/MLD/)
- routing header declaration with RFC3542 (note: sizeof(ip6_rthdr0) has changed!) also, sync up with RFC2460 routing header definition (no "strict" source routing mode any more) part of advanced API update (RFC2292 -> 3542). markus, todd, millert, henning ok
-rw-r--r--lib/libc/net/rthdr.c30
-rw-r--r--sbin/pfctl/pfctl_parser.c12
-rw-r--r--sys/netinet/icmp6.h63
-rw-r--r--sys/netinet6/icmp6.c18
-rw-r--r--sys/netinet6/ip6_output.c11
-rw-r--r--sys/netinet6/mld6.c150
-rw-r--r--sys/netinet6/mld6_var.h8
-rw-r--r--sys/netinet6/route6.c17
8 files changed, 163 insertions, 146 deletions
diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c
index 904d61c8bc8..366ca9e6ba0 100644
--- a/lib/libc/net/rthdr.c
+++ b/lib/libc/net/rthdr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthdr.c,v 1.5 2003/06/06 07:27:52 itojun Exp $ */
+/* $OpenBSD: rthdr.c,v 1.6 2003/06/11 02:54:02 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -47,7 +47,7 @@ inet6_rthdr_space(type, seg)
case IPV6_RTHDR_TYPE_0:
if (seg < 1 || seg > 23)
return (0);
- return (CMSG_SPACE(sizeof(struct in6_addr) * (seg - 1) +
+ return (CMSG_SPACE(sizeof(struct in6_addr) * seg +
sizeof(struct ip6_rthdr0)));
default:
return (0);
@@ -69,8 +69,7 @@ inet6_rthdr_init(bp, type)
switch (type) {
case IPV6_RTHDR_TYPE_0:
- ch->cmsg_len = CMSG_LEN(sizeof(struct ip6_rthdr0) -
- sizeof(struct in6_addr));
+ ch->cmsg_len = CMSG_LEN(sizeof(struct ip6_rthdr0));
bzero(rthdr, sizeof(struct ip6_rthdr0));
rthdr->ip6r_type = IPV6_RTHDR_TYPE_0;
return (ch);
@@ -93,16 +92,10 @@ inet6_rthdr_add(cmsg, addr, flags)
case IPV6_RTHDR_TYPE_0:
{
struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)rthdr;
- if (flags != IPV6_RTHDR_LOOSE && flags != IPV6_RTHDR_STRICT)
+ if (flags != IPV6_RTHDR_LOOSE)
return (-1);
if (rt0->ip6r0_segleft == 23)
return (-1);
- if (flags == IPV6_RTHDR_STRICT) {
- int c, b;
- c = rt0->ip6r0_segleft / 8;
- b = rt0->ip6r0_segleft % 8;
- rt0->ip6r0_slmap[c] |= (1 << (7 - b));
- }
rt0->ip6r0_segleft++;
bcopy(addr, (caddr_t)rt0 + ((rt0->ip6r0_len + 1) << 3),
sizeof(struct in6_addr));
@@ -130,16 +123,10 @@ inet6_rthdr_lasthop(cmsg, flags)
case IPV6_RTHDR_TYPE_0:
{
struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)rthdr;
- if (flags != IPV6_RTHDR_LOOSE && flags != IPV6_RTHDR_STRICT)
+ if (flags != IPV6_RTHDR_LOOSE)
return (-1);
if (rt0->ip6r0_segleft > 23)
return (-1);
- if (flags == IPV6_RTHDR_STRICT) {
- int c, b;
- c = rt0->ip6r0_segleft / 8;
- b = rt0->ip6r0_segleft % 8;
- rt0->ip6r0_slmap[c] |= (1 << (7 - b));
- }
break;
}
default:
@@ -204,7 +191,7 @@ inet6_rthdr_getaddr(cmsg, index)
naddr = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr);
if (index <= 0 || naddr < index)
return NULL;
- return &rt0->ip6r0_addr[index - 1];
+ return ((struct in6_addr *)(rt0 + 1)) + index;
}
default:
@@ -232,10 +219,7 @@ inet6_rthdr_getflags(cmsg, index)
naddr = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr);
if (index < 0 || naddr < index)
return (-1);
- if (rt0->ip6r0_slmap[index / 8] & (0x80 >> (index % 8)))
- return IPV6_RTHDR_STRICT;
- else
- return IPV6_RTHDR_LOOSE;
+ return IPV6_RTHDR_LOOSE;
}
default:
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index d0f0773d943..23e229f5d69 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.c,v 1.162 2003/06/09 11:14:46 mcbride Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.163 2003/06/11 02:54:02 itojun Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -104,11 +104,11 @@ static const struct icmptypeent icmp6_type[] = {
{ "echoreq", ICMP6_ECHO_REQUEST },
{ "echorep", ICMP6_ECHO_REPLY },
{ "groupqry", ICMP6_MEMBERSHIP_QUERY },
- { "listqry", MLD6_LISTENER_QUERY },
+ { "listqry", MLD_LISTENER_QUERY },
{ "grouprep", ICMP6_MEMBERSHIP_REPORT },
- { "listenrep", MLD6_LISTENER_REPORT },
+ { "listenrep", MLD_LISTENER_REPORT },
{ "groupterm", ICMP6_MEMBERSHIP_REDUCTION },
- { "listendone", MLD6_LISTENER_DONE },
+ { "listendone", MLD_LISTENER_DONE },
{ "routersol", ND_ROUTER_SOLICIT },
{ "routeradv", ND_ROUTER_ADVERT },
{ "neighbrsol", ND_NEIGHBOR_SOLICIT },
@@ -121,8 +121,8 @@ static const struct icmptypeent icmp6_type[] = {
{ "fqdnrep", ICMP6_FQDN_REPLY },
{ "niqry", ICMP6_NI_QUERY },
{ "nirep", ICMP6_NI_REPLY },
- { "mtraceresp", MLD6_MTRACE_RESP },
- { "mtrace", MLD6_MTRACE }
+ { "mtraceresp", MLD_MTRACE_RESP },
+ { "mtrace", MLD_MTRACE }
};
static const struct icmpcodeent icmp_code[] = {
diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h
index 0785ca5aa63..abfc4c732ef 100644
--- a/sys/netinet/icmp6.h
+++ b/sys/netinet/icmp6.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: icmp6.h,v 1.26 2003/06/02 23:28:13 millert Exp $ */
-/* $KAME: icmp6.h,v 1.71 2002/05/27 04:18:29 itojun Exp $ */
+/* $OpenBSD: icmp6.h,v 1.27 2003/06/11 02:54:02 itojun Exp $ */
+/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,12 +94,21 @@ struct icmp6_hdr {
#define ICMP6_ECHO_REQUEST 128 /* echo service */
#define ICMP6_ECHO_REPLY 129 /* echo reply */
+#define MLD_LISTENER_QUERY 130 /* multicast listener query */
+#define MLD_LISTENER_REPORT 131 /* multicast listener report */
+#define MLD_LISTENER_DONE 132 /* multicast listener done */
+
+/* RFC2292 decls */
#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
-#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
-#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
-#define MLD6_LISTENER_DONE 132 /* multicast listener done */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
+#define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
+#define MLD6_LISTENER_DONE MLD_LISTENER_DONE
+#endif
#define ND_ROUTER_SOLICIT 133 /* router solicitation */
#define ND_ROUTER_ADVERT 134 /* router advertisment */
@@ -117,8 +126,14 @@ struct icmp6_hdr {
#define ICMP6_NI_REPLY 140 /* node information reply */
/* The definitions below are experimental. TBA */
-#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
-#define MLD6_MTRACE 201 /* mtrace messages */
+#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
+#define MLD_MTRACE 201 /* mtrace messages */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_MTRACE_RESP MLD_MTRACE_RESP
+#define MLD6_MTRACE MLD_MTRACE
+#endif
#define ICMP6_MAXTYPE 201
@@ -157,16 +172,28 @@ struct icmp6_hdr {
/*
* Multicast Listener Discovery
*/
-struct mld6_hdr {
- struct icmp6_hdr mld6_hdr;
- struct in6_addr mld6_addr; /* multicast address */
+struct mld_hdr {
+ struct icmp6_hdr mld_icmp6_hdr;
+ struct in6_addr mld_addr; /* multicast address */
} __attribute__((__packed__));
-#define mld6_type mld6_hdr.icmp6_type
-#define mld6_code mld6_hdr.icmp6_code
-#define mld6_cksum mld6_hdr.icmp6_cksum
-#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
-#define mld6_reserved mld6_hdr.icmp6_data16[1]
+/* definitions to provide backward compatibility to old KAME applications */
+#ifndef _KERNEL
+#define mld6_hdr mld_hdr
+#define mld6_type mld_type
+#define mld6_code mld_code
+#define mld6_cksum mld_cksum
+#define mld6_maxdelay mld_maxdelay
+#define mld6_reserved mld_reserved
+#define mld6_addr mld_addr
+#endif
+
+/* shortcut macro definitions */
+#define mld_type mld_icmp6_hdr.icmp6_type
+#define mld_code mld_icmp6_hdr.icmp6_code
+#define mld_cksum mld_icmp6_hdr.icmp6_cksum
+#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
+#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
/*
* Neighbor Discovery
@@ -648,13 +675,13 @@ do { \
case ICMP6_ECHO_REPLY: \
icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
break; \
- case MLD6_LISTENER_QUERY: \
+ case MLD_LISTENER_QUERY: \
icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
break; \
- case MLD6_LISTENER_REPORT: \
+ case MLD_LISTENER_REPORT: \
icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
break; \
- case MLD6_LISTENER_DONE: \
+ case MLD_LISTENER_DONE: \
icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
break; \
case ND_ROUTER_SOLICIT: \
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 1800667847c..c34c599adf3 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.70 2003/06/03 06:25:26 itojun Exp $ */
+/* $OpenBSD: icmp6.c,v 1.71 2003/06/11 02:54:02 itojun Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -642,11 +642,11 @@ icmp6_input(mp, offp, proto)
goto badcode;
break;
- case MLD6_LISTENER_QUERY:
- case MLD6_LISTENER_REPORT:
- if (icmp6len < sizeof(struct mld6_hdr))
+ case MLD_LISTENER_QUERY:
+ case MLD_LISTENER_REPORT:
+ if (icmp6len < sizeof(struct mld_hdr))
goto badlen;
- if (icmp6->icmp6_type == MLD6_LISTENER_QUERY) /* XXX: ugly... */
+ if (icmp6->icmp6_type == MLD_LISTENER_QUERY) /* XXX: ugly... */
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mldquery);
else
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mldreport);
@@ -660,14 +660,14 @@ icmp6_input(mp, offp, proto)
/* m stays. */
break;
- case MLD6_LISTENER_DONE:
+ case MLD_LISTENER_DONE:
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mlddone);
- if (icmp6len < sizeof(struct mld6_hdr)) /* necessary? */
+ if (icmp6len < sizeof(struct mld_hdr)) /* necessary? */
goto badlen;
break; /* nothing to be done in kernel */
- case MLD6_MTRACE_RESP:
- case MLD6_MTRACE:
+ case MLD_MTRACE_RESP:
+ case MLD_MTRACE:
/* XXX: these two are experimental. not officially defined. */
/* XXX: per-interface statistics? */
break; /* just pass it to applications */
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 77650652c88..02c1609ee32 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.74 2003/06/02 23:28:15 millert Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.75 2003/06/11 02:54:02 itojun Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -402,6 +402,7 @@ ip6_output(m0, opt, ro, flags, im6o, ifpp)
if (exthdrs.ip6e_rthdr) {
struct ip6_rthdr *rh;
struct ip6_rthdr0 *rh0;
+ struct in6_addr *addr;
rh = (struct ip6_rthdr *)(mtod(exthdrs.ip6e_rthdr,
struct ip6_rthdr *));
@@ -409,11 +410,11 @@ ip6_output(m0, opt, ro, flags, im6o, ifpp)
switch (rh->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
rh0 = (struct ip6_rthdr0 *)rh;
- ip6->ip6_dst = rh0->ip6r0_addr[0];
- bcopy((caddr_t)&rh0->ip6r0_addr[1],
- (caddr_t)&rh0->ip6r0_addr[0],
+ addr = (struct in6_addr *)(rh0 + 1);
+ ip6->ip6_dst = addr[0];
+ bcopy(&addr[1], &addr[0],
sizeof(struct in6_addr) * (rh0->ip6r0_segleft - 1));
- rh0->ip6r0_addr[rh0->ip6r0_segleft - 1] = finaldst;
+ addr[rh0->ip6r0_segleft - 1] = finaldst;
break;
default: /* is it possible? */
error = EINVAL;
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index c897b9726c9..3806ed9c8a4 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mld6.c,v 1.18 2003/06/02 23:28:16 millert Exp $ */
+/* $OpenBSD: mld6.c,v 1.19 2003/06/11 02:54:02 itojun Exp $ */
/* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */
/*
@@ -87,18 +87,18 @@
*/
/* denotes that the MLD max response delay field specifies time in milliseconds */
-#define MLD6_TIMER_SCALE 1000
+#define MLD_TIMER_SCALE 1000
/*
* time between repetitions of a node's initial report of interest in a
* multicast address(in seconds)
*/
-#define MLD6_UNSOLICITED_REPORT_INTERVAL 10
+#define MLD_UNSOLICITED_REPORT_INTERVAL 10
static struct ip6_pktopts ip6_opts;
-static int mld6_timers_are_running;
+static int mld_timers_are_running;
/* XXX: These are necessary for KAME's link-local hack */
-static struct in6_addr mld6_all_nodes_linklocal = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
-static struct in6_addr mld6_all_routers_linklocal = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
+static struct in6_addr mld_all_nodes_linklocal = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+static struct in6_addr mld_all_routers_linklocal = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
static void mld6_sendpkt(struct in6_multi *, int, const struct in6_addr *);
@@ -109,7 +109,7 @@ mld6_init()
struct ip6_hbh *hbh = (struct ip6_hbh *)hbh_buf;
u_int16_t rtalert_code = htons((u_int16_t)IP6OPT_RTALERT_MLD);
- mld6_timers_are_running = 0;
+ mld_timers_are_running = 0;
/* ip6h_nxt will be fill in later */
hbh->ip6h_len = 0; /* (8 >> 3) - 1 */
@@ -139,19 +139,19 @@ mld6_start_listening(in6m)
* MLD messages are never sent for multicast addresses whose scope is 0
* (reserved) or 1 (node-local).
*/
- mld6_all_nodes_linklocal.s6_addr16[1] =
+ mld_all_nodes_linklocal.s6_addr16[1] =
htons(in6m->in6m_ifp->if_index); /* XXX */
- if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld6_all_nodes_linklocal) ||
+ if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld_all_nodes_linklocal) ||
IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) < IPV6_ADDR_SCOPE_LINKLOCAL) {
in6m->in6m_timer = 0;
- in6m->in6m_state = MLD6_OTHERLISTENER;
+ in6m->in6m_state = MLD_OTHERLISTENER;
} else {
- mld6_sendpkt(in6m, MLD6_LISTENER_REPORT, NULL);
+ mld6_sendpkt(in6m, MLD_LISTENER_REPORT, NULL);
in6m->in6m_timer =
- MLD6_RANDOM_DELAY(MLD6_UNSOLICITED_REPORT_INTERVAL *
+ MLD_RANDOM_DELAY(MLD_UNSOLICITED_REPORT_INTERVAL *
PR_FASTHZ);
- in6m->in6m_state = MLD6_IREPORTEDLAST;
- mld6_timers_are_running = 1;
+ in6m->in6m_state = MLD_IREPORTEDLAST;
+ mld_timers_are_running = 1;
}
splx(s);
}
@@ -160,16 +160,16 @@ void
mld6_stop_listening(in6m)
struct in6_multi *in6m;
{
- mld6_all_nodes_linklocal.s6_addr16[1] =
+ mld_all_nodes_linklocal.s6_addr16[1] =
htons(in6m->in6m_ifp->if_index); /* XXX */
- mld6_all_routers_linklocal.s6_addr16[1] =
+ mld_all_routers_linklocal.s6_addr16[1] =
htons(in6m->in6m_ifp->if_index); /* XXX: necessary when mrouting */
- if (in6m->in6m_state == MLD6_IREPORTEDLAST &&
- (!IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld6_all_nodes_linklocal)) &&
+ if (in6m->in6m_state == MLD_IREPORTEDLAST &&
+ (!IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld_all_nodes_linklocal)) &&
IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) > IPV6_ADDR_SCOPE_NODELOCAL)
- mld6_sendpkt(in6m, MLD6_LISTENER_DONE,
- &mld6_all_routers_linklocal);
+ mld6_sendpkt(in6m, MLD_LISTENER_DONE,
+ &mld_all_routers_linklocal);
}
void
@@ -178,13 +178,13 @@ mld6_input(m, off)
int off;
{
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
- struct mld6_hdr *mldh;
+ struct mld_hdr *mldh;
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct in6_multi *in6m;
struct in6_ifaddr *ia;
int timer; /* timer value in the MLD query header */
- IP6_EXTHDR_GET(mldh, struct mld6_hdr *, m, off, sizeof(*mldh));
+ IP6_EXTHDR_GET(mldh, struct mld_hdr *, m, off, sizeof(*mldh));
if (mldh == NULL) {
icmp6stat.icp6s_tooshort++;
return;
@@ -195,9 +195,9 @@ mld6_input(m, off)
if (!IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src)) {
#if 0
log(LOG_ERR,
- "mld6_input: src %s is not link-local (grp=%s)\n",
+ "mld_input: src %s is not link-local (grp=%s)\n",
ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&mldh->mld6_addr));
+ ip6_sprintf(&mldh->mld_addr));
#endif
/*
* spec (RFC2710) does not explicitly
@@ -215,20 +215,20 @@ mld6_input(m, off)
* In Delaying Listener state, our timer is running (in6m->in6m_timer)
* In Idle Listener state, our timer is not running (in6m->in6m_timer==0)
*
- * The flag is in6m->in6m_state, it is set to MLD6_OTHERLISTENER if
- * we have heard a report from another member, or MLD6_IREPORTEDLAST
+ * The flag is in6m->in6m_state, it is set to MLD_OTHERLISTENER if
+ * we have heard a report from another member, or MLD_IREPORTEDLAST
* if we sent the last report.
*/
- switch(mldh->mld6_type) {
- case MLD6_LISTENER_QUERY:
+ switch(mldh->mld_type) {
+ case MLD_LISTENER_QUERY:
if (ifp->if_flags & IFF_LOOPBACK)
break;
- if (!IN6_IS_ADDR_UNSPECIFIED(&mldh->mld6_addr) &&
- !IN6_IS_ADDR_MULTICAST(&mldh->mld6_addr))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&mldh->mld_addr) &&
+ !IN6_IS_ADDR_MULTICAST(&mldh->mld_addr))
break; /* print error or log stat? */
- if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld6_addr))
- mldh->mld6_addr.s6_addr16[1] =
+ if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr))
+ mldh->mld_addr.s6_addr16[1] =
htons(ifp->if_index); /* XXX */
/*
@@ -251,10 +251,10 @@ mld6_input(m, off)
* the calculated value equals to zero when Max Response
* Delay is positive.
*/
- timer = ntohs(mldh->mld6_maxdelay)*PR_FASTHZ/MLD6_TIMER_SCALE;
- if (timer == 0 && mldh->mld6_maxdelay)
+ timer = ntohs(mldh->mld_maxdelay)*PR_FASTHZ/MLD_TIMER_SCALE;
+ if (timer == 0 && mldh->mld_maxdelay)
timer = 1;
- mld6_all_nodes_linklocal.s6_addr16[1] =
+ mld_all_nodes_linklocal.s6_addr16[1] =
htons(ifp->if_index); /* XXX */
for (in6m = ia->ia6_multiaddrs.lh_first;
@@ -262,34 +262,34 @@ mld6_input(m, off)
in6m = in6m->in6m_entry.le_next)
{
if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr,
- &mld6_all_nodes_linklocal) ||
+ &mld_all_nodes_linklocal) ||
IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) <
IPV6_ADDR_SCOPE_LINKLOCAL)
continue;
- if (IN6_IS_ADDR_UNSPECIFIED(&mldh->mld6_addr) ||
- IN6_ARE_ADDR_EQUAL(&mldh->mld6_addr,
+ if (IN6_IS_ADDR_UNSPECIFIED(&mldh->mld_addr) ||
+ IN6_ARE_ADDR_EQUAL(&mldh->mld_addr,
&in6m->in6m_addr))
{
if (timer == 0) {
/* send a report immediately */
- mld6_sendpkt(in6m, MLD6_LISTENER_REPORT,
+ mld6_sendpkt(in6m, MLD_LISTENER_REPORT,
NULL);
in6m->in6m_timer = 0; /* reset timer */
- in6m->in6m_state = MLD6_IREPORTEDLAST;
+ in6m->in6m_state = MLD_IREPORTEDLAST;
} else if (in6m->in6m_timer == 0 || /* idle */
in6m->in6m_timer > timer) {
in6m->in6m_timer =
- MLD6_RANDOM_DELAY(timer);
- mld6_timers_are_running = 1;
+ MLD_RANDOM_DELAY(timer);
+ mld_timers_are_running = 1;
}
}
}
- if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld6_addr))
- mldh->mld6_addr.s6_addr16[1] = 0; /* XXX */
+ if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr))
+ mldh->mld_addr.s6_addr16[1] = 0; /* XXX */
break;
- case MLD6_LISTENER_REPORT:
+ case MLD_LISTENER_REPORT:
/*
* For fast leave to work, we have to know that we are the
* last person to send a report for this group. Reports
@@ -302,24 +302,24 @@ mld6_input(m, off)
if (m->m_flags & M_LOOP) /* XXX: grotty flag, but efficient */
break;
- if (!IN6_IS_ADDR_MULTICAST(&mldh->mld6_addr))
+ if (!IN6_IS_ADDR_MULTICAST(&mldh->mld_addr))
break;
- if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld6_addr))
- mldh->mld6_addr.s6_addr16[1] =
+ if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr))
+ mldh->mld_addr.s6_addr16[1] =
htons(ifp->if_index); /* XXX */
/*
* If we belong to the group being reported, stop
* our timer for that group.
*/
- IN6_LOOKUP_MULTI(mldh->mld6_addr, ifp, in6m);
+ IN6_LOOKUP_MULTI(mldh->mld_addr, ifp, in6m);
if (in6m) {
in6m->in6m_timer = 0; /* transit to idle state */
- in6m->in6m_state = MLD6_OTHERLISTENER; /* clear flag */
+ in6m->in6m_state = MLD_OTHERLISTENER; /* clear flag */
}
- if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld6_addr))
- mldh->mld6_addr.s6_addr16[1] = 0; /* XXX */
+ if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr))
+ mldh->mld_addr.s6_addr16[1] = 0; /* XXX */
break;
default: /* this is impossible */
#if 0
@@ -328,7 +328,7 @@ mld6_input(m, off)
* icmp6_input(). But we explicitly disabled this part
* just in case.
*/
- log(LOG_ERR, "mld6_input: illegal type(%d)", mldh->mld6_type);
+ log(LOG_ERR, "mld_input: illegal type(%d)", mldh->mld_type);
#endif
break;
}
@@ -347,20 +347,20 @@ mld6_fasttimeo()
* Quick check to see if any work needs to be done, in order
* to minimize the overhead of fasttimo processing.
*/
- if (!mld6_timers_are_running)
+ if (!mld_timers_are_running)
return;
s = splsoftnet();
- mld6_timers_are_running = 0;
+ mld_timers_are_running = 0;
IN6_FIRST_MULTI(step, in6m);
while (in6m != NULL) {
if (in6m->in6m_timer == 0) {
/* do nothing */
} else if (--in6m->in6m_timer == 0) {
- mld6_sendpkt(in6m, MLD6_LISTENER_REPORT, NULL);
- in6m->in6m_state = MLD6_IREPORTEDLAST;
+ mld6_sendpkt(in6m, MLD_LISTENER_REPORT, NULL);
+ in6m->in6m_state = MLD_IREPORTEDLAST;
} else {
- mld6_timers_are_running = 1;
+ mld_timers_are_running = 1;
}
IN6_NEXT_MULTI(step, in6m);
}
@@ -374,7 +374,7 @@ mld6_sendpkt(in6m, type, dst)
const struct in6_addr *dst;
{
struct mbuf *mh, *md;
- struct mld6_hdr *mldh;
+ struct mld_hdr *mldh;
struct ip6_hdr *ip6;
struct ip6_moptions im6o;
struct in6_ifaddr *ia;
@@ -409,7 +409,7 @@ mld6_sendpkt(in6m, type, dst)
mh->m_next = md;
mh->m_pkthdr.rcvif = NULL;
- mh->m_pkthdr.len = sizeof(struct ip6_hdr) + sizeof(struct mld6_hdr);
+ mh->m_pkthdr.len = sizeof(struct ip6_hdr) + sizeof(struct mld_hdr);
mh->m_len = sizeof(struct ip6_hdr);
MH_ALIGN(mh, sizeof(struct ip6_hdr));
@@ -425,19 +425,19 @@ mld6_sendpkt(in6m, type, dst)
ip6->ip6_dst = dst ? *dst : in6m->in6m_addr;
/* fill in the MLD header */
- md->m_len = sizeof(struct mld6_hdr);
- mldh = mtod(md, struct mld6_hdr *);
- mldh->mld6_type = type;
- mldh->mld6_code = 0;
- mldh->mld6_cksum = 0;
+ md->m_len = sizeof(struct mld_hdr);
+ mldh = mtod(md, struct mld_hdr *);
+ mldh->mld_type = type;
+ mldh->mld_code = 0;
+ mldh->mld_cksum = 0;
/* XXX: we assume the function will not be called for query messages */
- mldh->mld6_maxdelay = 0;
- mldh->mld6_reserved = 0;
- mldh->mld6_addr = in6m->in6m_addr;
- if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld6_addr))
- mldh->mld6_addr.s6_addr16[1] = 0; /* XXX */
- mldh->mld6_cksum = in6_cksum(mh, IPPROTO_ICMPV6, sizeof(struct ip6_hdr),
- sizeof(struct mld6_hdr));
+ mldh->mld_maxdelay = 0;
+ mldh->mld_reserved = 0;
+ mldh->mld_addr = in6m->in6m_addr;
+ if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr))
+ mldh->mld_addr.s6_addr16[1] = 0; /* XXX */
+ mldh->mld_cksum = in6_cksum(mh, IPPROTO_ICMPV6, sizeof(struct ip6_hdr),
+ sizeof(struct mld_hdr));
/* construct multicast option */
bzero(&im6o, sizeof(im6o));
@@ -454,13 +454,13 @@ mld6_sendpkt(in6m, type, dst)
icmp6stat.icp6s_outhist[type]++;
icmp6_ifstat_inc(ifp, ifs6_out_msg);
switch (type) {
- case MLD6_LISTENER_QUERY:
+ case MLD_LISTENER_QUERY:
icmp6_ifstat_inc(ifp, ifs6_out_mldquery);
break;
- case MLD6_LISTENER_REPORT:
+ case MLD_LISTENER_REPORT:
icmp6_ifstat_inc(ifp, ifs6_out_mldreport);
break;
- case MLD6_LISTENER_DONE:
+ case MLD_LISTENER_DONE:
icmp6_ifstat_inc(ifp, ifs6_out_mlddone);
break;
}
diff --git a/sys/netinet6/mld6_var.h b/sys/netinet6/mld6_var.h
index 991e294f427..7024215467a 100644
--- a/sys/netinet6/mld6_var.h
+++ b/sys/netinet6/mld6_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mld6_var.h,v 1.4 2002/03/14 01:27:12 millert Exp $ */
+/* $OpenBSD: mld6_var.h,v 1.5 2003/06/11 02:54:02 itojun Exp $ */
/* $KAME: mld6_var.h,v 1.4 2000/03/25 07:23:54 sumikawa Exp $ */
/*
@@ -35,13 +35,13 @@
#ifdef _KERNEL
-#define MLD6_RANDOM_DELAY(X) (arc4random() % (X) + 1)
+#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
/*
* States for MLD stop-listening processing
*/
-#define MLD6_OTHERLISTENER 0
-#define MLD6_IREPORTEDLAST 1
+#define MLD_OTHERLISTENER 0
+#define MLD_IREPORTEDLAST 1
void mld6_init(void);
void mld6_input(struct mbuf *, int);
diff --git a/sys/netinet6/route6.c b/sys/netinet6/route6.c
index ba04e656e64..0811cc05ed6 100644
--- a/sys/netinet6/route6.c
+++ b/sys/netinet6/route6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route6.c,v 1.9 2003/05/14 14:24:44 itojun Exp $ */
+/* $OpenBSD: route6.c,v 1.10 2003/06/11 02:54:02 itojun Exp $ */
/* $KAME: route6.c,v 1.22 2000/12/03 00:54:00 itojun Exp $ */
/*
@@ -101,6 +101,9 @@ route6_input(mp, offp, proto)
/*
* Type0 routing header processing
+ *
+ * RFC2292 backward compatibility warning: no support for strict/loose bitmap,
+ * as it was dropped between RFC1883 and RFC2460.
*/
static int
ip6_rthdr0(m, ip6, rh0)
@@ -139,7 +142,7 @@ ip6_rthdr0(m, ip6, rh0)
index = addrs - rh0->ip6r0_segleft;
rh0->ip6r0_segleft--;
- nextaddr = rh0->ip6r0_addr + index;
+ nextaddr = ((struct in6_addr *)(rh0 + 1)) + index;
/*
* reject invalid addresses. be proactive about malicious use of
@@ -151,16 +154,14 @@ ip6_rthdr0(m, ip6, rh0)
IN6_IS_ADDR_V4MAPPED(nextaddr) ||
IN6_IS_ADDR_V4COMPAT(nextaddr)) {
ip6stat.ip6s_badoptions++;
- m_freem(m);
- return (-1);
+ goto bad;
}
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst) ||
IN6_IS_ADDR_V4COMPAT(&ip6->ip6_dst)) {
ip6stat.ip6s_badoptions++;
- m_freem(m);
- return (-1);
+ goto bad;
}
/*
@@ -184,4 +185,8 @@ ip6_rthdr0(m, ip6, rh0)
#endif
return (-1); /* m would be freed in ip6_forward() */
+
+ bad:
+ m_freem(m);
+ return (-1);
}