1 /* $NetBSD: mroute6.c,v 1.11 2003/08/07 11:15:21 agc Exp $ */
4 * Copyright (C) 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * Copyright (c) 1992, 1993
34 * The Regents of the University of California. All rights reserved.
36 * This code is derived from software contributed to Berkeley by
37 * Stephen Deering of Stanford University.
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)mroute.c 8.2 (Berkeley) 4/28/95
67 * Copyright (c) 1989 Stephen Deering
69 * This code is derived from software contributed to Berkeley by
70 * Stephen Deering of Stanford University.
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
75 * 1. Redistributions of source code must retain the above copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 3. All advertising materials mentioning features or use of this software
81 * must display the following acknowledgement:
82 * This product includes software developed by the University of
83 * California, Berkeley and its contributors.
84 * 4. Neither the name of the University nor the names of its contributors
85 * may be used to endorse or promote products derived from this software
86 * without specific prior written permission.
88 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
89 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
90 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
91 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
92 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
93 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
94 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
95 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
96 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
97 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * @(#)mroute.c 8.2 (Berkeley) 4/28/95
103 #include <sys/param.h>
104 #include <sys/queue.h>
105 #include <sys/socket.h>
106 #include <sys/socketvar.h>
107 #include <sys/protosw.h>
111 #include <netinet/in.h>
114 #include <netinet6/ip6_mroute.h>
123 #define WID_ORG (lflag ? 39 : (numeric_addr ? 29 : 18)) /* width of origin column */
124 #define WID_GRP (lflag ? 18 : (numeric_addr ? 16 : 18)) /* width of group column */
127 mroute6pr(mrpaddr
, mfcaddr
, mifaddr
)
128 u_long mrpaddr
, mfcaddr
, mifaddr
;
131 struct mf6c
*mf6ctable
[MF6CTBLSIZ
], *mfcp
;
132 struct mif6 mif6table
[MAXMIFS
];
134 struct rtdetq rte
, *rtep
;
135 register struct mif6
*mifp
;
136 register mifi_t mifi
;
138 register int banner_printed
;
139 register int saved_numeric_addr
;
144 printf("mroute6pr: symbol not in namelist\n");
148 kread(mrpaddr
, (char *)&mrtproto
, sizeof(mrtproto
));
151 printf("no IPv6 multicast routing compiled into this system\n");
158 printf("IPv6 multicast routing protocol %u, unknown\n",
164 printf("mf6ctable: symbol not in namelist\n");
168 printf("miftable: symbol not in namelist\n");
172 saved_numeric_addr
= numeric_addr
;
175 kread(mifaddr
, (char *)&mif6table
, sizeof(mif6table
));
177 for (mifi
= 0, mifp
= mif6table
; mifi
< MAXMIFS
; ++mifi
, ++mifp
) {
179 char ifname
[IFNAMSIZ
];
181 if (mifp
->m6_ifp
== NULL
)
184 kread((u_long
)mifp
->m6_ifp
, (char *)&ifnet
, sizeof(ifnet
));
186 if (!banner_printed
) {
187 printf("\nIPv6 Multicast Interface Table\n"
188 " Mif Rate PhyIF Pkts-In Pkts-Out\n");
192 printf(" %2u %4d", mifi
, mifp
->m6_rate_limit
);
193 printf(" %5s", (mifp
->m6_flags
& MIFF_REGISTER
) ?
194 "reg0" : if_indextoname(ifnet
.if_index
, ifname
));
196 printf(" %9llu %9llu\n", (unsigned long long)mifp
->m6_pkt_in
,
197 (unsigned long long)mifp
->m6_pkt_out
);
200 printf("\nIPv6 Multicast Interface Table is empty\n");
202 kread(mfcaddr
, (char *)&mf6ctable
, sizeof(mf6ctable
));
204 for (i
= 0; i
< MF6CTBLSIZ
; ++i
) {
207 kread((u_long
)mfcp
, (char *)&mfc
, sizeof(mfc
));
208 if (!banner_printed
) {
209 printf ("\nIPv6 Multicast Forwarding Cache\n");
210 printf(" %-*.*s %-*.*s %s",
211 WID_ORG
, WID_ORG
, "Origin",
212 WID_GRP
, WID_GRP
, "Group",
213 " Packets Waits In-Mif Out-Mifs\n");
217 printf(" %-*.*s", WID_ORG
, WID_ORG
,
218 routename6(&mfc
.mf6c_origin
));
219 printf(" %-*.*s", WID_GRP
, WID_GRP
,
220 routename6(&mfc
.mf6c_mcastgrp
));
221 printf(" %9llu", (unsigned long long)mfc
.mf6c_pkt_cnt
);
223 for (waitings
= 0, rtep
= mfc
.mf6c_stall
; rtep
; ) {
225 kread((u_long
)rtep
, (char *)&rte
, sizeof(rte
));
228 printf(" %3d", waitings
);
230 if (mfc
.mf6c_parent
== MF6C_INCOMPLETE_PARENT
)
233 printf(" %3d ", mfc
.mf6c_parent
);
234 for (mifi
= 0; mifi
<= MAXMIFS
; mifi
++) {
235 if (IF_ISSET(mifi
, &mfc
.mf6c_ifset
))
240 mfcp
= mfc
.mf6c_next
;
244 printf("\nIPv6 Multicast Routing Table is empty\n");
247 numeric_addr
= saved_numeric_addr
;
251 mrt6_stats(mrpaddr
, mstaddr
)
252 u_long mrpaddr
, mstaddr
;
254 #define p(f, m) printf(m, (unsigned long long)mrtstat.f, plural(mrtstat.f))
255 #define pes(f, m) printf(m, (unsigned long long)mrtstat.f, plurales(mrtstat.f))
257 struct mrt6stat mrtstat
;
260 printf("mrt6_stats: symbol not in namelist\n");
264 kread(mrpaddr
, (char *)&mrtproto
, sizeof(mrtproto
));
267 printf("no IPv6 multicast routing compiled into this system\n");
274 printf("IPv6 multicast routing protocol %u, unknown\n",
280 printf("mrt6_stats: symbol not in namelist\n");
284 kread(mstaddr
, (char *)&mrtstat
, sizeof(mrtstat
));
285 printf("multicast forwarding:\n");
286 p(mrt6s_mfc_lookups
, " %10llu multicast forwarding cache lookup%s\n");
287 pes(mrt6s_mfc_misses
, " %10llu multicast forwarding cache miss%s\n");
288 p(mrt6s_upcalls
, " %10llu upcall%s to mrouted\n");
289 p(mrt6s_upq_ovflw
, " %10llu upcall queue overflow%s\n");
290 p(mrt6s_upq_sockfull
,
291 " %10llu upcall%s dropped due to full socket buffer\n");
292 p(mrt6s_cache_cleanups
, " %10llu cache cleanup%s\n");
293 p(mrt6s_no_route
, " %10llu datagram%s with no route for origin\n");
294 p(mrt6s_bad_tunnel
, " %10llu datagram%s arrived with bad tunneling\n");
295 p(mrt6s_cant_tunnel
, " %10llu datagram%s could not be tunneled\n");
296 p(mrt6s_wrong_if
, " %10llu datagram%s arrived on wrong interface\n");
297 p(mrt6s_drop_sel
, " %10llu datagram%s selectively dropped\n");
299 " %10llu datagram%s dropped due to queue overflow\n");
300 p(mrt6s_pkt2large
, " %10llu datagram%s dropped for being too large\n");