1/* 2 * Copyright (c) 1989 Stephen Deering 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Stephen Deering of Stanford University. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by the University of 20 * California, Berkeley and its contributors. 21 * 4. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)mroute.c 8.1 (Berkeley) 6/6/93 38 */ 39 40/* 41 * Print DVMRP multicast routing structures and statistics. 42 * 43 * MROUTING 1.0 44 */ 45 46#include <sys/param.h> 47#include <sys/socket.h> 48#include <sys/socketvar.h> 49#include <sys/protosw.h> 50
| 1/* 2 * Copyright (c) 1989 Stephen Deering 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Stephen Deering of Stanford University. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by the University of 20 * California, Berkeley and its contributors. 21 * 4. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)mroute.c 8.1 (Berkeley) 6/6/93 38 */ 39 40/* 41 * Print DVMRP multicast routing structures and statistics. 42 * 43 * MROUTING 1.0 44 */ 45 46#include <sys/param.h> 47#include <sys/socket.h> 48#include <sys/socketvar.h> 49#include <sys/protosw.h> 50
|
| 51#include <net/if.h>
|
51#include <netinet/in.h> 52#include <netinet/igmp.h> 53#define KERNEL 1 54#include <netinet/ip_mroute.h> 55#undef KERNEL 56 57#include <stdio.h> 58#include <stdlib.h> 59#include "netstat.h" 60 61void 62mroutepr(mrpaddr, mrtaddr, vifaddr) 63 u_long mrpaddr, mrtaddr, vifaddr; 64{
| 52#include <netinet/in.h> 53#include <netinet/igmp.h> 54#define KERNEL 1 55#include <netinet/ip_mroute.h> 56#undef KERNEL 57 58#include <stdio.h> 59#include <stdlib.h> 60#include "netstat.h" 61 62void 63mroutepr(mrpaddr, mrtaddr, vifaddr) 64 u_long mrpaddr, mrtaddr, vifaddr; 65{
|
| 66#if 0
|
65 u_int mrtproto; 66 struct mrt *mrttable[MRTHASHSIZ]; 67 struct vif viftable[MAXVIFS]; 68 register struct mrt *mrt; 69 struct mrt smrt; 70 register struct vif *v; 71 register vifi_t vifi; 72 register struct in_addr *grp; 73 register int i, n; 74 register int banner_printed; 75 register int saved_nflag; 76 77 if (mrpaddr == 0) { 78 printf("ip_mrtproto: symbol not in namelist\n"); 79 return; 80 } 81 82 kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto)); 83 switch (mrtproto) { 84 85 case 0: 86 printf("no multicast routing compiled into this system\n"); 87 return; 88 89 case IGMP_DVMRP: 90 break; 91 92 default: 93 printf("multicast routing protocol %u, unknown\n", mrtproto); 94 return; 95 } 96 97 if (mrtaddr == 0) { 98 printf("mrttable: symbol not in namelist\n"); 99 return; 100 } 101 if (vifaddr == 0) { 102 printf("viftable: symbol not in namelist\n"); 103 return; 104 } 105 106 saved_nflag = nflag; 107 nflag = 1; 108 109 kread(vifaddr, (char *)&viftable, sizeof(viftable)); 110 banner_printed = 0; 111 for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) { 112 if (v->v_lcl_addr.s_addr == 0) 113 continue; 114 115 if (!banner_printed) { 116 printf("\nVirtual Interface Table\n%s%s", 117 " Vif Threshold Local-Address ", 118 "Remote-Address Groups\n"); 119 banner_printed = 1; 120 } 121 122 printf(" %2u %3u %-15.15s", 123 vifi, v->v_threshold, routename(v->v_lcl_addr.s_addr)); 124 printf(" %-15.15s\n", (v->v_flags & VIFF_TUNNEL) ? 125 routename(v->v_rmt_addr.s_addr) : ""); 126 127 n = v->v_lcl_grps_n; 128 grp = (struct in_addr *)malloc(n * sizeof(*grp)); 129 if (grp == NULL) { 130 printf("v_lcl_grps_n: malloc failed\n"); 131 return; 132 } 133 kread((u_long)v->v_lcl_grps, (caddr_t)grp, n * sizeof(*grp)); 134 for (i = 0; i < n; ++i) 135 printf("%51s %-15.15s\n", 136 "", routename((grp++)->s_addr)); 137 free(grp); 138 } 139 if (!banner_printed) 140 printf("\nVirtual Interface Table is empty\n"); 141 142 kread(mrtaddr, (char *)&mrttable, sizeof(mrttable)); 143 banner_printed = 0; 144 for (i = 0; i < MRTHASHSIZ; ++i) { 145 for (mrt = mrttable[i]; mrt != NULL; mrt = mrt->mrt_next) { 146 if (!banner_printed) { 147 printf("\nMulticast Routing Table\n%s", 148 " Hash Origin-Subnet In-Vif Out-Vifs\n"); 149 banner_printed = 1; 150 } 151 152 kread((u_long)mrt, (char *)&smrt, sizeof(*mrt)); 153 mrt = &smrt; 154 printf(" %3u %-15.15s %2u ", 155 i, netname(mrt->mrt_origin.s_addr, 156 ntohl(mrt->mrt_originmask.s_addr)), 157 mrt->mrt_parent); 158 for (vifi = 0; vifi < MAXVIFS; ++vifi) 159 if (VIFM_ISSET(vifi, mrt->mrt_children)) 160 printf(" %u%c", 161 vifi, 162 VIFM_ISSET(vifi, mrt->mrt_leaves) ? 163 '*' : ' '); 164 printf("\n"); 165 } 166 } 167 if (!banner_printed) 168 printf("\nMulticast Routing Table is empty\n"); 169 170 printf("\n"); 171 nflag = saved_nflag;
| 67 u_int mrtproto; 68 struct mrt *mrttable[MRTHASHSIZ]; 69 struct vif viftable[MAXVIFS]; 70 register struct mrt *mrt; 71 struct mrt smrt; 72 register struct vif *v; 73 register vifi_t vifi; 74 register struct in_addr *grp; 75 register int i, n; 76 register int banner_printed; 77 register int saved_nflag; 78 79 if (mrpaddr == 0) { 80 printf("ip_mrtproto: symbol not in namelist\n"); 81 return; 82 } 83 84 kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto)); 85 switch (mrtproto) { 86 87 case 0: 88 printf("no multicast routing compiled into this system\n"); 89 return; 90 91 case IGMP_DVMRP: 92 break; 93 94 default: 95 printf("multicast routing protocol %u, unknown\n", mrtproto); 96 return; 97 } 98 99 if (mrtaddr == 0) { 100 printf("mrttable: symbol not in namelist\n"); 101 return; 102 } 103 if (vifaddr == 0) { 104 printf("viftable: symbol not in namelist\n"); 105 return; 106 } 107 108 saved_nflag = nflag; 109 nflag = 1; 110 111 kread(vifaddr, (char *)&viftable, sizeof(viftable)); 112 banner_printed = 0; 113 for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) { 114 if (v->v_lcl_addr.s_addr == 0) 115 continue; 116 117 if (!banner_printed) { 118 printf("\nVirtual Interface Table\n%s%s", 119 " Vif Threshold Local-Address ", 120 "Remote-Address Groups\n"); 121 banner_printed = 1; 122 } 123 124 printf(" %2u %3u %-15.15s", 125 vifi, v->v_threshold, routename(v->v_lcl_addr.s_addr)); 126 printf(" %-15.15s\n", (v->v_flags & VIFF_TUNNEL) ? 127 routename(v->v_rmt_addr.s_addr) : ""); 128 129 n = v->v_lcl_grps_n; 130 grp = (struct in_addr *)malloc(n * sizeof(*grp)); 131 if (grp == NULL) { 132 printf("v_lcl_grps_n: malloc failed\n"); 133 return; 134 } 135 kread((u_long)v->v_lcl_grps, (caddr_t)grp, n * sizeof(*grp)); 136 for (i = 0; i < n; ++i) 137 printf("%51s %-15.15s\n", 138 "", routename((grp++)->s_addr)); 139 free(grp); 140 } 141 if (!banner_printed) 142 printf("\nVirtual Interface Table is empty\n"); 143 144 kread(mrtaddr, (char *)&mrttable, sizeof(mrttable)); 145 banner_printed = 0; 146 for (i = 0; i < MRTHASHSIZ; ++i) { 147 for (mrt = mrttable[i]; mrt != NULL; mrt = mrt->mrt_next) { 148 if (!banner_printed) { 149 printf("\nMulticast Routing Table\n%s", 150 " Hash Origin-Subnet In-Vif Out-Vifs\n"); 151 banner_printed = 1; 152 } 153 154 kread((u_long)mrt, (char *)&smrt, sizeof(*mrt)); 155 mrt = &smrt; 156 printf(" %3u %-15.15s %2u ", 157 i, netname(mrt->mrt_origin.s_addr, 158 ntohl(mrt->mrt_originmask.s_addr)), 159 mrt->mrt_parent); 160 for (vifi = 0; vifi < MAXVIFS; ++vifi) 161 if (VIFM_ISSET(vifi, mrt->mrt_children)) 162 printf(" %u%c", 163 vifi, 164 VIFM_ISSET(vifi, mrt->mrt_leaves) ? 165 '*' : ' '); 166 printf("\n"); 167 } 168 } 169 if (!banner_printed) 170 printf("\nMulticast Routing Table is empty\n"); 171 172 printf("\n"); 173 nflag = saved_nflag;
|
| 174#else 175 printf("this isn't supported yet\n"); 176#endif
|
172} 173 174 175void 176mrt_stats(mrpaddr, mstaddr) 177 u_long mrpaddr, mstaddr; 178{ 179 u_int mrtproto; 180 struct mrtstat mrtstat; 181 182 if(mrpaddr == 0) { 183 printf("ip_mrtproto: symbol not in namelist\n"); 184 return; 185 } 186 187 kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto)); 188 switch (mrtproto) { 189 case 0: 190 printf("no multicast routing compiled into this system\n"); 191 return; 192 193 case IGMP_DVMRP: 194 break; 195 196 default: 197 printf("multicast routing protocol %u, unknown\n", mrtproto); 198 return; 199 } 200 201 if (mstaddr == 0) { 202 printf("mrtstat: symbol not in namelist\n"); 203 return; 204 } 205 206 kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat)); 207 printf("multicast routing:\n");
| 177} 178 179 180void 181mrt_stats(mrpaddr, mstaddr) 182 u_long mrpaddr, mstaddr; 183{ 184 u_int mrtproto; 185 struct mrtstat mrtstat; 186 187 if(mrpaddr == 0) { 188 printf("ip_mrtproto: symbol not in namelist\n"); 189 return; 190 } 191 192 kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto)); 193 switch (mrtproto) { 194 case 0: 195 printf("no multicast routing compiled into this system\n"); 196 return; 197 198 case IGMP_DVMRP: 199 break; 200 201 default: 202 printf("multicast routing protocol %u, unknown\n", mrtproto); 203 return; 204 } 205 206 if (mstaddr == 0) { 207 printf("mrtstat: symbol not in namelist\n"); 208 return; 209 } 210 211 kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat)); 212 printf("multicast routing:\n");
|
208 printf(" %10u multicast route lookup%s\n", 209 mrtstat.mrts_mrt_lookups, plural(mrtstat.mrts_mrt_lookups)); 210 printf(" %10u multicast route cache miss%s\n", 211 mrtstat.mrts_mrt_misses, plurales(mrtstat.mrts_mrt_misses)); 212 printf(" %10u group address lookup%s\n", 213 mrtstat.mrts_grp_lookups, plural(mrtstat.mrts_grp_lookups)); 214 printf(" %10u group address cache miss%s\n", 215 mrtstat.mrts_grp_misses, plurales(mrtstat.mrts_grp_misses));
| 213 printf(" %10u multicast forwarding cache lookup%s\n", 214 mrtstat.mrts_mfc_lookups, plural(mrtstat.mrts_mfc_lookups)); 215 printf(" %10u multicast forwarding cache miss%s\n", 216 mrtstat.mrts_mfc_misses, plurales(mrtstat.mrts_mfc_misses)); 217 printf(" %10u upcall%s to mrouted\n", 218 mrtstat.mrts_upcalls, plural(mrtstat.mrts_upcalls)); 219 printf(" %10u upcall queue overflow%s\n", 220 mrtstat.mrts_upq_ovflw, plural(mrtstat.mrts_upq_ovflw)); 221 printf(" %10u cache cleanup%s\n", 222 mrtstat.mrts_cache_cleanups, plural(mrtstat.mrts_cache_cleanups));
|
216 printf(" %10u datagram%s with no route for origin\n", 217 mrtstat.mrts_no_route, plural(mrtstat.mrts_no_route)); 218 printf(" %10u datagram%s with malformed tunnel options\n", 219 mrtstat.mrts_bad_tunnel, plural(mrtstat.mrts_bad_tunnel)); 220 printf(" %10u datagram%s with no room for tunnel options\n", 221 mrtstat.mrts_cant_tunnel, plural(mrtstat.mrts_cant_tunnel));
| 223 printf(" %10u datagram%s with no route for origin\n", 224 mrtstat.mrts_no_route, plural(mrtstat.mrts_no_route)); 225 printf(" %10u datagram%s with malformed tunnel options\n", 226 mrtstat.mrts_bad_tunnel, plural(mrtstat.mrts_bad_tunnel)); 227 printf(" %10u datagram%s with no room for tunnel options\n", 228 mrtstat.mrts_cant_tunnel, plural(mrtstat.mrts_cant_tunnel));
|
| 229 printf(" %10u datagram%s arrived on wrong interface\n", 230 mrtstat.mrts_wrong_if, plural(mrtstat.mrts_wrong_if)); 231 printf(" %10u datagram%s selectively dropped\n", 232 mrtstat.mrts_drop_sel, plural(mrtstat.mrts_drop_sel)); 233 printf(" %10u datagram%s dropped due to queue overflow\n", 234 mrtstat.mrts_q_overflow, plural(mrtstat.mrts_q_overflow)); 235 printf(" %10u datagram%s dropped for being too large\n", 236 mrtstat.mrts_pkt2large, plural(mrtstat.mrts_pkt2large));
|
222}
| 237}
|