aboutsummaryrefslogtreecommitdiffstats
path: root/src/stroke
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-03-15 10:55:22 +0100
committerMartin Willi <martin@revosec.ch>2013-03-15 10:55:22 +0100
commitcf729248b28473b9651e347741d351cf0d34892f (patch)
treeffa05dd5a68b0fec088d779323fec34b36c45f33 /src/stroke
parentd022322bed29e0b6d1ca09edb891402d7e2cc73f (diff)
downloadstrongswan-cf729248b28473b9651e347741d351cf0d34892f.tar.bz2
strongswan-cf729248b28473b9651e347741d351cf0d34892f.tar.xz
Add a "resetcounters" command to ipsec, clearing global or connection counters
Diffstat (limited to 'src/stroke')
-rw-r--r--src/stroke/stroke.c15
-rw-r--r--src/stroke/stroke_keywords.h1
-rw-r--r--src/stroke/stroke_keywords.txt1
-rw-r--r--src/stroke/stroke_msg.h4
4 files changed, 11 insertions, 10 deletions
diff --git a/src/stroke/stroke.c b/src/stroke/stroke.c
index 1be275c28..c8c8e7cf7 100644
--- a/src/stroke/stroke.c
+++ b/src/stroke/stroke.c
@@ -364,13 +364,15 @@ static int user_credentials(char *name, char *user, char *pass)
return send_stroke_msg(&msg);
}
-static int counters(char *name)
+static int counters(int reset, char *name)
{
stroke_msg_t msg;
msg.type = STR_COUNTERS;
msg.length = offsetof(stroke_msg_t, buffer);
msg.counters.name = push_string(&msg, name);
+ msg.counters.reset = reset;
+
return send_stroke_msg(&msg);
}
@@ -605,14 +607,9 @@ int main(int argc, char *argv[])
res = user_credentials(argv[2], argv[3], argc > 4 ? argv[4] : NULL);
break;
case STROKE_COUNTERS:
- if (argc > 2)
- {
- res = counters(argv[2]);
- }
- else
- {
- res = counters(NULL);
- }
+ case STROKE_COUNTERS_RESET:
+ res = counters(token->kw == STROKE_COUNTERS_RESET,
+ argc > 2 ? argv[2] : NULL);
break;
default:
exit_usage(NULL);
diff --git a/src/stroke/stroke_keywords.h b/src/stroke/stroke_keywords.h
index 12abce1d3..f5979a0e5 100644
--- a/src/stroke/stroke_keywords.h
+++ b/src/stroke/stroke_keywords.h
@@ -59,6 +59,7 @@ typedef enum {
STROKE_MEMUSAGE,
STROKE_USER_CREDS,
STROKE_COUNTERS,
+ STROKE_COUNTERS_RESET,
} stroke_keyword_t;
#define STROKE_LIST_FIRST STROKE_LIST_PUBKEYS
diff --git a/src/stroke/stroke_keywords.txt b/src/stroke/stroke_keywords.txt
index 12c590962..5d2ebd9e2 100644
--- a/src/stroke/stroke_keywords.txt
+++ b/src/stroke/stroke_keywords.txt
@@ -66,3 +66,4 @@ leases, STROKE_LEASES
memusage, STROKE_MEMUSAGE
user-creds, STROKE_USER_CREDS
listcounters, STROKE_COUNTERS
+resetcounters, STROKE_COUNTERS_RESET
diff --git a/src/stroke/stroke_msg.h b/src/stroke/stroke_msg.h
index 494acba11..c415a92c3 100644
--- a/src/stroke/stroke_msg.h
+++ b/src/stroke/stroke_msg.h
@@ -223,7 +223,7 @@ struct stroke_msg_t {
STR_MEMUSAGE,
/* set username and password for a connection */
STR_USER_CREDS,
- /* print counters */
+ /* print/reset counters */
STR_COUNTERS,
/* more to come */
} type;
@@ -357,6 +357,8 @@ struct stroke_msg_t {
/* data for STR_COUNTERS */
struct {
+ /* reset or print counters? */
+ int reset;
char *name;
} counters;
};