xref: /freebsd/usr.bin/netstat/mroute6.c (revision ade9ccfe211ac8b27c58a4dc11a6cd1d33767ce0)
165475bc8SDavid E. O'Brien /*-
20fea3d51SYoshinobu Inoue  * Copyright (C) 1998 WIDE Project.
30fea3d51SYoshinobu Inoue  * All rights reserved.
40fea3d51SYoshinobu Inoue  *
50fea3d51SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
60fea3d51SYoshinobu Inoue  * modification, are permitted provided that the following conditions
70fea3d51SYoshinobu Inoue  * are met:
80fea3d51SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
90fea3d51SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
100fea3d51SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
110fea3d51SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
120fea3d51SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
130fea3d51SYoshinobu Inoue  * 3. Neither the name of the project nor the names of its contributors
140fea3d51SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
150fea3d51SYoshinobu Inoue  *    without specific prior written permission.
160fea3d51SYoshinobu Inoue  *
170fea3d51SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
180fea3d51SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
190fea3d51SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
200fea3d51SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
210fea3d51SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
220fea3d51SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
230fea3d51SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
240fea3d51SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
250fea3d51SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
260fea3d51SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
270fea3d51SYoshinobu Inoue  * SUCH DAMAGE.
280fea3d51SYoshinobu Inoue  */
2965475bc8SDavid E. O'Brien /*-
300fea3d51SYoshinobu Inoue  * Copyright (c) 1989 Stephen Deering
310fea3d51SYoshinobu Inoue  * Copyright (c) 1992, 1993
320fea3d51SYoshinobu Inoue  *	The Regents of the University of California.  All rights reserved.
330fea3d51SYoshinobu Inoue  *
340fea3d51SYoshinobu Inoue  * This code is derived from software contributed to Berkeley by
350fea3d51SYoshinobu Inoue  * Stephen Deering of Stanford University.
360fea3d51SYoshinobu Inoue  *
370fea3d51SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
380fea3d51SYoshinobu Inoue  * modification, are permitted provided that the following conditions
390fea3d51SYoshinobu Inoue  * are met:
400fea3d51SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
410fea3d51SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
420fea3d51SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
430fea3d51SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
440fea3d51SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
450fea3d51SYoshinobu Inoue  * 3. All advertising materials mentioning features or use of this software
460fea3d51SYoshinobu Inoue  *    must display the following acknowledgement:
470fea3d51SYoshinobu Inoue  *	This product includes software developed by the University of
480fea3d51SYoshinobu Inoue  *	California, Berkeley and its contributors.
490fea3d51SYoshinobu Inoue  * 4. Neither the name of the University nor the names of its contributors
500fea3d51SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
510fea3d51SYoshinobu Inoue  *    without specific prior written permission.
520fea3d51SYoshinobu Inoue  *
530fea3d51SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
540fea3d51SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
550fea3d51SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
560fea3d51SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
570fea3d51SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
580fea3d51SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
590fea3d51SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
600fea3d51SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
610fea3d51SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
620fea3d51SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
630fea3d51SYoshinobu Inoue  * SUCH DAMAGE.
640fea3d51SYoshinobu Inoue  *
650fea3d51SYoshinobu Inoue  *	@(#)mroute.c	8.2 (Berkeley) 4/28/95
660fea3d51SYoshinobu Inoue  */
670fea3d51SYoshinobu Inoue 
686cc6f122SPhilippe Charnier #include <sys/cdefs.h>
696cc6f122SPhilippe Charnier __FBSDID("$FreeBSD$");
706cc6f122SPhilippe Charnier 
71d84a1df4SHajimu UMEMOTO #ifdef INET6
720fea3d51SYoshinobu Inoue #include <sys/param.h>
730fea3d51SYoshinobu Inoue #include <sys/queue.h>
740fea3d51SYoshinobu Inoue #include <sys/socket.h>
750fea3d51SYoshinobu Inoue #include <sys/socketvar.h>
76c15ddad9SBruce M Simpson #include <sys/sysctl.h>
770fea3d51SYoshinobu Inoue #include <sys/protosw.h>
78c15ddad9SBruce M Simpson #include <sys/mbuf.h>
79c15ddad9SBruce M Simpson #include <sys/time.h>
800fea3d51SYoshinobu Inoue 
810fea3d51SYoshinobu Inoue #include <net/if.h>
820fea3d51SYoshinobu Inoue #include <net/if_var.h>
8333841545SHajimu UMEMOTO #include <net/route.h>
840fea3d51SYoshinobu Inoue 
850fea3d51SYoshinobu Inoue #include <netinet/in.h>
860fea3d51SYoshinobu Inoue 
87c15ddad9SBruce M Simpson #include <err.h>
88fc47e028SAlexander V. Chernikov #include <nlist.h>
897b95a1ebSYaroslav Tykhiy #include <stdint.h>
900fea3d51SYoshinobu Inoue #include <stdio.h>
91c15ddad9SBruce M Simpson #include <stdlib.h>
92*ade9ccfeSMarcel Moolenaar #include <stdbool.h>
93*ade9ccfeSMarcel Moolenaar #include <libxo/xo.h>
940fea3d51SYoshinobu Inoue 
950fea3d51SYoshinobu Inoue #define	KERNEL 1
960fea3d51SYoshinobu Inoue #include <netinet6/ip6_mroute.h>
970fea3d51SYoshinobu Inoue #undef KERNEL
980fea3d51SYoshinobu Inoue 
990fea3d51SYoshinobu Inoue #include "netstat.h"
1000fea3d51SYoshinobu Inoue 
101fc47e028SAlexander V. Chernikov /*
102fc47e028SAlexander V. Chernikov  * kvm(3) bindings for every needed symbol
103fc47e028SAlexander V. Chernikov  */
104fc47e028SAlexander V. Chernikov static struct nlist mrl[] = {
105fc47e028SAlexander V. Chernikov #define	N_MF6CTABLE	0
106fc47e028SAlexander V. Chernikov 	{ .n_name = "_mf6ctable" },
107fc47e028SAlexander V. Chernikov #define	N_MIF6TABLE	1
108fc47e028SAlexander V. Chernikov 	{ .n_name = "_mif6table" },
109fc47e028SAlexander V. Chernikov #define	N_MRT6STAT	2
110fc47e028SAlexander V. Chernikov 	{ .n_name = "_mrt6stat" },
111fc47e028SAlexander V. Chernikov 	{ .n_name = NULL },
112fc47e028SAlexander V. Chernikov };
113fc47e028SAlexander V. Chernikov 
114fc47e028SAlexander V. Chernikov 
11570057abfSRuslan Ermilov #define	WID_ORG	(Wflag ? 39 : (numeric_addr ? 29 : 18)) /* width of origin column */
11670057abfSRuslan Ermilov #define	WID_GRP	(Wflag ? 18 : (numeric_addr ? 16 : 18)) /* width of group column */
1170fea3d51SYoshinobu Inoue 
1180fea3d51SYoshinobu Inoue void
119fc47e028SAlexander V. Chernikov mroute6pr()
1200fea3d51SYoshinobu Inoue {
1210fea3d51SYoshinobu Inoue 	struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;
1220fea3d51SYoshinobu Inoue 	struct mif6 mif6table[MAXMIFS];
1230fea3d51SYoshinobu Inoue 	struct mf6c mfc;
1240fea3d51SYoshinobu Inoue 	struct rtdetq rte, *rtep;
125a01e3379SDavid Malone 	struct mif6 *mifp;
126fc47e028SAlexander V. Chernikov 	u_long mfcaddr, mifaddr;
127a01e3379SDavid Malone 	mifi_t mifi;
128a01e3379SDavid Malone 	int i;
129a01e3379SDavid Malone 	int banner_printed;
130a01e3379SDavid Malone 	int saved_numeric_addr;
1310fea3d51SYoshinobu Inoue 	mifi_t maxmif = 0;
1320fea3d51SYoshinobu Inoue 	long int waitings;
133c15ddad9SBruce M Simpson 	size_t len;
1340fea3d51SYoshinobu Inoue 
135fc47e028SAlexander V. Chernikov 	kresolve_list(mrl);
136fc47e028SAlexander V. Chernikov 	mfcaddr = mrl[N_MF6CTABLE].n_value;
137fc47e028SAlexander V. Chernikov 	mifaddr = mrl[N_MIF6TABLE].n_value;
138fc47e028SAlexander V. Chernikov 
139fc47e028SAlexander V. Chernikov 	if (mfcaddr == 0 || mifaddr == 0) {
140fc47e028SAlexander V. Chernikov 		fprintf(stderr, "No IPv6 MROUTING kernel support.\n");
141fc47e028SAlexander V. Chernikov 		return;
142fc47e028SAlexander V. Chernikov 	}
143fc47e028SAlexander V. Chernikov 
144c15ddad9SBruce M Simpson 	len = sizeof(mif6table);
145feda1a43SJohn Baldwin 	if (live) {
146c15ddad9SBruce M Simpson 		if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
147c15ddad9SBruce M Simpson 		    NULL, 0) < 0) {
148*ade9ccfeSMarcel Moolenaar 			xo_warn("sysctl: net.inet6.ip6.mif6table");
1490fea3d51SYoshinobu Inoue 			return;
1500fea3d51SYoshinobu Inoue 		}
151feda1a43SJohn Baldwin 	} else
152c15ddad9SBruce M Simpson 		kread(mifaddr, (char *)mif6table, sizeof(mif6table));
1530fea3d51SYoshinobu Inoue 
15465ea0024SAssar Westerlund 	saved_numeric_addr = numeric_addr;
15565ea0024SAssar Westerlund 	numeric_addr = 1;
1560fea3d51SYoshinobu Inoue 	banner_printed = 0;
157c15ddad9SBruce M Simpson 
1580fea3d51SYoshinobu Inoue 	for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
1590fea3d51SYoshinobu Inoue 		struct ifnet ifnet;
1600fea3d51SYoshinobu Inoue 		char ifname[IFNAMSIZ];
1610fea3d51SYoshinobu Inoue 
1620fea3d51SYoshinobu Inoue 		if (mifp->m6_ifp == NULL)
1630fea3d51SYoshinobu Inoue 			continue;
1640fea3d51SYoshinobu Inoue 
165c15ddad9SBruce M Simpson 		/* XXX KVM */
1660fea3d51SYoshinobu Inoue 		kread((u_long)mifp->m6_ifp, (char *)&ifnet, sizeof(ifnet));
167c15ddad9SBruce M Simpson 
1680fea3d51SYoshinobu Inoue 		maxmif = mifi;
1690fea3d51SYoshinobu Inoue 		if (!banner_printed) {
170*ade9ccfeSMarcel Moolenaar 			xo_open_list("multicast-interface");
171*ade9ccfeSMarcel Moolenaar 			xo_emit("\n{T:IPv6 Multicast Interface Table}\n"
172*ade9ccfeSMarcel Moolenaar 			    "{T: Mif   Rate   PhyIF   Pkts-In   Pkts-Out}\n");
1730fea3d51SYoshinobu Inoue 			banner_printed = 1;
1740fea3d51SYoshinobu Inoue 		}
1750fea3d51SYoshinobu Inoue 
176*ade9ccfeSMarcel Moolenaar 		xo_open_instance("multicast-interface");
177*ade9ccfeSMarcel Moolenaar 		xo_emit("  {:mif/%2u}   {:rate-limit/%4d}",
1780fea3d51SYoshinobu Inoue 		    mifi, mifp->m6_rate_limit);
179*ade9ccfeSMarcel Moolenaar 		xo_emit("   {:ifname/%5s}", (mifp->m6_flags & MIFF_REGISTER) ?
1800fea3d51SYoshinobu Inoue 		    "reg0" : if_indextoname(ifnet.if_index, ifname));
1810fea3d51SYoshinobu Inoue 
182*ade9ccfeSMarcel Moolenaar 		xo_emit(" {:received-packets/%9ju}  {:sent-packets/%9ju}\n",
183*ade9ccfeSMarcel Moolenaar 		    (uintmax_t)mifp->m6_pkt_in,
1847b95a1ebSYaroslav Tykhiy 		    (uintmax_t)mifp->m6_pkt_out);
185*ade9ccfeSMarcel Moolenaar 		xo_close_instance("multicast-interface");
1860fea3d51SYoshinobu Inoue 	}
187*ade9ccfeSMarcel Moolenaar 	if (banner_printed)
188*ade9ccfeSMarcel Moolenaar 		xo_open_list("multicast-interface");
189*ade9ccfeSMarcel Moolenaar 	else
190*ade9ccfeSMarcel Moolenaar 		xo_emit("\n{T:IPv6 Multicast Interface Table is empty}\n");
1910fea3d51SYoshinobu Inoue 
192c15ddad9SBruce M Simpson 	len = sizeof(mf6ctable);
193feda1a43SJohn Baldwin 	if (live) {
194c15ddad9SBruce M Simpson 		if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len,
195c15ddad9SBruce M Simpson 		    NULL, 0) < 0) {
196*ade9ccfeSMarcel Moolenaar 			xo_warn("sysctl: net.inet6.ip6.mf6ctable");
197c15ddad9SBruce M Simpson 			return;
198c15ddad9SBruce M Simpson 		}
199feda1a43SJohn Baldwin 	} else
200c15ddad9SBruce M Simpson 		kread(mfcaddr, (char *)mf6ctable, sizeof(mf6ctable));
201c15ddad9SBruce M Simpson 
2020fea3d51SYoshinobu Inoue 	banner_printed = 0;
203c15ddad9SBruce M Simpson 
2040fea3d51SYoshinobu Inoue 	for (i = 0; i < MF6CTBLSIZ; ++i) {
2050fea3d51SYoshinobu Inoue 		mfcp = mf6ctable[i];
2060fea3d51SYoshinobu Inoue 		while(mfcp) {
2070fea3d51SYoshinobu Inoue 			kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
2080fea3d51SYoshinobu Inoue 			if (!banner_printed) {
209*ade9ccfeSMarcel Moolenaar 				xo_open_list("multicast-forwarding-cache");
210*ade9ccfeSMarcel Moolenaar 				xo_emit("\n"
211*ade9ccfeSMarcel Moolenaar 				    "{T:IPv6 Multicast Forwarding Cache}\n");
212*ade9ccfeSMarcel Moolenaar 				xo_emit(" {T:%-*.*s} {T:%-*.*s} {T:%s}",
2130fea3d51SYoshinobu Inoue 				    WID_ORG, WID_ORG, "Origin",
2140fea3d51SYoshinobu Inoue 				    WID_GRP, WID_GRP, "Group",
2150fea3d51SYoshinobu Inoue 				    "  Packets Waits In-Mif  Out-Mifs\n");
2160fea3d51SYoshinobu Inoue 				banner_printed = 1;
2170fea3d51SYoshinobu Inoue 			}
2180fea3d51SYoshinobu Inoue 
219*ade9ccfeSMarcel Moolenaar 			xo_open_instance("multicast-forwarding-cache");
220*ade9ccfeSMarcel Moolenaar 
221*ade9ccfeSMarcel Moolenaar 			xo_emit(" {:origin/%-*.*s}", WID_ORG, WID_ORG,
2220fea3d51SYoshinobu Inoue 			    routename6(&mfc.mf6c_origin));
223*ade9ccfeSMarcel Moolenaar 			xo_emit(" {:group/%-*.*s}", WID_GRP, WID_GRP,
2240fea3d51SYoshinobu Inoue 			    routename6(&mfc.mf6c_mcastgrp));
225*ade9ccfeSMarcel Moolenaar 			xo_emit(" {:total-packets/%9ju}",
226*ade9ccfeSMarcel Moolenaar 			    (uintmax_t)mfc.mf6c_pkt_cnt);
2270fea3d51SYoshinobu Inoue 
2280fea3d51SYoshinobu Inoue 			for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {
2290fea3d51SYoshinobu Inoue 				waitings++;
230c15ddad9SBruce M Simpson 				/* XXX KVM */
2310fea3d51SYoshinobu Inoue 				kread((u_long)rtep, (char *)&rte, sizeof(rte));
2320fea3d51SYoshinobu Inoue 				rtep = rte.next;
2330fea3d51SYoshinobu Inoue 			}
234*ade9ccfeSMarcel Moolenaar 			xo_emit("   {:waitings/%3ld}", waitings);
2350fea3d51SYoshinobu Inoue 
2360fea3d51SYoshinobu Inoue 			if (mfc.mf6c_parent == MF6C_INCOMPLETE_PARENT)
237*ade9ccfeSMarcel Moolenaar 				xo_emit(" ---   ");
2380fea3d51SYoshinobu Inoue 			else
239*ade9ccfeSMarcel Moolenaar 				xo_emit("  {:parent/%3d}   ", mfc.mf6c_parent);
240*ade9ccfeSMarcel Moolenaar 			xo_open_list("mif");
2410fea3d51SYoshinobu Inoue 			for (mifi = 0; mifi <= maxmif; mifi++) {
2420fea3d51SYoshinobu Inoue 				if (IF_ISSET(mifi, &mfc.mf6c_ifset))
243*ade9ccfeSMarcel Moolenaar 					xo_emit(" {l:%u}", mifi);
2440fea3d51SYoshinobu Inoue 			}
245*ade9ccfeSMarcel Moolenaar 			xo_close_list("mif");
246*ade9ccfeSMarcel Moolenaar 			xo_emit("\n");
2470fea3d51SYoshinobu Inoue 
2480fea3d51SYoshinobu Inoue 			mfcp = mfc.mf6c_next;
249*ade9ccfeSMarcel Moolenaar 			xo_close_instance("multicast-forwarding-cache");
2500fea3d51SYoshinobu Inoue 		}
2510fea3d51SYoshinobu Inoue 	}
252*ade9ccfeSMarcel Moolenaar 	if (banner_printed)
253*ade9ccfeSMarcel Moolenaar 		xo_close_list("multicast-forwarding-cache");
254*ade9ccfeSMarcel Moolenaar 	else
255*ade9ccfeSMarcel Moolenaar 		xo_emit("\n{T:IPv6 Multicast Forwarding Table is empty}\n");
2560fea3d51SYoshinobu Inoue 
257*ade9ccfeSMarcel Moolenaar 	xo_emit("\n");
25865ea0024SAssar Westerlund 	numeric_addr = saved_numeric_addr;
2590fea3d51SYoshinobu Inoue }
2600fea3d51SYoshinobu Inoue 
2610fea3d51SYoshinobu Inoue void
262fc47e028SAlexander V. Chernikov mrt6_stats()
2630fea3d51SYoshinobu Inoue {
2640fea3d51SYoshinobu Inoue 	struct mrt6stat mrtstat;
265fc47e028SAlexander V. Chernikov 	u_long mstaddr;
266c15ddad9SBruce M Simpson 	size_t len = sizeof mrtstat;
2670fea3d51SYoshinobu Inoue 
268fc47e028SAlexander V. Chernikov 	kresolve_list(mrl);
269fc47e028SAlexander V. Chernikov 	mstaddr = mrl[N_MRT6STAT].n_value;
270fc47e028SAlexander V. Chernikov 
271fc47e028SAlexander V. Chernikov 	if (mstaddr == 0) {
272fc47e028SAlexander V. Chernikov 		fprintf(stderr, "No IPv6 MROUTING kernel support.\n");
273fc47e028SAlexander V. Chernikov 		return;
274fc47e028SAlexander V. Chernikov 	}
275fc47e028SAlexander V. Chernikov 
276feda1a43SJohn Baldwin 	if (live) {
277c15ddad9SBruce M Simpson 		if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
278c15ddad9SBruce M Simpson 		    NULL, 0) < 0) {
279*ade9ccfeSMarcel Moolenaar 			xo_warn("sysctl: net.inet6.ip6.mrt6stat");
2800fea3d51SYoshinobu Inoue 			return;
2810fea3d51SYoshinobu Inoue 		}
282feda1a43SJohn Baldwin 	} else
2830fea3d51SYoshinobu Inoue 		kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
284feda1a43SJohn Baldwin 
285*ade9ccfeSMarcel Moolenaar 	xo_open_container("multicast-statistics");
286*ade9ccfeSMarcel Moolenaar 	xo_emit("{T:IPv6 multicast forwarding}:\n");
28776840ccbSRuslan Ermilov 
28876840ccbSRuslan Ermilov #define	p(f, m) if (mrtstat.f || sflag <= 1) \
289*ade9ccfeSMarcel Moolenaar 	xo_emit(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
29076840ccbSRuslan Ermilov #define	p2(f, m) if (mrtstat.f || sflag <= 1) \
291*ade9ccfeSMarcel Moolenaar 	xo_emit(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
29276840ccbSRuslan Ermilov 
293*ade9ccfeSMarcel Moolenaar 	p(mrt6s_mfc_lookups, "\t{:cache-lookups/%ju} "
294*ade9ccfeSMarcel Moolenaar 	    "{N:/multicast forwarding cache lookup%s}\n");
295*ade9ccfeSMarcel Moolenaar 	p2(mrt6s_mfc_misses, "\t{:cache-misses/%ju} "
296*ade9ccfeSMarcel Moolenaar 	    "{N:/multicast forwarding cache miss%s}\n");
297*ade9ccfeSMarcel Moolenaar 	p(mrt6s_upcalls, "\t{:upcalls/%ju} "
298*ade9ccfeSMarcel Moolenaar 	    "{N:/upcall%s to multicast routing daemon}\n");
299*ade9ccfeSMarcel Moolenaar 	p(mrt6s_upq_ovflw, "\t{:upcall-overflows/%ju} "
300*ade9ccfeSMarcel Moolenaar 	    "{N:/upcall queue overflow%s}\n");
301*ade9ccfeSMarcel Moolenaar 	p(mrt6s_upq_sockfull, "\t{:upcalls-dropped-full-buffer/%ju} "
302*ade9ccfeSMarcel Moolenaar 	    "{N:/upcall%s dropped due to full socket buffer}\n");
303*ade9ccfeSMarcel Moolenaar 	p(mrt6s_cache_cleanups, "\t{:cache-cleanups/%ju} "
304*ade9ccfeSMarcel Moolenaar 	    "{N:/cache cleanup%s}\n");
305*ade9ccfeSMarcel Moolenaar 	p(mrt6s_no_route, "\t{:dropped-no-origin/%ju} "
306*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s with no route for origin}\n");
307*ade9ccfeSMarcel Moolenaar 	p(mrt6s_bad_tunnel, "\t{:dropped-bad-tunnel/%ju} "
308*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s arrived with bad tunneling}\n");
309*ade9ccfeSMarcel Moolenaar 	p(mrt6s_cant_tunnel, "\t{:dropped-could-not-tunnel/%ju} "
310*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s could not be tunneled}\n");
311*ade9ccfeSMarcel Moolenaar 	p(mrt6s_wrong_if, "\t{:dropped-wrong-incoming-interface/%ju} "
312*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s arrived on wrong interface}\n");
313*ade9ccfeSMarcel Moolenaar 	p(mrt6s_drop_sel, "\t{:dropped-selectively/%ju} "
314*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s selectively dropped}\n");
315*ade9ccfeSMarcel Moolenaar 	p(mrt6s_q_overflow, "\t{:dropped-queue-overflow/%ju} "
316*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s dropped due to queue overflow}\n");
317*ade9ccfeSMarcel Moolenaar 	p(mrt6s_pkt2large, "\t{:dropped-too-large/%ju} "
318*ade9ccfeSMarcel Moolenaar 	    "{N:/datagram%s dropped for being too large}\n");
31976840ccbSRuslan Ermilov 
32076840ccbSRuslan Ermilov #undef	p2
32176840ccbSRuslan Ermilov #undef	p
322*ade9ccfeSMarcel Moolenaar 	xo_close_container("multicast-statistics");
3230fea3d51SYoshinobu Inoue }
324d84a1df4SHajimu UMEMOTO #endif /*INET6*/
325