Add a "resetcounters" command to ipsec, clearing global or connection counters
This commit is contained in:
+6
-9
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -66,3 +66,4 @@ leases, STROKE_LEASES
|
||||
memusage, STROKE_MEMUSAGE
|
||||
user-creds, STROKE_USER_CREDS
|
||||
listcounters, STROKE_COUNTERS
|
||||
resetcounters, STROKE_COUNTERS_RESET
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user