Deleted Added
full compact
ipsec.c (62584) ipsec.c (78064)
1/* $FreeBSD: head/usr.bin/netstat/ipsec.c 62584 2000-07-04 16:26:46Z itojun $ */
1/* $FreeBSD: head/usr.bin/netstat/ipsec.c 78064 2001-06-11 12:39:29Z ume $ */
2/* $NetBSD: inet.c,v 1.35.2.1 1999/04/29 14:57:08 perry Exp $ */
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 $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

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

58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE.
64 */
65
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
10 * modification, are permitted provided that the following conditions
11 * are met:

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

59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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
67#include <sys/cdefs.h>
66#ifndef lint
67/*
68static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
69*/
70static const char rcsid[] =
68#ifndef lint
69/*
70static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
71*/
72static const char rcsid[] =
71 "$FreeBSD: head/usr.bin/netstat/ipsec.c 62584 2000-07-04 16:26:46Z itojun $";
73 "$FreeBSD: head/usr.bin/netstat/ipsec.c 78064 2001-06-11 12:39:29Z ume $";
72#endif /* not lint */
73
74#include <sys/param.h>
75#include <sys/queue.h>
76#include <sys/socket.h>
77
78#include <netinet/in.h>
79

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

94 */
95/*
96 * XXX see PORTABILITY for the twist
97 */
98#define LLU "%llu"
99#define CAST unsigned long long
100
101#ifdef IPSEC
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

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

96 */
97/*
98 * XXX see PORTABILITY for the twist
99 */
100#define LLU "%llu"
101#define CAST unsigned long long
102
103#ifdef IPSEC
102static const char *ipsec_ahnames[] = {
103 "none",
104 "hmac MD5",
105 "hmac SHA1",
106 "keyed MD5",
107 "keyed SHA1",
108 "null",
104struct val2str {
105 int val;
106 const char *str;
109};
110
107};
108
111static const char *ipsec_espnames[] = {
112 "none",
113 "DES CBC",
114 "3DES CBC",
115 "simple",
116 "blowfish CBC",
117 "CAST128 CBC",
118 "DES derived IV",
109static struct val2str ipsec_ahnames[] = {
110 { SADB_AALG_NONE, "none", },
111 { SADB_AALG_MD5HMAC, "hmac-md5", },
112 { SADB_AALG_SHA1HMAC, "hmac-sha1", },
113 { SADB_X_AALG_MD5, "md5", },
114 { SADB_X_AALG_SHA, "sha", },
115 { SADB_X_AALG_NULL, "null", },
116#ifdef SADB_X_AALG_SHA2_256
117 { SADB_X_AALG_SHA2_256, "hmac-sha2-256", },
118#endif
119#ifdef SADB_X_AALG_SHA2_384
120 { SADB_X_AALG_SHA2_384, "hmac-sha2-384", },
121#endif
122#ifdef SADB_X_AALG_SHA2_512
123 { SADB_X_AALG_SHA2_512, "hmac-sha2-512", },
124#endif
125 { -1, NULL },
119};
120
126};
127
121static const char *ipsec_compnames[] = {
122 "none",
123 "OUI",
124 "deflate",
125 "LZS",
128static struct val2str ipsec_espnames[] = {
129 { SADB_EALG_NONE, "none", },
130 { SADB_EALG_DESCBC, "des-cbc", },
131 { SADB_EALG_3DESCBC, "3des-cbc", },
132 { SADB_EALG_NULL, "null", },
133#ifdef SADB_X_EALG_RC5CBC
134 { SADB_X_EALG_RC5CBC, "rc5-cbc", },
135#endif
136 { SADB_X_EALG_CAST128CBC, "cast128-cbc", },
137 { SADB_X_EALG_BLOWFISHCBC, "blowfish-cbc", },
138#ifdef SADB_X_EALG_RIJNDAELCBC
139 { SADB_X_EALG_RIJNDAELCBC, "rijndael-cbc", },
140#endif
141 { -1, NULL },
126};
127
142};
143
144static struct val2str ipsec_compnames[] = {
145 { SADB_X_CALG_NONE, "none", },
146 { SADB_X_CALG_OUI, "oui", },
147 { SADB_X_CALG_DEFLATE, "deflate", },
148 { SADB_X_CALG_LZS, "lzs", },
149 { -1, NULL },
150};
151
128static const char *pfkey_msgtypenames[] = {
129 "reserved", "getspi", "update", "add", "delete",
130 "get", "acquire", "register", "expire", "flush",
131 "dump", "x_promisc", "x_pchange", "x_spdupdate", "x_spdadd",
132 "x_spddelete", "x_spdget", "x_spdacquire", "x_spddump", "x_spdflush",
133 "x_spdsetidx", "x_spdexpire", "x_spddelete2"
134};
135
136static struct ipsecstat ipsecstat;
137
138static void print_ipsecstats __P((void));
139static const char *pfkey_msgtype_names __P((int));
152static const char *pfkey_msgtypenames[] = {
153 "reserved", "getspi", "update", "add", "delete",
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));
140static void ipsec_hist __P((const u_quad_t *, size_t, const char **, size_t,
141 const char *));
164static void ipsec_hist __P((const u_quad_t *, size_t, const struct val2str *,
165 size_t, const char *));
142
143/*
144 * Dump IPSEC statistics structure.
145 */
146static void
147ipsec_hist(hist, histmax, name, namemax, title)
148 const u_quad_t *hist;
149 size_t histmax;
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;
150 const char **name;
174 const struct val2str *name;
151 size_t namemax;
152 const char *title;
153{
154 int first;
155 size_t proto;
175 size_t namemax;
176 const char *title;
177{
178 int first;
179 size_t proto;
180 const struct val2str *p;
156
181
157 for (first = 1, proto = 0; proto < histmax; proto++) {
182 first = 1;
183 for (proto = 0; proto < histmax; proto++) {
158 if (hist[proto] <= 0)
159 continue;
160 if (first) {
161 printf("\t%s histogram:\n", title);
162 first = 0;
163 }
184 if (hist[proto] <= 0)
185 continue;
186 if (first) {
187 printf("\t%s histogram:\n", title);
188 first = 0;
189 }
164 if (proto < namemax && name[proto]) {
165 printf("\t\t%s: " LLU "\n", name[proto],
166 (CAST)hist[proto]);
190 for (p = name; p && p->str; p++) {
191 if (p->val == proto)
192 break;
193 }
194 if (p && p->str) {
195 printf("\t\t%s: " LLU "\n", p->str, (CAST)hist[proto]);
167 } else {
168 printf("\t\t#%ld: " LLU "\n", (long)proto,
196 } else {
197 printf("\t\t#%ld: " LLU "\n", (long)proto,
169 (CAST)hist[proto]);
198 (CAST)hist[proto]);
170 }
171 }
172}
173
174static void
175print_ipsecstats()
176{
177#define p(f, m) if (ipsecstat.f || sflag <= 1) \

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

216 if (off == 0)
217 return;
218 printf ("%s:\n", name);
219 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
220
221 print_ipsecstats();
222}
223
199 }
200 }
201}
202
203static void
204print_ipsecstats()
205{
206#define p(f, m) if (ipsecstat.f || sflag <= 1) \

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

245 if (off == 0)
246 return;
247 printf ("%s:\n", name);
248 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
249
250 print_ipsecstats();
251}
252
224#if defined(__bsdi__) && _BSDI_VERSION >= 199802 /* bsdi4 only */
225void
226ipsec_stats0(name)
227 char *name;
228{
229 printf("%s:\n", name);
230
231 skread(name, &ipsecstat_info);
232
233 print_ipsecstats();
234}
235#endif
236
237static const char *
238pfkey_msgtype_names(x)
239 int x;
240{
241 const int max =
242 sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]);
243 static char buf[10];
244

--- 72 unchanged lines hidden ---
253static const char *
254pfkey_msgtype_names(x)
255 int x;
256{
257 const int max =
258 sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]);
259 static char buf[10];
260

--- 72 unchanged lines hidden ---