Deleted Added
full compact
ipsec.c (78309) ipsec.c (78314)
1/* $FreeBSD: head/usr.bin/netstat/ipsec.c 78309 2001-06-15 23:07:59Z assar $ */
1/* $FreeBSD: head/usr.bin/netstat/ipsec.c 78314 2001-06-15 23:35:13Z assar $ */
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 *
9 * Redistribution and use in source and binary forms, with or without

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

65 */
66
67#include <sys/cdefs.h>
68#ifndef lint
69/*
70static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
71*/
72static const char rcsid[] =
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 *
9 * Redistribution and use in source and binary forms, with or without

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

65 */
66
67#include <sys/cdefs.h>
68#ifndef lint
69/*
70static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
71*/
72static const char rcsid[] =
73 "$FreeBSD: head/usr.bin/netstat/ipsec.c 78309 2001-06-15 23:07:59Z assar $";
73 "$FreeBSD: head/usr.bin/netstat/ipsec.c 78314 2001-06-15 23:35:13Z assar $";
74#endif /* not lint */
75
76#include <sys/param.h>
77#include <sys/queue.h>
78#include <sys/socket.h>
79
80#include <netinet/in.h>
81

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

154 "get", "acquire", "register", "expire", "flush",
155 "dump", "x_promisc", "x_pchange", "x_spdupdate", "x_spdadd",
156 "x_spddelete", "x_spdget", "x_spdacquire", "x_spddump", "x_spdflush",
157 "x_spdsetidx", "x_spdexpire", "x_spddelete2"
158};
159
160static struct ipsecstat ipsecstat;
161
74#endif /* not lint */
75
76#include <sys/param.h>
77#include <sys/queue.h>
78#include <sys/socket.h>
79
80#include <netinet/in.h>
81

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

154 "get", "acquire", "register", "expire", "flush",
155 "dump", "x_promisc", "x_pchange", "x_spdupdate", "x_spdadd",
156 "x_spddelete", "x_spdget", "x_spdacquire", "x_spddump", "x_spdflush",
157 "x_spdsetidx", "x_spdexpire", "x_spddelete2"
158};
159
160static struct ipsecstat ipsecstat;
161
162static void print_ipsecstats __P((void));
163static const char *pfkey_msgtype_names __P((int));
164static void ipsec_hist __P((const u_quad_t *, size_t, const struct val2str *,
165 size_t, const char *));
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 *);
166
167/*
168 * Dump IPSEC statistics structure.
169 */
170static void
166
167/*
168 * Dump IPSEC statistics structure.
169 */
170static void
171ipsec_hist(hist, histmax, name, namemax, title)
172 const u_quad_t *hist;
173 size_t histmax;
174 const struct val2str *name;
175 size_t namemax;
176 const char *title;
171ipsec_hist(const u_quad_t *hist,
172 size_t histmax,
173 const struct val2str *name,
174 size_t namemax,
175 const char *title)
177{
178 int first;
179 size_t proto;
180 const struct val2str *p;
181
182 first = 1;
183 for (proto = 0; proto < histmax; proto++) {
184 if (hist[proto] <= 0)

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

196 } else {
197 printf("\t\t#%ld: " LLU "\n", (long)proto,
198 (CAST)hist[proto]);
199 }
200 }
201}
202
203static void
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)

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

195 } else {
196 printf("\t\t#%ld: " LLU "\n", (long)proto,
197 (CAST)hist[proto]);
198 }
199 }
200}
201
202static void
204print_ipsecstats()
203print_ipsecstats(void)
205{
206#define p(f, m) if (ipsecstat.f || sflag <= 1) \
207 printf(m, (CAST)ipsecstat.f, plural(ipsecstat.f))
208#define hist(f, n, t) \
209 ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), sizeof(n)/sizeof(n[0]), (t));
210
211 p(in_success, "\t" LLU " inbound packet%s processed successfully\n");
212 p(in_polvio, "\t" LLU " inbound packet%s violated process security "

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

233 hist(ipsecstat.out_ahhist, ipsec_ahnames, "AH output");
234 hist(ipsecstat.out_esphist, ipsec_espnames, "ESP output");
235 hist(ipsecstat.out_comphist, ipsec_compnames, "IPComp output");
236#undef p
237#undef hist
238}
239
240void
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) \
208 ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), sizeof(n)/sizeof(n[0]), (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 "

--- 20 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
241ipsec_stats(off, name)
242 u_long off;
243 char *name;
240ipsec_stats(u_long off, char *name)
244{
245 if (off == 0)
246 return;
247 printf ("%s:\n", name);
248 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
249
250 print_ipsecstats();
251}
252
253static const char *
241{
242 if (off == 0)
243 return;
244 printf ("%s:\n", name);
245 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
246
247 print_ipsecstats();
248}
249
250static const char *
254pfkey_msgtype_names(x)
255 int x;
251pfkey_msgtype_names(int x)
256{
257 const int max =
258 sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]);
259 static char buf[10];
260
261 if (x < max && pfkey_msgtypenames[x])
262 return pfkey_msgtypenames[x];
263 snprintf(buf, sizeof(buf), "#%d", x);
264 return buf;
265}
266
267void
252{
253 const int max =
254 sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]);
255 static char buf[10];
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
268pfkey_stats(off, name)
269 u_long off;
270 char *name;
264pfkey_stats(u_long off, char *name)
271{
272 struct pfkeystat pfkeystat;
273 int first, type;
274
275 if (off == 0)
276 return;
277 printf ("%s:\n", name);
278 kread(off, (char *)&pfkeystat, sizeof(pfkeystat));

--- 54 unchanged lines hidden ---
265{
266 struct pfkeystat pfkeystat;
267 int first, type;
268
269 if (off == 0)
270 return;
271 printf ("%s:\n", name);
272 kread(off, (char *)&pfkeystat, sizeof(pfkeystat));

--- 54 unchanged lines hidden ---