]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Add a "ipsec listcounters" command to stroke
authorMartin Willi <martin@revosec.ch>
Mon, 8 Oct 2012 10:36:08 +0000 (12:36 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 24 Oct 2012 09:34:31 +0000 (11:34 +0200)
src/ipsec/_ipsec.in
src/libcharon/plugins/stroke/stroke_counter.c
src/libcharon/plugins/stroke/stroke_socket.c
src/stroke/stroke.c
src/stroke/stroke_keywords.h
src/stroke/stroke_keywords.txt
src/stroke/stroke_msg.h

index 2acf5a3f635c282a573faa93099b88e8f1f0b3c2..8b6ad660dad649807c0b7caa8d69c740bda623d7 100644 (file)
@@ -59,7 +59,7 @@ case "$1" in
        echo "  listalgs|listpubkeys|listcerts [--utc]"
        echo "  listcacerts|listaacerts|listocspcerts [--utc]"
        echo "  listacerts|listgroups|listcainfos [--utc]"
-       echo "  listcrls|listocsp|listcards|listplugins|listall [--utc]"
+       echo "  listcrls|listocsp|listcards|listplugins|listcounters|listall [--utc]"
        echo "  leases [<poolname> [<address>]]"
        echo "  rereadsecrets|rereadgroups"
        echo "  rereadcacerts|rereadaacerts|rereadocspcerts"
@@ -149,7 +149,7 @@ leases)
 listalgs|listpubkeys|listplugins|\
 listcerts|listcacerts|listaacerts|\
 listacerts|listgroups|listocspcerts|\
-listcainfos|listcrls|listocsp|listall|\
+listcainfos|listcrls|listocsp|listcounters|listall|\
 rereadsecrets|rereadcacerts|rereadaacerts|\
 rereadacerts|rereadocspcerts|rereadcrls|\
 rereadall|purgeocsp)
index 6e30a9f029625f020ccebce88c55f45b08d83cc5..56eda945a11d42af12eeed1da84ae0daf5ea0f55 100644 (file)
@@ -213,6 +213,8 @@ METHOD(stroke_counter_t, print, void,
        }
        this->lock->unlock(this->lock);
 
+       fprintf(out, "\nList of IKE counters:\n\n");
+
        /* but do blocking write without the lock. */
        for (i = 0; i < countof(this->counter); i++)
        {
index 777378ac5fd6b0fd6790d551358d50037c8900d0..14f36cde55d3e11eb8f1ee4784212738312cee12 100644 (file)
@@ -395,6 +395,10 @@ static void stroke_list(private_stroke_socket_t *this, stroke_msg_t *msg, FILE *
                this->ca->list(this->ca, msg, out);
        }
        this->list->list(this->list, msg, out);
+       if (msg->list.flags & LIST_COUNTERS)
+       {
+               this->counter->print(this->counter, out);
+       }
 }
 
 /**
index 03890b5173a6641a2017ac574967a3c63ca3c802..5dae53ea293d25e1f59a5041e43c34d0cb36df70 100644 (file)
@@ -265,6 +265,7 @@ static int list_flags[] = {
        LIST_OCSP,
        LIST_ALGS,
        LIST_PLUGINS,
+       LIST_COUNTERS,
        LIST_ALL
 };
 
@@ -363,7 +364,6 @@ static int user_credentials(char *name, char *user, char *pass)
        return send_stroke_msg(&msg);
 }
 
-
 static int set_loglevel(char *type, u_int level)
 {
        stroke_msg_t msg;
@@ -418,7 +418,7 @@ static void exit_usage(char *error)
        printf("  Show list of authority and attribute certificates:\n");
        printf("    stroke listcacerts|listocspcerts|listaacerts|listacerts\n");
        printf("  Show list of end entity certificates, ca info records  and crls:\n");
-       printf("    stroke listcerts|listcainfos|listcrls|listall\n");
+       printf("    stroke listcerts|listcainfos|listcrls|listcounters|listall\n");
        printf("  Show list of supported algorithms:\n");
        printf("    stroke listalgs\n");
        printf("  Reload authority and attribute certificates:\n");
@@ -552,6 +552,7 @@ int main(int argc, char *argv[])
                case STROKE_LIST_OCSP:
                case STROKE_LIST_ALGS:
                case STROKE_LIST_PLUGINS:
+               case STROKE_LIST_COUNTERS:
                case STROKE_LIST_ALL:
                        res = list(token->kw, argc > 2 && strcmp(argv[2], "--utc") == 0);
                        break;
index 554d071f3b6d65ccec4478f4e28a0f7916126e03..0ad87b7056ba6dfa660496a3297496da31b5cb4f 100644 (file)
@@ -42,6 +42,7 @@ typedef enum {
        STROKE_LIST_OCSP,
        STROKE_LIST_ALGS,
        STROKE_LIST_PLUGINS,
+       STROKE_LIST_COUNTERS,
        STROKE_LIST_ALL,
        STROKE_REREAD_SECRETS,
        STROKE_REREAD_CACERTS,
index 1d7ab8a45c45e2984505fa5120dc3a5f6ba92bc6..95b2981d90a0d40fb87339423d9d04b4fb691a2d 100644 (file)
@@ -49,6 +49,7 @@ listcrls,        STROKE_LIST_CRLS
 listocsp,        STROKE_LIST_OCSP
 listalgs,        STROKE_LIST_ALGS
 listplugins,     STROKE_LIST_PLUGINS
+listcounters,    STROKE_LIST_COUNTERS
 listall,         STROKE_LIST_ALL
 rereadsecrets,   STROKE_REREAD_SECRETS
 rereadcacerts,   STROKE_REREAD_CACERTS
index 662feed6969c620a328dc45ec25ae6632de1b3dc..1ce44f9eb45f5b2b57607e427f7dbcc9df778173 100644 (file)
@@ -67,8 +67,10 @@ enum list_flag_t {
        LIST_ALGS =                     0x0400,
        /** list plugin information */
        LIST_PLUGINS =          0x0800,
+       /** list IKE counters */
+       LIST_COUNTERS =         0x1000,
        /** all list options */
-       LIST_ALL =                      0x0FFF,
+       LIST_ALL =                      0x1FFF,
 };
 
 typedef enum reread_flag_t reread_flag_t;