Merge branch 'stroke-counters'
Extend stroke counters functionality by connection specific counters, and a resetcounters command to reset the global or connection counters.
This commit is contained in:
+20
-3
@@ -268,7 +268,6 @@ static int list_flags[] = {
|
||||
LIST_OCSP,
|
||||
LIST_ALGS,
|
||||
LIST_PLUGINS,
|
||||
LIST_COUNTERS,
|
||||
LIST_ALL
|
||||
};
|
||||
|
||||
@@ -367,6 +366,18 @@ static int user_credentials(char *name, char *user, char *pass)
|
||||
return send_stroke_msg(&msg);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static int set_loglevel(char *type, u_int level)
|
||||
{
|
||||
stroke_msg_t msg;
|
||||
@@ -421,7 +432,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|listcounters|listall\n");
|
||||
printf(" stroke listcerts|listcainfos|listcrls|listall\n");
|
||||
printf(" Show list of supported algorithms:\n");
|
||||
printf(" stroke listalgs\n");
|
||||
printf(" Reload authority and attribute certificates:\n");
|
||||
@@ -447,6 +458,8 @@ static void exit_usage(char *error)
|
||||
printf(" where: NAME is a connection name added with \"stroke add\"\n");
|
||||
printf(" USERNAME is the username\n");
|
||||
printf(" PASSWORD is the optional password, you'll be asked to enter it if not given\n");
|
||||
printf(" Show IKE counters:\n");
|
||||
printf(" stroke listcounters [connection-name]\n");
|
||||
exit_error(error);
|
||||
}
|
||||
|
||||
@@ -555,7 +568,6 @@ 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;
|
||||
@@ -596,6 +608,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
res = user_credentials(argv[2], argv[3], argc > 4 ? argv[4] : NULL);
|
||||
break;
|
||||
case STROKE_COUNTERS:
|
||||
case STROKE_COUNTERS_RESET:
|
||||
res = counters(token->kw == STROKE_COUNTERS_RESET,
|
||||
argc > 2 ? argv[2] : NULL);
|
||||
break;
|
||||
default:
|
||||
exit_usage(NULL);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ typedef enum {
|
||||
STROKE_LIST_OCSP,
|
||||
STROKE_LIST_ALGS,
|
||||
STROKE_LIST_PLUGINS,
|
||||
STROKE_LIST_COUNTERS,
|
||||
STROKE_LIST_ALL,
|
||||
STROKE_REREAD_SECRETS,
|
||||
STROKE_REREAD_CACERTS,
|
||||
@@ -59,6 +58,8 @@ typedef enum {
|
||||
STROKE_LEASES,
|
||||
STROKE_MEMUSAGE,
|
||||
STROKE_USER_CREDS,
|
||||
STROKE_COUNTERS,
|
||||
STROKE_COUNTERS_RESET,
|
||||
} stroke_keyword_t;
|
||||
|
||||
#define STROKE_LIST_FIRST STROKE_LIST_PUBKEYS
|
||||
@@ -71,4 +72,3 @@ typedef struct stroke_token stroke_token_t;
|
||||
extern const stroke_token_t* in_word_set(register const char *str, register unsigned int len);
|
||||
|
||||
#endif /* _STROKE_KEYWORDS_H_ */
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ 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
|
||||
@@ -66,3 +65,5 @@ exportx509, STROKE_EXPORT_X509
|
||||
leases, STROKE_LEASES
|
||||
memusage, STROKE_MEMUSAGE
|
||||
user-creds, STROKE_USER_CREDS
|
||||
listcounters, STROKE_COUNTERS
|
||||
resetcounters, STROKE_COUNTERS_RESET
|
||||
|
||||
+10
-3
@@ -67,10 +67,8 @@ enum list_flag_t {
|
||||
LIST_ALGS = 0x0400,
|
||||
/** list plugin information */
|
||||
LIST_PLUGINS = 0x0800,
|
||||
/** list IKE counters */
|
||||
LIST_COUNTERS = 0x1000,
|
||||
/** all list options */
|
||||
LIST_ALL = 0x1FFF,
|
||||
LIST_ALL = 0x0FFF,
|
||||
};
|
||||
|
||||
typedef enum reread_flag_t reread_flag_t;
|
||||
@@ -226,6 +224,8 @@ struct stroke_msg_t {
|
||||
STR_MEMUSAGE,
|
||||
/* set username and password for a connection */
|
||||
STR_USER_CREDS,
|
||||
/* print/reset counters */
|
||||
STR_COUNTERS,
|
||||
/* more to come */
|
||||
} type;
|
||||
|
||||
@@ -356,6 +356,13 @@ struct stroke_msg_t {
|
||||
char *username;
|
||||
char *password;
|
||||
} user_creds;
|
||||
|
||||
/* data for STR_COUNTERS */
|
||||
struct {
|
||||
/* reset or print counters? */
|
||||
int reset;
|
||||
char *name;
|
||||
} counters;
|
||||
};
|
||||
char buffer[STROKE_BUF_LEN];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user