Deleted Added
full compact
mroute6.c (166952) mroute6.c (171465)
1/*
2 * Copyright (C) 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 53 unchanged lines hidden (view full) ---

62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)mroute.c 8.2 (Berkeley) 4/28/95
67 */
68
69#include <sys/cdefs.h>
1/*
2 * Copyright (C) 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 53 unchanged lines hidden (view full) ---

62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)mroute.c 8.2 (Berkeley) 4/28/95
67 */
68
69#include <sys/cdefs.h>
70__FBSDID("$FreeBSD: head/usr.bin/netstat/mroute6.c 166952 2007-02-24 21:58:30Z bms $");
70__FBSDID("$FreeBSD: head/usr.bin/netstat/mroute6.c 171465 2007-07-16 17:15:55Z jhb $");
71
72#ifdef INET6
73#include <sys/param.h>
74#include <sys/queue.h>
75#include <sys/socket.h>
76#include <sys/socketvar.h>
77#include <sys/sysctl.h>
78#include <sys/protosw.h>

--- 32 unchanged lines hidden (view full) ---

111 int i;
112 int banner_printed;
113 int saved_numeric_addr;
114 mifi_t maxmif = 0;
115 long int waitings;
116 size_t len;
117
118 len = sizeof(mif6table);
71
72#ifdef INET6
73#include <sys/param.h>
74#include <sys/queue.h>
75#include <sys/socket.h>
76#include <sys/socketvar.h>
77#include <sys/sysctl.h>
78#include <sys/protosw.h>

--- 32 unchanged lines hidden (view full) ---

111 int i;
112 int banner_printed;
113 int saved_numeric_addr;
114 mifi_t maxmif = 0;
115 long int waitings;
116 size_t len;
117
118 len = sizeof(mif6table);
119 if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
120 NULL, 0) < 0) {
121 warn("sysctl: net.inet6.ip6.mif6table");
122 if (mifaddr == 0) {
123 printf("No IPv6 multicast forwarding configured in "
124 "the running system.\n");
119 if (live) {
120 if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
121 NULL, 0) < 0) {
122 warn("sysctl: net.inet6.ip6.mif6table");
125 return;
126 }
123 return;
124 }
125 } else
127 kread(mifaddr, (char *)mif6table, sizeof(mif6table));
126 kread(mifaddr, (char *)mif6table, sizeof(mif6table));
128 }
129
130 saved_numeric_addr = numeric_addr;
131 numeric_addr = 1;
132 banner_printed = 0;
133
134 for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
135 struct ifnet ifnet;
136 char ifname[IFNAMSIZ];

--- 19 unchanged lines hidden (view full) ---

156
157 printf(" %9ju %9ju\n", (uintmax_t)mifp->m6_pkt_in,
158 (uintmax_t)mifp->m6_pkt_out);
159 }
160 if (!banner_printed)
161 printf("\nIPv6 Multicast Interface Table is empty\n");
162
163 len = sizeof(mf6ctable);
127
128 saved_numeric_addr = numeric_addr;
129 numeric_addr = 1;
130 banner_printed = 0;
131
132 for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
133 struct ifnet ifnet;
134 char ifname[IFNAMSIZ];

--- 19 unchanged lines hidden (view full) ---

154
155 printf(" %9ju %9ju\n", (uintmax_t)mifp->m6_pkt_in,
156 (uintmax_t)mifp->m6_pkt_out);
157 }
158 if (!banner_printed)
159 printf("\nIPv6 Multicast Interface Table is empty\n");
160
161 len = sizeof(mf6ctable);
164 if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len,
165 NULL, 0) < 0) {
166 warn("sysctl: net.inet6.ip6.mf6ctable");
167 if (mfcaddr == 0) {
168 printf("No IPv6 multicast forwarding configured in "
169 "the running system.\n");
162 if (live) {
163 if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len,
164 NULL, 0) < 0) {
165 warn("sysctl: net.inet6.ip6.mf6ctable");
170 return;
171 }
166 return;
167 }
172 /*
173 * XXX: Try KVM if the module is neither compiled nor loaded.
174 * The correct behaviour would be to always use KVM if
175 * the -M option is specified to netstat(1).
176 */
168 } else
177 kread(mfcaddr, (char *)mf6ctable, sizeof(mf6ctable));
169 kread(mfcaddr, (char *)mf6ctable, sizeof(mf6ctable));
178 }
179
180 banner_printed = 0;
181
182 for (i = 0; i < MF6CTBLSIZ; ++i) {
183 mfcp = mf6ctable[i];
184 while(mfcp) {
185 kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
186 if (!banner_printed) {

--- 40 unchanged lines hidden (view full) ---

227}
228
229void
230mrt6_stats(u_long mstaddr)
231{
232 struct mrt6stat mrtstat;
233 size_t len = sizeof mrtstat;
234
170
171 banner_printed = 0;
172
173 for (i = 0; i < MF6CTBLSIZ; ++i) {
174 mfcp = mf6ctable[i];
175 while(mfcp) {
176 kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
177 if (!banner_printed) {

--- 40 unchanged lines hidden (view full) ---

218}
219
220void
221mrt6_stats(u_long mstaddr)
222{
223 struct mrt6stat mrtstat;
224 size_t len = sizeof mrtstat;
225
235 if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
236 NULL, 0) < 0) {
237 warn("sysctl: net.inet6.ip6.mrt6stat");
238 if (mstaddr == 0) {
239 printf("No IPv6 multicast forwarding configured in the "
240 "running system.\n");
226 if (live) {
227 if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
228 NULL, 0) < 0) {
229 warn("sysctl: net.inet6.ip6.mrt6stat");
241 return;
242 }
230 return;
231 }
232 } else
243 kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
233 kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
244 }
234
245 printf("IPv6 multicast forwarding:\n");
246
247#define p(f, m) if (mrtstat.f || sflag <= 1) \
248 printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
249#define p2(f, m) if (mrtstat.f || sflag <= 1) \
250 printf(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
251
252 p(mrt6s_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");

--- 19 unchanged lines hidden ---
235 printf("IPv6 multicast forwarding:\n");
236
237#define p(f, m) if (mrtstat.f || sflag <= 1) \
238 printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
239#define p2(f, m) if (mrtstat.f || sflag <= 1) \
240 printf(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
241
242 p(mrt6s_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");

--- 19 unchanged lines hidden ---