Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.bin/netstat pullup 1.7 -> 1.8 (approved by releng-1-5)



details:   https://anonhg.NetBSD.org/src/rev/09e7d8379a1b
branches:  netbsd-1-5
changeset: 488699:09e7d8379a1b
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Jul 25 04:26:45 2000 +0000

description:
pullup 1.7 -> 1.8 (approved by releng-1-5)
do not rely upon algorithm ordering in pfkey spec. sync with kame

diffstat:

 usr.bin/netstat/ipsec.c |  82 +++++++++++++++++++++++++++++-------------------
 1 files changed, 50 insertions(+), 32 deletions(-)

diffs (149 lines):

diff -r 4b9d818a44d8 -r 09e7d8379a1b usr.bin/netstat/ipsec.c
--- a/usr.bin/netstat/ipsec.c   Tue Jul 25 04:26:15 2000 +0000
+++ b/usr.bin/netstat/ipsec.c   Tue Jul 25 04:26:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.c,v 1.1 2000/02/26 09:55:24 itojun Exp $ */
+/*     $NetBSD: ipsec.c,v 1.1.4.1 2000/07/25 04:26:45 itojun Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -68,7 +68,7 @@
 static char sccsid[] = "from: @(#)inet.c       8.4 (Berkeley) 4/20/94";
 #else
 #ifdef __NetBSD__
-__RCSID("$NetBSD: ipsec.c,v 1.1 2000/02/26 09:55:24 itojun Exp $");
+__RCSID("$NetBSD: ipsec.c,v 1.1.4.1 2000/07/25 04:26:45 itojun Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -97,7 +97,10 @@
 #ifdef __bsdi__
 #define plural(x)      PLURAL(x)
 #endif
-#ifdef __FreeBSD__
+/*
+ * XXX see PORTABILITY for the twist
+ */
+#if defined(__FreeBSD__) && __FreeBSD__ < 3
 #define LLU    "%qu"
 #define CAST   u_quad_t
 #else
@@ -106,30 +109,40 @@
 #endif
 
 #ifdef IPSEC 
-static const char *ipsec_ahnames[] = {
-       "none",
-       "hmac MD5",
-       "hmac SHA1",
-       "keyed MD5",
-       "keyed SHA1",
-       "null",
+struct val2str {
+       int val;
+       const char *str;
+};
+
+static struct val2str ipsec_ahnames[] = {
+       { SADB_AALG_NONE, "none", },
+       { SADB_AALG_MD5HMAC, "hmac-md5", },
+       { SADB_AALG_SHA1HMAC, "hmac-sha1", },
+       { SADB_X_AALG_MD5, "md5", },
+       { SADB_X_AALG_SHA, "sha", },
+       { SADB_X_AALG_NULL, "null", },
+       { -1, NULL },
 };
 
-static const char *ipsec_espnames[] = {
-       "none",
-       "DES CBC",
-       "3DES CBC",
-       "simple",
-       "blowfish CBC",
-       "CAST128 CBC",
-       "DES derived IV",
+static struct val2str ipsec_espnames[] = {
+       { SADB_EALG_NONE, "none", },
+       { SADB_EALG_DESCBC, "des-cbc", },
+       { SADB_EALG_3DESCBC, "3des-cbc", },
+       { SADB_EALG_NULL, "null", },
+#ifdef SADB_X_EALG_RC5CBC
+       { SADB_X_EALG_RC5CBC, "rc5-cbc", },
+#endif
+       { SADB_X_EALG_CAST128CBC, "cast128-cbc", },
+       { SADB_X_EALG_BLOWFISHCBC, "blowfish-cbc", },
+       { -1, NULL },
 };
 
-static const char *ipsec_compnames[] = {
-       "none",
-       "OUI",
-       "deflate",
-       "LZS",
+static struct val2str ipsec_compnames[] = {
+       { SADB_X_CALG_NONE, "none", },
+       { SADB_X_CALG_OUI, "oui", },
+       { SADB_X_CALG_DEFLATE, "deflate", },
+       { SADB_X_CALG_LZS, "lzs", },
+       { -1, NULL },
 };
 
 static const char *pfkey_msgtypenames[] = {
@@ -137,7 +150,7 @@
        "get", "acquire", "register", "expire", "flush",
        "dump", "x_promisc", "x_pchange", "x_spdupdate", "x_spdadd",
        "x_spddelete", "x_spdget", "x_spdacquire", "x_spddump", "x_spdflush",
-       "x_spdsetidx", "x_spdexpire",
+       "x_spdsetidx", "x_spdexpire", "x_spddelete2"
 };
 
 static struct ipsecstat ipsecstat;
@@ -152,8 +165,8 @@
 
 static void print_ipsecstats __P((void));
 static const char *pfkey_msgtype_names __P((int));
-static void ipsec_hist __P((const u_quad_t *, size_t, const char **, size_t,
-       const char *));
+static void ipsec_hist __P((const u_quad_t *, size_t, const struct val2str *,
+       size_t, const char *));
 
 /*
  * Dump IPSEC statistics structure.
@@ -162,26 +175,31 @@
 ipsec_hist(hist, histmax, name, namemax, title)
        const u_quad_t *hist;
        size_t histmax;
-       const char **name;
+       const struct val2str *name;
        size_t namemax;
        const char *title;
 {
        int first;
        size_t proto;
+       const struct val2str *p;
 
-       for (first = 1, proto = 0; proto < histmax; proto++) {
+       first = 1;
+       for (proto = 0; proto < histmax; proto++) {
                if (hist[proto] <= 0)
                        continue;
                if (first) {
                        printf("\t%s histogram:\n", title);
                        first = 0;
                }
-               if (proto < namemax && name[proto]) {
-                       printf("\t\t%s: " LLU "\n", name[proto],
-                               (CAST)hist[proto]);
+               for (p = name; p && p->str; p++) {
+                       if (p->val == proto)
+                               break;
+               }
+               if (p && p->str) {
+                       printf("\t\t%s: " LLU "\n", p->str, (CAST)hist[proto]);
                } else {
                        printf("\t\t#%ld: " LLU "\n", (long)proto,
-                               (CAST)hist[proto]);
+                           (CAST)hist[proto]);
                }
        }
 }



Home | Main Index | Thread Index | Old Index