diff options
author | ume <ume@FreeBSD.org> | 2003-10-08 18:26:08 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2003-10-08 18:26:08 +0000 |
commit | cb2c1545ab3b25d366aeb88623dd50ed9349e174 (patch) | |
tree | 0e57d38335c69eed019dcea1730b3cd22ff6025e /sys/netinet6/ip6_mroute.c | |
parent | 8f2de8390a373f0018eb9a8bb4cab9e630163357 (diff) | |
download | FreeBSD-src-cb2c1545ab3b25d366aeb88623dd50ed9349e174.zip FreeBSD-src-cb2c1545ab3b25d366aeb88623dd50ed9349e174.tar.gz |
- fix typo in comments.
- style.
- NULL is not 0.
- some variables were renamed.
- nuke unused logic.
(there is no functional change.)
Obtained from: KAME
Diffstat (limited to 'sys/netinet6/ip6_mroute.c')
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 126 |
1 files changed, 84 insertions, 42 deletions
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 0857bf7..eeb9b21 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -33,6 +33,45 @@ /* BSDI ip_mroute.c,v 2.10 1996/11/14 00:29:52 jch Exp */ /* + * Copyright (c) 1989 Stephen Deering + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_mroute.c 8.2 (Berkeley) 11/15/93 + */ + +/* * IP multicast forwarding procedures * * Written by David Waitzman, BBN Labs, August 1988. @@ -40,7 +79,7 @@ * Modified by Mark J. Steiglitz, Stanford, May, 1991 * Modified by Van Jacobson, LBL, January 1993 * Modified by Ajit Thyagarajan, PARC, August 1993 - * Modified by Bill Fenenr, PARC, April 1994 + * Modified by Bill Fenner, PARC, April 1994 * * MROUTING Revision: 3.5.1.2 + PIM-SMv2 (pimd) Support */ @@ -89,9 +128,9 @@ static void phyint_send __P((struct ip6_hdr *, struct mif6 *, struct mbuf *)); static int set_pim6 __P((int *)); static int socket_send __P((struct socket *, struct mbuf *, - struct sockaddr_in6 *)); + struct sockaddr_in6 *)); static int register_send __P((struct ip6_hdr *, struct mif6 *, - struct mbuf *)); + struct mbuf *)); /* * Globals. All but ip6_mrouter, ip6_mrtproto and mrt6stat could be static, @@ -110,17 +149,17 @@ u_char n6expire[MF6CTBLSIZ]; static struct mif6 mif6table[MAXMIFS]; #ifdef MRT6DEBUG u_int mrt6debug = 0; /* debug level */ -#define DEBUG_MFC 0x02 -#define DEBUG_FORWARD 0x04 -#define DEBUG_EXPIRE 0x08 -#define DEBUG_XMIT 0x10 -#define DEBUG_REG 0x20 -#define DEBUG_PIM 0x40 +#define DEBUG_MFC 0x02 +#define DEBUG_FORWARD 0x04 +#define DEBUG_EXPIRE 0x08 +#define DEBUG_XMIT 0x10 +#define DEBUG_REG 0x20 +#define DEBUG_PIM 0x40 #endif static void expire_upcalls __P((void *)); -#define EXPIRE_TIMEOUT (hz / 4) /* 4x / second */ -#define UPCALL_EXPIRE 6 /* number of timeouts */ +#define EXPIRE_TIMEOUT (hz / 4) /* 4x / second */ +#define UPCALL_EXPIRE 6 /* number of timeouts */ #ifdef INET #ifdef MROUTING @@ -178,7 +217,7 @@ static int pim6; if (rt == NULL) { \ mrt6stat.mrt6s_mfc_misses++; \ } \ -} while (0) +} while (/*CONSTCOND*/ 0) /* * Macros to compute elapsed time efficiently @@ -192,7 +231,7 @@ static int pim6; switch (xxs) { \ case 2: \ delta += 1000000; \ - /* fall through */ \ + /* FALLTHROUGH */ \ case 1: \ delta += 1000000; \ break; \ @@ -200,7 +239,7 @@ static int pim6; delta += (1000000 * xxs); \ } \ } \ -} while (0) +} while (/*CONSTCOND*/ 0) #define TV_LT(a, b) (((a).tv_usec < (b).tv_usec && \ (a).tv_sec <= (b).tv_sec) || (a).tv_sec < (b).tv_sec) @@ -400,7 +439,8 @@ ip6_mrouter_init(so, m, cmd) if (*v != 1) return (ENOPROTOOPT); - if (ip6_mrouter != NULL) return (EADDRINUSE); + if (ip6_mrouter != NULL) + return (EADDRINUSE); ip6_mrouter = so; ip6_mrouter_ver = cmd; @@ -457,7 +497,7 @@ ip6_mrouter_done() if (mif6table[mifi].m6_ifp && !(mif6table[mifi].m6_flags & MIFF_REGISTER)) { ifr.ifr_addr.sin6_family = AF_INET6; - ifr.ifr_addr.sin6_addr= in6addr_any; + ifr.ifr_addr.sin6_addr = in6addr_any; ifp = mif6table[mifi].m6_ifp; (*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr); @@ -741,7 +781,8 @@ add_m6fc(mfccp) if (nstl == 0) { #ifdef MRT6DEBUG if (mrt6debug & DEBUG_MFC) - log(LOG_DEBUG,"add_mfc no upcall h %d o %s g %s p %x\n", + log(LOG_DEBUG, + "add_mfc no upcall h %d o %s g %s p %x\n", hash, ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr), ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr), @@ -749,7 +790,7 @@ add_m6fc(mfccp) #endif for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) { - + if (IN6_ARE_ADDR_EQUAL(&rt->mf6c_origin.sin6_addr, &mfccp->mf6cc_origin.sin6_addr)&& IN6_ARE_ADDR_EQUAL(&rt->mf6c_mcastgrp.sin6_addr, @@ -777,7 +818,7 @@ add_m6fc(mfccp) splx(s); return (ENOBUFS); } - + /* insert new entry at head of hash chain */ rt->mf6c_origin = mfccp->mf6cc_origin; rt->mf6c_mcastgrp = mfccp->mf6cc_mcastgrp; @@ -789,7 +830,7 @@ add_m6fc(mfccp) rt->mf6c_wrong_if = 0; rt->mf6c_expire = 0; rt->mf6c_stall = NULL; - + /* link into table */ rt->mf6c_next = mf6ctable[hash]; mf6ctable[hash] = rt; @@ -816,11 +857,11 @@ collate(t) if (TV_LT(*t, tp)) { TV_DELTA(tp, *t, delta); - + d = delta >> 10; if (d > UPCALL_MAX) d = UPCALL_MAX; - + ++upcall_data[d]; } } @@ -1014,7 +1055,7 @@ ip6_mforward(ip6, ifp, m) splx(s); return (ENOBUFS); } - + /* is there an upcall waiting for this packet? */ hash = MF6CHASH(ip6->ip6_src, ip6->ip6_dst); for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) { @@ -1059,7 +1100,7 @@ ip6_mforward(ip6, ifp, m) * Send message to routing daemon */ sin6.sin6_addr = ip6->ip6_src; - + im = NULL; #ifdef MRT6_OINIT oim = NULL; @@ -1248,11 +1289,11 @@ ip6_mdq(m, ifp, rt) */ #define MC6_SEND(ip6, mifp, m) do { \ - if ((mifp)->m6_flags & MIFF_REGISTER) \ - register_send((ip6), (mifp), (m)); \ - else \ - phyint_send((ip6), (mifp), (m)); \ -} while (0) + if ((mifp)->m6_flags & MIFF_REGISTER) \ + register_send((ip6), (mifp), (m)); \ + else \ + phyint_send((ip6), (mifp), (m)); \ +} while (/*CONSTCOND*/ 0) /* * Don't forward if it didn't arrive from the parent mif @@ -1299,7 +1340,7 @@ ip6_mdq(m, ifp, rt) mm = m_pullup(mm, sizeof(struct ip6_hdr)); if (mm == NULL) return (ENOBUFS); - + #ifdef MRT6_OINIT oim = NULL; #endif @@ -1371,7 +1412,7 @@ ip6_mdq(m, ifp, rt) * For each mif, forward a copy of the packet if there are group * members downstream on the interface. */ - for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++) + for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++) { if (IF_ISSET(mifi, &rt->mf6c_ifset)) { /* * check if the outgoing packet is going to break @@ -1396,6 +1437,7 @@ ip6_mdq(m, ifp, rt) mifp->m6_bytes_out += plen; MC6_SEND(ip6, mifp, m); } + } return (0); } @@ -1689,7 +1731,7 @@ pim6_input(mp, offp, proto) struct ip6_hdr *eip6; u_int32_t *reghdr; int rc; - + ++pim6stat.pim6s_rcv_registers; if ((reg_mif_num >= nummifs) || (reg_mif_num == (mifi_t) -1)) { @@ -1702,9 +1744,9 @@ pim6_input(mp, offp, proto) m_freem(m); return (IPPROTO_DONE); } - + reghdr = (u_int32_t *)(pim + 1); - + if ((ntohl(*reghdr) & PIM_NULL_REGISTER)) goto pim6_input_to_daemon; @@ -1723,9 +1765,9 @@ pim6_input(mp, offp, proto) m_freem(m); return (IPPROTO_DONE); } - + eip6 = (struct ip6_hdr *) (reghdr + 1); -#ifdef MRT6DEBUG +#ifdef MRT6DEBUG if (mrt6debug & DEBUG_PIM) log(LOG_DEBUG, "pim6_input[register], eip6: %s -> %s, " @@ -1746,7 +1788,7 @@ pim6_input(mp, offp, proto) m_freem(m); return (IPPROTO_NONE); } - + /* verify the inner packet is destined to a mcast group */ if (!IN6_IS_ADDR_MULTICAST(&eip6->ip6_dst)) { ++pim6stat.pim6s_rcv_badregisters; @@ -1760,7 +1802,7 @@ pim6_input(mp, offp, proto) m_freem(m); return (IPPROTO_DONE); } - + /* * make a copy of the whole header to pass to the daemon later. */ @@ -1774,7 +1816,7 @@ pim6_input(mp, offp, proto) m_freem(m); return (IPPROTO_DONE); } - + /* * forward the inner ip6 packet; point m_data at the inner ip6. */ @@ -1790,9 +1832,9 @@ pim6_input(mp, offp, proto) } #endif - rc = if_simloop(mif6table[reg_mif_num].m6_ifp, m, - dst.sin6_family, 0); - + rc = if_simloop(mif6table[reg_mif_num].m6_ifp, m, + dst.sin6_family, NULL); + /* prepare the register head to send to the mrouting daemon */ m = mcp; } |