]>
git.saurik.com Git - apple/network_cmds.git/blob - netstat.tproj/mroute.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright (c) 1989 Stephen Deering
26 * Copyright (c) 1992, 1993
27 * The Regents of the University of California. All rights reserved.
29 * This code is derived from software contributed to Berkeley by
30 * Stephen Deering of Stanford University.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)mroute.c 8.2 (Berkeley) 4/28/95
64 * Print DVMRP multicast routing structures and statistics.
69 #include <sys/param.h>
70 #include <sys/queue.h>
71 #include <sys/socket.h>
72 #include <sys/socketvar.h>
73 #include <sys/protosw.h>
78 #include <netinet/in.h>
79 #include <netinet/igmp.h>
80 #include <net/route.h>
81 #include <netinet/ip_mroute.h>
88 mroutepr(mfcaddr
, vifaddr
)
89 u_long mfcaddr
, vifaddr
;
92 struct mfc
*mfctable
[MFCTBLSIZ
];
93 struct vif viftable
[MAXVIFS
];
95 register struct vif
*v
;
98 register int banner_printed
;
99 register int saved_nflag
;
102 if (mfcaddr
== 0 || vifaddr
== 0) {
103 printf("No IPv4 multicast routing compiled into this system.\n");
110 kread(vifaddr
, (char *)&viftable
, sizeof(viftable
));
112 for (vifi
= 0, v
= viftable
; vifi
< MAXVIFS
; ++vifi
, ++v
) {
113 if (v
->v_lcl_addr
.s_addr
== 0)
117 if (!banner_printed
) {
118 printf("\nVirtual Interface Table\n"
119 " Vif Thresh Rate Local-Address "
120 "Remote-Address Pkts-In Pkts-Out\n");
124 printf(" %2u %6u %4d %-15.15s",
125 /* opposite math of add_vif() */
126 vifi
, v
->v_threshold
, v
->v_rate_limit
* 1000 / 1024,
127 routename(v
->v_lcl_addr
.s_addr
));
128 printf(" %-15.15s", (v
->v_flags
& VIFF_TUNNEL
) ?
129 routename(v
->v_rmt_addr
.s_addr
) : "");
131 printf(" %9lu %9lu\n", v
->v_pkt_in
, v
->v_pkt_out
);
134 printf("\nVirtual Interface Table is empty\n");
136 kread(mfcaddr
, (char *)&mfctable
, sizeof(mfctable
));
138 for (i
= 0; i
< MFCTBLSIZ
; ++i
) {
141 kread((u_long
)m
, (char *)&mfc
, sizeof mfc
);
143 if (!banner_printed
) {
144 printf("\nIPv4 Multicast Forwarding Cache\n"
146 " Packets In-Vif Out-Vifs:Ttls\n");
150 printf(" %-15.15s", routename(mfc
.mfc_origin
.s_addr
));
151 printf(" %-15.15s", routename(mfc
.mfc_mcastgrp
.s_addr
));
152 printf(" %9lu", mfc
.mfc_pkt_cnt
);
153 printf(" %3d ", mfc
.mfc_parent
);
154 for (vifi
= 0; vifi
<= maxvif
; vifi
++) {
155 if (mfc
.mfc_ttls
[vifi
] > 0)
156 printf(" %u:%u", vifi
,
164 printf("\nMulticast Routing Table is empty\n");
175 struct mrtstat mrtstat
;
178 printf("No IPv4 multicast routing compiled into this system.\n");
182 kread(mstaddr
, (char *)&mrtstat
, sizeof(mrtstat
));
183 printf("IPv4 multicast forwarding:\n");
184 printf(" %10lu multicast forwarding cache lookup%s\n",
185 mrtstat
.mrts_mfc_lookups
, plural(mrtstat
.mrts_mfc_lookups
));
186 printf(" %10lu multicast forwarding cache miss%s\n",
187 mrtstat
.mrts_mfc_misses
, plurales(mrtstat
.mrts_mfc_misses
));
188 printf(" %10lu upcall%s to mrouted\n",
189 mrtstat
.mrts_upcalls
, plural(mrtstat
.mrts_upcalls
));
190 printf(" %10lu upcall queue overflow%s\n",
191 mrtstat
.mrts_upq_ovflw
, plural(mrtstat
.mrts_upq_ovflw
));
192 printf(" %10lu upcall%s dropped due to full socket buffer\n",
193 mrtstat
.mrts_upq_sockfull
, plural(mrtstat
.mrts_upq_sockfull
));
194 printf(" %10lu cache cleanup%s\n",
195 mrtstat
.mrts_cache_cleanups
, plural(mrtstat
.mrts_cache_cleanups
));
196 printf(" %10lu datagram%s with no route for origin\n",
197 mrtstat
.mrts_no_route
, plural(mrtstat
.mrts_no_route
));
198 printf(" %10lu datagram%s arrived with bad tunneling\n",
199 mrtstat
.mrts_bad_tunnel
, plural(mrtstat
.mrts_bad_tunnel
));
200 printf(" %10lu datagram%s could not be tunneled\n",
201 mrtstat
.mrts_cant_tunnel
, plural(mrtstat
.mrts_cant_tunnel
));
202 printf(" %10lu datagram%s arrived on wrong interface\n",
203 mrtstat
.mrts_wrong_if
, plural(mrtstat
.mrts_wrong_if
));
204 printf(" %10lu datagram%s selectively dropped\n",
205 mrtstat
.mrts_drop_sel
, plural(mrtstat
.mrts_drop_sel
));
206 printf(" %10lu datagram%s dropped due to queue overflow\n",
207 mrtstat
.mrts_q_overflow
, plural(mrtstat
.mrts_q_overflow
));
208 printf(" %10lu datagram%s dropped for being too large\n",
209 mrtstat
.mrts_pkt2large
, plural(mrtstat
.mrts_pkt2large
));