ipsec.c (5e0517186d418529323a5eb007287145e4fd3b50) ipsec.c (f964d60dd3287932055bfdaadf3cba4a7ff2d648)
1/* $FreeBSD$ */
2/* $NetBSD: inet.c,v 1.35.2.1 1999/04/29 14:57:08 perry Exp $ */
3/* $KAME: ipsec.c,v 1.25 2001/03/12 09:04:39 itojun Exp $ */
4
5/*
6 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
7 * All rights reserved.
8 *

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

157 "x_spdsetidx", "x_spdexpire", "x_spddelete2"
158};
159
160static struct ipsecstat ipsecstat;
161
162static void print_ipsecstats (void);
163static const char *pfkey_msgtype_names (int);
164static void ipsec_hist (const u_quad_t *, size_t, const struct val2str *,
1/* $FreeBSD$ */
2/* $NetBSD: inet.c,v 1.35.2.1 1999/04/29 14:57:08 perry Exp $ */
3/* $KAME: ipsec.c,v 1.25 2001/03/12 09:04:39 itojun Exp $ */
4
5/*
6 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
7 * All rights reserved.
8 *

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

157 "x_spdsetidx", "x_spdexpire", "x_spddelete2"
158};
159
160static struct ipsecstat ipsecstat;
161
162static void print_ipsecstats (void);
163static const char *pfkey_msgtype_names (int);
164static void ipsec_hist (const u_quad_t *, size_t, const struct val2str *,
165 size_t, const char *);
165 const char *);
166
167/*
168 * Dump IPSEC statistics structure.
169 */
170static void
171ipsec_hist(const u_quad_t *hist,
172 size_t histmax,
173 const struct val2str *name,
166
167/*
168 * Dump IPSEC statistics structure.
169 */
170static void
171ipsec_hist(const u_quad_t *hist,
172 size_t histmax,
173 const struct val2str *name,
174 size_t namemax,
175 const char *title)
176{
177 int first;
178 size_t proto;
179 const struct val2str *p;
180
181 first = 1;
182 for (proto = 0; proto < histmax; proto++) {
183 if (hist[proto] <= 0)
184 continue;
185 if (first) {
186 printf("\t%s histogram:\n", title);
187 first = 0;
188 }
189 for (p = name; p && p->str; p++) {
174 const char *title)
175{
176 int first;
177 size_t proto;
178 const struct val2str *p;
179
180 first = 1;
181 for (proto = 0; proto < histmax; proto++) {
182 if (hist[proto] <= 0)
183 continue;
184 if (first) {
185 printf("\t%s histogram:\n", title);
186 first = 0;
187 }
188 for (p = name; p && p->str; p++) {
190 if (p->val == proto)
189 if (p->val == (int)proto)
191 break;
192 }
193 if (p && p->str) {
194 printf("\t\t%s: " LLU "\n", p->str, (CAST)hist[proto]);
195 } else {
196 printf("\t\t#%ld: " LLU "\n", (long)proto,
197 (CAST)hist[proto]);
198 }
199 }
200}
201
202static void
203print_ipsecstats(void)
204{
205#define p(f, m) if (ipsecstat.f || sflag <= 1) \
206 printf(m, (CAST)ipsecstat.f, plural(ipsecstat.f))
207#define hist(f, n, t) \
190 break;
191 }
192 if (p && p->str) {
193 printf("\t\t%s: " LLU "\n", p->str, (CAST)hist[proto]);
194 } else {
195 printf("\t\t#%ld: " LLU "\n", (long)proto,
196 (CAST)hist[proto]);
197 }
198 }
199}
200
201static void
202print_ipsecstats(void)
203{
204#define p(f, m) if (ipsecstat.f || sflag <= 1) \
205 printf(m, (CAST)ipsecstat.f, plural(ipsecstat.f))
206#define hist(f, n, t) \
208 ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), sizeof(n)/sizeof(n[0]), (t));
207 ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), (t));
209
210 p(in_success, "\t" LLU " inbound packet%s processed successfully\n");
211 p(in_polvio, "\t" LLU " inbound packet%s violated process security "
212 "policy\n");
213 p(in_nosa, "\t" LLU " inbound packet%s with no SA available\n");
214 p(in_inval, "\t" LLU " invalid inbound packet%s\n");
215 p(in_nomem, "\t" LLU " inbound packet%s failed due to insufficient memory\n");
216 p(in_badspi, "\t" LLU " inbound packet%s failed getting SPI\n");

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

232 hist(ipsecstat.out_ahhist, ipsec_ahnames, "AH output");
233 hist(ipsecstat.out_esphist, ipsec_espnames, "ESP output");
234 hist(ipsecstat.out_comphist, ipsec_compnames, "IPComp output");
235#undef p
236#undef hist
237}
238
239void
208
209 p(in_success, "\t" LLU " inbound packet%s processed successfully\n");
210 p(in_polvio, "\t" LLU " inbound packet%s violated process security "
211 "policy\n");
212 p(in_nosa, "\t" LLU " inbound packet%s with no SA available\n");
213 p(in_inval, "\t" LLU " invalid inbound packet%s\n");
214 p(in_nomem, "\t" LLU " inbound packet%s failed due to insufficient memory\n");
215 p(in_badspi, "\t" LLU " inbound packet%s failed getting SPI\n");

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

231 hist(ipsecstat.out_ahhist, ipsec_ahnames, "AH output");
232 hist(ipsecstat.out_esphist, ipsec_espnames, "ESP output");
233 hist(ipsecstat.out_comphist, ipsec_compnames, "IPComp output");
234#undef p
235#undef hist
236}
237
238void
240ipsec_stats(u_long off, char *name)
239ipsec_stats(u_long off __unused, char *name, int af __unused)
241{
242 if (off == 0)
243 return;
244 printf ("%s:\n", name);
245 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
246
247 print_ipsecstats();
248}

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

256
257 if (x < max && pfkey_msgtypenames[x])
258 return pfkey_msgtypenames[x];
259 snprintf(buf, sizeof(buf), "#%d", x);
260 return buf;
261}
262
263void
240{
241 if (off == 0)
242 return;
243 printf ("%s:\n", name);
244 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
245
246 print_ipsecstats();
247}

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

255
256 if (x < max && pfkey_msgtypenames[x])
257 return pfkey_msgtypenames[x];
258 snprintf(buf, sizeof(buf), "#%d", x);
259 return buf;
260}
261
262void
264pfkey_stats(u_long off, char *name)
263pfkey_stats(u_long off __unused, char *name, int af __unused)
265{
266 struct pfkeystat pfkeystat;
264{
265 struct pfkeystat pfkeystat;
267 int first, type;
266 unsigned first, type;
268
269 if (off == 0)
270 return;
271 printf ("%s:\n", name);
272 kread(off, (char *)&pfkeystat, sizeof(pfkeystat));
273
274#define p(f, m) if (pfkeystat.f || sflag <= 1) \
275 printf(m, (CAST)pfkeystat.f, plural(pfkeystat.f))

--- 51 unchanged lines hidden ---
267
268 if (off == 0)
269 return;
270 printf ("%s:\n", name);
271 kread(off, (char *)&pfkeystat, sizeof(pfkeystat));
272
273#define p(f, m) if (pfkeystat.f || sflag <= 1) \
274 printf(m, (CAST)pfkeystat.f, plural(pfkeystat.f))

--- 51 unchanged lines hidden ---