Add connection name specific stroke counters

This commit is contained in:
Martin Willi
2013-03-15 10:41:04 +01:00
parent a34ffd1c05
commit d022322bed
7 changed files with 181 additions and 20 deletions
+23 -3
View File
@@ -266,7 +266,6 @@ static int list_flags[] = {
LIST_OCSP,
LIST_ALGS,
LIST_PLUGINS,
LIST_COUNTERS,
LIST_ALL
};
@@ -365,6 +364,16 @@ static int user_credentials(char *name, char *user, char *pass)
return send_stroke_msg(&msg);
}
static int counters(char *name)
{
stroke_msg_t msg;
msg.type = STR_COUNTERS;
msg.length = offsetof(stroke_msg_t, buffer);
msg.counters.name = push_string(&msg, name);
return send_stroke_msg(&msg);
}
static int set_loglevel(char *type, u_int level)
{
stroke_msg_t msg;
@@ -419,7 +428,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");
@@ -445,6 +454,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);
}
@@ -553,7 +564,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;
@@ -594,6 +604,16 @@ 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);
}
break;
default:
exit_usage(NULL);
}
+1 -2
View File
@@ -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,7 @@ typedef enum {
STROKE_LEASES,
STROKE_MEMUSAGE,
STROKE_USER_CREDS,
STROKE_COUNTERS,
} stroke_keyword_t;
#define STROKE_LIST_FIRST STROKE_LIST_PUBKEYS
@@ -71,4 +71,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_ */
+1 -1
View File
@@ -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,4 @@ exportx509, STROKE_EXPORT_X509
leases, STROKE_LEASES
memusage, STROKE_MEMUSAGE
user-creds, STROKE_USER_CREDS
listcounters, STROKE_COUNTERS
+8 -3
View File
@@ -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;
@@ -225,6 +223,8 @@ struct stroke_msg_t {
STR_MEMUSAGE,
/* set username and password for a connection */
STR_USER_CREDS,
/* print counters */
STR_COUNTERS,
/* more to come */
} type;
@@ -354,6 +354,11 @@ struct stroke_msg_t {
char *username;
char *password;
} user_creds;
/* data for STR_COUNTERS */
struct {
char *name;
} counters;
};
char buffer[STROKE_BUF_LEN];
};