Deleted Added
full compact
mroute.c (166951) mroute.c (171465)
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 *

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

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.2 (Berkeley) 4/28/95
38 */
39
40#include <sys/cdefs.h>
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 *

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

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.2 (Berkeley) 4/28/95
38 */
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD: head/usr.bin/netstat/mroute.c 166951 2007-02-24 21:56:52Z bms $");
41__FBSDID("$FreeBSD: head/usr.bin/netstat/mroute.c 171465 2007-07-16 17:15:55Z jhb $");
42
43/*
44 * Print multicast routing structures and statistics.
45 *
46 * MROUTING 1.0
47 */
48
49#include <sys/param.h>

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

79 vifi_t vifi;
80 int i;
81 int banner_printed;
82 int saved_numeric_addr;
83 vifi_t maxvif = 0;
84 size_t len;
85
86 len = sizeof(mfctable);
42
43/*
44 * Print multicast routing structures and statistics.
45 *
46 * MROUTING 1.0
47 */
48
49#include <sys/param.h>

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

79 vifi_t vifi;
80 int i;
81 int banner_printed;
82 int saved_numeric_addr;
83 vifi_t maxvif = 0;
84 size_t len;
85
86 len = sizeof(mfctable);
87 if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL, 0) < 0) {
88 warn("sysctl: net.inet.ip.mfctable");
89 if (mfcaddr == 0) {
90 printf("No IPv4 multicast forwarding configured in "
91 "the running system.\n");
87 if (live) {
88 if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL,
89 0) < 0) {
90 warn("sysctl: net.inet.ip.mfctable");
92 return;
93 }
91 return;
92 }
94 /*
95 * XXX: Try KVM if the module is neither compiled nor loaded.
96 * The correct behaviour would be to always use KVM if
97 * the -M option is specified to netstat(1).
98 */
93 } else
99 kread(mfcaddr, (char *)mfctable, sizeof(mfctable));
94 kread(mfcaddr, (char *)mfctable, sizeof(mfctable));
100 }
101
102 len = sizeof(viftable);
95
96 len = sizeof(viftable);
103 if (sysctlbyname("net.inet.ip.viftable", viftable, &len, NULL, 0) < 0) {
104 warn("sysctl: net.inet.ip.viftable");
105 if (vifaddr == 0) {
106 printf("No IPv4 multicast forwarding configured in "
107 "the running system.\n");
97 if (live) {
98 if (sysctlbyname("net.inet.ip.viftable", viftable, &len, NULL,
99 0) < 0) {
100 warn("sysctl: net.inet.ip.viftable");
108 return;
109 }
101 return;
102 }
110 /* XXX KVM */
103 } else
111 kread(vifaddr, (char *)viftable, sizeof(viftable));
104 kread(vifaddr, (char *)viftable, sizeof(viftable));
112 }
113
114 saved_numeric_addr = numeric_addr;
115 numeric_addr = 1;
116
117 banner_printed = 0;
118 for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
119 if (v->v_lcl_addr.s_addr == 0)
120 continue;

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

271}
272
273void
274mrt_stats(u_long mstaddr)
275{
276 struct mrtstat mrtstat;
277 size_t len = sizeof mrtstat;
278
105
106 saved_numeric_addr = numeric_addr;
107 numeric_addr = 1;
108
109 banner_printed = 0;
110 for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
111 if (v->v_lcl_addr.s_addr == 0)
112 continue;

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

263}
264
265void
266mrt_stats(u_long mstaddr)
267{
268 struct mrtstat mrtstat;
269 size_t len = sizeof mrtstat;
270
279 if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len,
280 NULL, 0) < 0) {
281 warn("sysctl: net.inet.ip.mrtstat");
282 /* Compatability with older kernels - candidate for removal */
283 if (mstaddr == 0) {
284 printf("No IPv4 multicast forwarding configured in "
285 "the running system.\n");
271 if (live) {
272 if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL,
273 0) < 0) {
274 warn("sysctl: net.inet.ip.mrtstat");
286 return;
287 }
275 return;
276 }
288 /* XXX KVM */
277 } else
289 kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
278 kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
290 }
279
291 printf("IPv4 multicast forwarding:\n");
292
293#define p(f, m) if (mrtstat.f || sflag <= 1) \
294 printf(m, mrtstat.f, plural(mrtstat.f))
295#define p2(f, m) if (mrtstat.f || sflag <= 1) \
296 printf(m, mrtstat.f, plurales(mrtstat.f))
297
298 p(mrts_mfc_lookups, "\t%lu multicast forwarding cache lookup%s\n");

--- 17 unchanged lines hidden ---
280 printf("IPv4 multicast forwarding:\n");
281
282#define p(f, m) if (mrtstat.f || sflag <= 1) \
283 printf(m, mrtstat.f, plural(mrtstat.f))
284#define p2(f, m) if (mrtstat.f || sflag <= 1) \
285 printf(m, mrtstat.f, plurales(mrtstat.f))
286
287 p(mrts_mfc_lookups, "\t%lu multicast forwarding cache lookup%s\n");

--- 17 unchanged lines hidden ---