diff options
author | ume <ume@FreeBSD.org> | 2002-05-06 16:28:25 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2002-05-06 16:28:25 +0000 |
commit | 0dc033806b6e467440aa8004facf38c61c83e617 (patch) | |
tree | ef83cfffd0177cf608e0acf729fd8aab5f3e1979 /sys | |
parent | a65193d5b159668ce23ff42d7b44cae3b1c06bd6 (diff) | |
download | FreeBSD-src-0dc033806b6e467440aa8004facf38c61c83e617.zip FreeBSD-src-0dc033806b6e467440aa8004facf38c61c83e617.tar.gz |
Revised MLD-related definitions
- Used mld_xxx and MLD_xxx instead of mld6_xxx and MLD6_xxx according
to the official defintions in rfc2292bis
(macro definitions for backward compatibility were provided)
- Changed the first member of mld_hdr{} from mld_hdr to mld_icmp6_hdr
to avoid name space conflict in C++
This change makes ports/net/pchar compilable again under -CURRENT.
Obtained from: KAME
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/icmp6.h | 56 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 16 | ||||
-rw-r--r-- | sys/netinet6/mld6.c | 91 |
3 files changed, 94 insertions, 69 deletions
diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index abef35c..2b1f529 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -99,11 +99,18 @@ struct icmp6_hdr { #define ICMP6_ECHO_REQUEST 128 /* echo service */ #define ICMP6_ECHO_REPLY 129 /* echo reply */ #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ -#define MLD6_LISTENER_QUERY 130 /* multicast listener query */ +#define MLD_LISTENER_QUERY 130 /* multicast listener query */ #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ -#define MLD6_LISTENER_REPORT 131 /* multicast listener report */ +#define MLD_LISTENER_REPORT 131 /* multicast listener report */ #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ -#define MLD6_LISTENER_DONE 132 /* multicast listener done */ +#define MLD_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 */ @@ -121,12 +128,17 @@ 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 resp (to sender) */ +#define MLD_MTRACE 201 /* mtrace messages */ #define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */ #define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */ +#ifndef _KERNEL +#define MLD6_MTRACE_RESP MLD_MTRACE_RESP +#define MLD6_MTRACE MLD_MTRACE +#endif + #define ICMP6_MAXTYPE 203 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ @@ -164,16 +176,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 @@ -682,13 +706,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 65e1c89..38332b2 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -606,11 +606,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); @@ -624,14 +624,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 defind. */ /* XXX: per-interface statistics? */ break; /* just pass it to applications */ diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 27b8480..b35d10d 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -153,7 +153,7 @@ mld6_start_listening(in6m) in6m->in6m_timer = 0; in6m->in6m_state = MLD6_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 * PR_FASTHZ); in6m->in6m_state = MLD6_IREPORTEDLAST; @@ -174,7 +174,7 @@ mld6_stop_listening(in6m) if (in6m->in6m_state == MLD6_IREPORTEDLAST && (!IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld6_all_nodes_linklocal)) && IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) > IPV6_ADDR_SCOPE_NODELOCAL) - mld6_sendpkt(in6m, MLD6_LISTENER_DONE, + mld6_sendpkt(in6m, MLD_LISTENER_DONE, &mld6_all_routers_linklocal); } @@ -184,7 +184,7 @@ 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; @@ -193,9 +193,9 @@ mld6_input(m, off) #ifndef PULLDOWN_TEST IP6_EXTHDR_CHECK(m, off, sizeof(*mldh),); - mldh = (struct mld6_hdr *)(mtod(m, caddr_t) + off); + mldh = (struct mld_hdr *)(mtod(m, caddr_t) + off); #else - 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; @@ -208,7 +208,7 @@ mld6_input(m, off) log(LOG_ERR, "mld6_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)); /* * spec (RFC2710) does not explicitly * specify to discard the packet from a non link-local @@ -230,16 +230,16 @@ mld6_input(m, off) * we have heard a report from another member, or MLD6_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 */ /* @@ -262,8 +262,8 @@ 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/MLD6_TIMER_SCALE; + if (timer == 0 && mldh->mld_maxdelay) timer = 1; mld6_all_nodes_linklocal.s6_addr16[1] = htons(ifp->if_index); /* XXX */ @@ -279,13 +279,13 @@ mld6_input(m, off) 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; @@ -299,10 +299,10 @@ mld6_input(m, off) } } - 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 @@ -315,27 +315,27 @@ 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 */ } - 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 */ - log(LOG_ERR, "mld6_input: illegal type(%d)", mldh->mld6_type); + log(LOG_ERR, "mld6_input: illegal type(%d)", mldh->mld_type); break; } @@ -363,7 +363,7 @@ mld6_fasttimeo() if (in6m->in6m_timer == 0) { /* do nothing */ } else if (--in6m->in6m_timer == 0) { - mld6_sendpkt(in6m, MLD6_LISTENER_REPORT, NULL); + mld6_sendpkt(in6m, MLD_LISTENER_REPORT, NULL); in6m->in6m_state = MLD6_IREPORTEDLAST; } else { mld6_timers_are_running = 1; @@ -380,7 +380,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; @@ -411,7 +411,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)); @@ -427,19 +427,20 @@ 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)); @@ -459,13 +460,13 @@ mld6_sendpkt(in6m, type, dst) if (outif) { icmp6_ifstat_inc(outif, ifs6_out_msg); switch (type) { - case MLD6_LISTENER_QUERY: + case MLD_LISTENER_QUERY: icmp6_ifstat_inc(outif, ifs6_out_mldquery); break; - case MLD6_LISTENER_REPORT: + case MLD_LISTENER_REPORT: icmp6_ifstat_inc(outif, ifs6_out_mldreport); break; - case MLD6_LISTENER_DONE: + case MLD_LISTENER_DONE: icmp6_ifstat_inc(outif, ifs6_out_mlddone); break; } |