inet.c (94f138fe6022bf3cb80608ece005ea315cbd081f) | inet.c (d10910e6cee0dca8be3d5a7fdbe404a15d9e7b52) |
---|---|
1/*- 2 * Copyright (c) 1983, 1988, 1993, 1995 3 * The Regents of the University of California. 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 --- 983 unchanged lines hidden (view full) --- 992 if (sysctlbyname("net.inet.icmp.maskrepl", &i, &len, NULL, 0) < 993 0) 994 return; 995 printf("\tICMP address mask responses are %sabled\n", 996 i ? "en" : "dis"); 997 } 998} 999 | 1/*- 2 * Copyright (c) 1983, 1988, 1993, 1995 3 * The Regents of the University of California. 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 --- 983 unchanged lines hidden (view full) --- 992 if (sysctlbyname("net.inet.icmp.maskrepl", &i, &len, NULL, 0) < 993 0) 994 return; 995 printf("\tICMP address mask responses are %sabled\n", 996 i ? "en" : "dis"); 997 } 998} 999 |
1000#ifndef BURN_BRIDGES |
|
1000/* | 1001/* |
1001 * Dump IGMP statistics structure. | 1002 * Dump IGMP statistics structure (pre 8.x kernel). |
1002 */ | 1003 */ |
1003void 1004igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) | 1004static void 1005igmp_stats_live_old(u_long off, const char *name) |
1005{ | 1006{ |
1006 struct igmpstat igmpstat, zerostat; 1007 size_t len = sizeof igmpstat; | 1007 struct oigmpstat oigmpstat, zerostat; 1008 size_t len = sizeof(oigmpstat); |
1008 | 1009 |
1009 if (live) { 1010 if (zflag) 1011 memset(&zerostat, 0, len); 1012 if (sysctlbyname("net.inet.igmp.stats", &igmpstat, &len, 1013 zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { 1014 warn("sysctl: net.inet.igmp.stats"); 1015 return; 1016 } 1017 } else 1018 kread(off, &igmpstat, len); | 1010 if (zflag) 1011 memset(&zerostat, 0, len); 1012 if (sysctlbyname("net.inet.igmp.stats", &oigmpstat, &len, 1013 zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { 1014 warn("sysctl: net.inet.igmp.stats"); 1015 return; 1016 } |
1019 1020 printf("%s:\n", name); 1021 | 1017 1018 printf("%s:\n", name); 1019 |
1022#define p(f, m) if (igmpstat.f || sflag <= 1) \ 1023 printf(m, igmpstat.f, plural(igmpstat.f)) 1024#define py(f, m) if (igmpstat.f || sflag <= 1) \ 1025 printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y") | 1020#define p(f, m) if (oigmpstat.f || sflag <= 1) \ 1021 printf(m, oigmpstat.f, plural(oigmpstat.f)) 1022#define py(f, m) if (oigmpstat.f || sflag <= 1) \ 1023 printf(m, oigmpstat.f, oigmpstat.f != 1 ? "ies" : "y") |
1026 p(igps_rcv_total, "\t%u message%s received\n"); 1027 p(igps_rcv_tooshort, "\t%u message%s received with too few bytes\n"); 1028 p(igps_rcv_badsum, "\t%u message%s received with bad checksum\n"); 1029 py(igps_rcv_queries, "\t%u membership quer%s received\n"); 1030 py(igps_rcv_badqueries, 1031 "\t%u membership quer%s received with invalid field(s)\n"); 1032 p(igps_rcv_reports, "\t%u membership report%s received\n"); 1033 p(igps_rcv_badreports, 1034 "\t%u membership report%s received with invalid field(s)\n"); 1035 p(igps_rcv_ourreports, 1036"\t%u membership report%s received for groups to which we belong\n"); 1037 p(igps_snd_reports, "\t%u membership report%s sent\n"); 1038#undef p 1039#undef py 1040} | 1024 p(igps_rcv_total, "\t%u message%s received\n"); 1025 p(igps_rcv_tooshort, "\t%u message%s received with too few bytes\n"); 1026 p(igps_rcv_badsum, "\t%u message%s received with bad checksum\n"); 1027 py(igps_rcv_queries, "\t%u membership quer%s received\n"); 1028 py(igps_rcv_badqueries, 1029 "\t%u membership quer%s received with invalid field(s)\n"); 1030 p(igps_rcv_reports, "\t%u membership report%s received\n"); 1031 p(igps_rcv_badreports, 1032 "\t%u membership report%s received with invalid field(s)\n"); 1033 p(igps_rcv_ourreports, 1034"\t%u membership report%s received for groups to which we belong\n"); 1035 p(igps_snd_reports, "\t%u membership report%s sent\n"); 1036#undef p 1037#undef py 1038} |
1039#endif /* !BURN_BRIDGES */ |
|
1041 1042/* | 1040 1041/* |
1042 * Dump IGMP statistics structure. 1043 */ 1044void 1045igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) 1046{ 1047 struct igmpstat igmpstat, zerostat; 1048 size_t len; 1049 1050#ifndef BURN_BRIDGES 1051 if (live) { 1052 /* 1053 * Detect if we are being run against a pre-IGMPv3 kernel. 1054 * We cannot do this for a core file as the legacy 1055 * struct igmpstat has no size field, nor does it 1056 * export it in any readily-available symbols. 1057 */ 1058 len = 0; 1059 if (sysctlbyname("net.inet.igmp.stats", NULL, &len, NULL, 1060 0) < 0) { 1061 warn("sysctl: net.inet.igmp.stats"); 1062 return; 1063 } 1064 if (len < sizeof(igmpstat)) { 1065 igmp_stats_live_old(off, name); 1066 return; 1067 } 1068 } 1069#endif /* !BURN_BRIDGES */ 1070 1071 len = sizeof(igmpstat); 1072 if (live) { 1073 if (zflag) 1074 memset(&zerostat, 0, len); 1075 if (sysctlbyname("net.inet.igmp.stats", &igmpstat, &len, 1076 zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { 1077 warn("sysctl: net.inet.igmp.stats"); 1078 return; 1079 } 1080 } else { 1081 len = sizeof(igmpstat); 1082 kread(off, &igmpstat, len); 1083 } 1084 1085 if (igmpstat.igps_version != IGPS_VERSION_3) { 1086 warnx("%s: version mismatch (%d != %d)", __func__, 1087 igmpstat.igps_version, IGPS_VERSION_3); 1088 } 1089 if (igmpstat.igps_len != IGPS_VERSION3_LEN) { 1090 warnx("%s: size mismatch (%d != %d)", __func__, 1091 igmpstat.igps_len, IGPS_VERSION3_LEN); 1092 } 1093 1094 printf("%s:\n", name); 1095 1096#define p64(f, m) if (igmpstat.f || sflag <= 1) \ 1097 printf(m, (uintmax_t) igmpstat.f, plural(igmpstat.f)) 1098#define py64(f, m) if (igmpstat.f || sflag <= 1) \ 1099 printf(m, (uintmax_t) igmpstat.f, pluralies(igmpstat.f)) 1100 p64(igps_rcv_total, "\t%ju message%s received\n"); 1101 p64(igps_rcv_tooshort, "\t%ju message%s received with too few bytes\n"); 1102 p64(igps_rcv_badttl, "\t%ju message%s received with wrong TTL\n"); 1103 p64(igps_rcv_badsum, "\t%ju message%s received with bad checksum\n"); 1104 py64(igps_rcv_v1v2_queries, "\t%ju V1/V2 membership quer%s received\n"); 1105 py64(igps_rcv_v3_queries, "\t%ju V3 membership quer%s received\n"); 1106 py64(igps_rcv_badqueries, 1107 "\t%ju membership quer%s received with invalid field(s)\n"); 1108 py64(igps_rcv_gen_queries, "\t%ju general quer%s received\n"); 1109 py64(igps_rcv_group_queries, "\t%ju group quer%s received\n"); 1110 py64(igps_rcv_gsr_queries, "\t%ju group-source quer%s received\n"); 1111 py64(igps_drop_gsr_queries, "\t%ju group-source quer%s dropped\n"); 1112 p64(igps_rcv_reports, "\t%ju membership report%s received\n"); 1113 p64(igps_rcv_badreports, 1114 "\t%ju membership report%s received with invalid field(s)\n"); 1115 p64(igps_rcv_ourreports, 1116"\t%ju membership report%s received for groups to which we belong\n"); 1117 p64(igps_rcv_nora, "\t%ju V3 report%s received without Router Alert\n"); 1118 p64(igps_snd_reports, "\t%ju membership report%s sent\n"); 1119#undef p64 1120#undef py64 1121} 1122 1123/* |
|
1043 * Dump PIM statistics structure. 1044 */ 1045void 1046pim_stats(u_long off __unused, const char *name, int af1 __unused, 1047 int proto __unused) 1048{ 1049 struct pimstat pimstat, zerostat; 1050 size_t len = sizeof pimstat; --- 109 unchanged lines hidden --- | 1124 * Dump PIM statistics structure. 1125 */ 1126void 1127pim_stats(u_long off __unused, const char *name, int af1 __unused, 1128 int proto __unused) 1129{ 1130 struct pimstat pimstat, zerostat; 1131 size_t len = sizeof pimstat; --- 109 unchanged lines hidden --- |