2 * Copyright (c) 1989 Stephen Deering
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Stephen Deering of Stanford University.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * @(#)mroute.c 8.1 (Berkeley) 6/6/93
43 * Print DVMRP multicast routing structures and statistics.
48 #ifdef ENABLE_MULTICAST
49 #include <sys/param.h>
50 #include <sys/socket.h>
51 #include <sys/socketvar.h>
52 #include <sys/protosw.h>
55 #include <netinet/in.h>
56 #include <netinet/igmp.h>
58 #include <netinet/ip_mroute.h>
66 mroutepr(mrpaddr
, mrtaddr
, vifaddr
)
67 u_long mrpaddr
, mrtaddr
, vifaddr
;
71 struct mrt
*mrttable
[MRTHASHSIZ
];
72 struct vif viftable
[MAXVIFS
];
73 register struct mrt
*mrt
;
75 register struct vif
*v
;
77 register struct in_addr
*grp
;
79 register int banner_printed
;
80 register int saved_nflag
;
83 printf("ip_mrtproto: symbol not in namelist\n");
87 kread(mrpaddr
, (char *)&mrtproto
, sizeof(mrtproto
));
91 printf("no multicast routing compiled into this system\n");
98 printf("multicast routing protocol %u, unknown\n", mrtproto
);
103 printf("mrttable: symbol not in namelist\n");
107 printf("viftable: symbol not in namelist\n");
114 kread(vifaddr
, (char *)&viftable
, sizeof(viftable
));
116 for (vifi
= 0, v
= viftable
; vifi
< MAXVIFS
; ++vifi
, ++v
) {
117 if (v
->v_lcl_addr
.s_addr
== 0)
120 if (!banner_printed
) {
121 printf("\nVirtual Interface Table\n%s%s",
122 " Vif Threshold Local-Address ",
123 "Remote-Address Groups\n");
127 printf(" %2u %3u %-15.15s",
128 vifi
, v
->v_threshold
, routename(v
->v_lcl_addr
.s_addr
));
129 printf(" %-15.15s\n", (v
->v_flags
& VIFF_TUNNEL
) ?
130 routename(v
->v_rmt_addr
.s_addr
) : "");
133 grp
= (struct in_addr
*)malloc(n
* sizeof(*grp
));
135 printf("v_lcl_grps_n: malloc failed\n");
138 kread((u_long
)v
->v_lcl_grps
, (caddr_t
)grp
, n
* sizeof(*grp
));
139 for (i
= 0; i
< n
; ++i
)
140 printf("%51s %-15.15s\n",
141 "", routename((grp
++)->s_addr
));
145 printf("\nVirtual Interface Table is empty\n");
147 kread(mrtaddr
, (char *)&mrttable
, sizeof(mrttable
));
149 for (i
= 0; i
< MRTHASHSIZ
; ++i
) {
150 for (mrt
= mrttable
[i
]; mrt
!= NULL
; mrt
= mrt
->mrt_next
) {
151 if (!banner_printed
) {
152 printf("\nMulticast Routing Table\n%s",
153 " Hash Origin-Subnet In-Vif Out-Vifs\n");
157 kread((u_long
)mrt
, (char *)&smrt
, sizeof(*mrt
));
159 printf(" %3u %-15.15s %2u ",
160 i
, netname(mrt
->mrt_origin
.s_addr
,
161 ntohl(mrt
->mrt_originmask
.s_addr
)),
163 for (vifi
= 0; vifi
< MAXVIFS
; ++vifi
)
164 if (VIFM_ISSET(vifi
, mrt
->mrt_children
))
167 VIFM_ISSET(vifi
, mrt
->mrt_leaves
) ?
173 printf("\nMulticast Routing Table is empty\n");
178 printf("this isn't supported yet\n");
184 mrt_stats(mrpaddr
, mstaddr
)
185 u_long mrpaddr
, mstaddr
;
188 struct mrtstat mrtstat
;
191 printf("ip_mrtproto: symbol not in namelist\n");
195 kread(mrpaddr
, (char *)&mrtproto
, sizeof(mrtproto
));
198 printf("no multicast routing compiled into this system\n");
205 printf("multicast routing protocol %u, unknown\n", mrtproto
);
210 printf("mrtstat: symbol not in namelist\n");
214 kread(mstaddr
, (char *)&mrtstat
, sizeof(mrtstat
));
215 printf("multicast routing:\n");
216 printf(" %10u multicast forwarding cache lookup%s\n",
217 mrtstat
.mrts_mfc_lookups
, plural(mrtstat
.mrts_mfc_lookups
));
218 printf(" %10u multicast forwarding cache miss%s\n",
219 mrtstat
.mrts_mfc_misses
, plurales(mrtstat
.mrts_mfc_misses
));
220 printf(" %10u upcall%s to mrouted\n",
221 mrtstat
.mrts_upcalls
, plural(mrtstat
.mrts_upcalls
));
222 printf(" %10u upcall queue overflow%s\n",
223 mrtstat
.mrts_upq_ovflw
, plural(mrtstat
.mrts_upq_ovflw
));
224 printf(" %10u cache cleanup%s\n",
225 mrtstat
.mrts_cache_cleanups
, plural(mrtstat
.mrts_cache_cleanups
));
226 printf(" %10u datagram%s with no route for origin\n",
227 mrtstat
.mrts_no_route
, plural(mrtstat
.mrts_no_route
));
228 printf(" %10u datagram%s with malformed tunnel options\n",
229 mrtstat
.mrts_bad_tunnel
, plural(mrtstat
.mrts_bad_tunnel
));
230 printf(" %10u datagram%s with no room for tunnel options\n",
231 mrtstat
.mrts_cant_tunnel
, plural(mrtstat
.mrts_cant_tunnel
));
232 printf(" %10u datagram%s arrived on wrong interface\n",
233 mrtstat
.mrts_wrong_if
, plural(mrtstat
.mrts_wrong_if
));
234 printf(" %10u datagram%s selectively dropped\n",
235 mrtstat
.mrts_drop_sel
, plural(mrtstat
.mrts_drop_sel
));
236 printf(" %10u datagram%s dropped due to queue overflow\n",
237 mrtstat
.mrts_q_overflow
, plural(mrtstat
.mrts_q_overflow
));
238 printf(" %10u datagram%s dropped for being too large\n",
239 mrtstat
.mrts_pkt2large
, plural(mrtstat
.mrts_pkt2large
));