Added a statusallnb stroke command to show status non-blocking
This commit is contained in:
@@ -389,7 +389,8 @@ static void log_auth_cfgs(FILE *out, peer_cfg_t *peer_cfg, bool local)
|
||||
}
|
||||
|
||||
METHOD(stroke_list_t, status, void,
|
||||
private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bool all)
|
||||
private_stroke_list_t *this, stroke_msg_t *msg, FILE *out,
|
||||
bool all, bool wait)
|
||||
{
|
||||
enumerator_t *enumerator, *children;
|
||||
ike_cfg_t *ike_cfg;
|
||||
@@ -531,7 +532,7 @@ METHOD(stroke_list_t, status, void,
|
||||
|
||||
fprintf(out, "Security Associations:\n");
|
||||
enumerator = charon->controller->create_ike_sa_enumerator(
|
||||
charon->controller, TRUE);
|
||||
charon->controller, wait);
|
||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||
{
|
||||
bool ike_printed = FALSE;
|
||||
|
||||
@@ -47,8 +47,10 @@ struct stroke_list_t {
|
||||
* @param msg stroke message
|
||||
* @param out stroke console stream
|
||||
* @param all TRUE for "statusall"
|
||||
* @param wait TRUE to wait for IKE_SA entries, FALSE to skip if locked
|
||||
*/
|
||||
void (*status)(stroke_list_t *this, stroke_msg_t *msg, FILE *out, bool all);
|
||||
void (*status)(stroke_list_t *this, stroke_msg_t *msg, FILE *out,
|
||||
bool all, bool wait);
|
||||
|
||||
/**
|
||||
* Log pool leases to stroke console.
|
||||
|
||||
@@ -322,11 +322,11 @@ static void stroke_del_ca(private_stroke_socket_t *this,
|
||||
* show status of daemon
|
||||
*/
|
||||
static void stroke_status(private_stroke_socket_t *this,
|
||||
stroke_msg_t *msg, FILE *out, bool all)
|
||||
stroke_msg_t *msg, FILE *out, bool all, bool wait)
|
||||
{
|
||||
pop_string(msg, &(msg->status.name));
|
||||
|
||||
this->list->status(this->list, msg, out, all);
|
||||
this->list->status(this->list, msg, out, all, wait);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,10 +546,13 @@ static job_requeue_t process(stroke_job_context_t *ctx)
|
||||
stroke_rekey(this, msg, out);
|
||||
break;
|
||||
case STR_STATUS:
|
||||
stroke_status(this, msg, out, FALSE);
|
||||
stroke_status(this, msg, out, FALSE, TRUE);
|
||||
break;
|
||||
case STR_STATUS_ALL:
|
||||
stroke_status(this, msg, out, TRUE);
|
||||
stroke_status(this, msg, out, TRUE, TRUE);
|
||||
break;
|
||||
case STR_STATUS_ALL_NOBLK:
|
||||
stroke_status(this, msg, out, TRUE, FALSE);
|
||||
break;
|
||||
case STR_ADD_CONN:
|
||||
stroke_add_conn(this, msg);
|
||||
|
||||
+13
-1
@@ -231,7 +231,18 @@ static int show_status(stroke_keyword_t kw, char *connection)
|
||||
{
|
||||
stroke_msg_t msg;
|
||||
|
||||
msg.type = (kw == STROKE_STATUS)? STR_STATUS:STR_STATUS_ALL;
|
||||
switch (kw)
|
||||
{
|
||||
case STROKE_STATUSALL:
|
||||
msg.type = STR_STATUS_ALL;
|
||||
break;
|
||||
case STROKE_STATUSALL_NOBLK:
|
||||
msg.type = STR_STATUS_ALL_NOBLK;
|
||||
break;
|
||||
default:
|
||||
msg.type = STR_STATUS;
|
||||
break;
|
||||
}
|
||||
msg.length = offsetof(stroke_msg_t, buffer);
|
||||
msg.status.name = push_string(&msg, connection);
|
||||
return send_stroke_msg(&msg);
|
||||
@@ -498,6 +509,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case STROKE_STATUS:
|
||||
case STROKE_STATUSALL:
|
||||
case STROKE_STATUSALL_NOBLK:
|
||||
res = show_status(token->kw, argc > 2 ? argv[2] : NULL);
|
||||
break;
|
||||
case STROKE_LIST_PUBKEYS:
|
||||
|
||||
@@ -29,6 +29,7 @@ typedef enum {
|
||||
STROKE_LOGLEVEL,
|
||||
STROKE_STATUS,
|
||||
STROKE_STATUSALL,
|
||||
STROKE_STATUSALL_NOBLK,
|
||||
STROKE_LIST_PUBKEYS,
|
||||
STROKE_LIST_CERTS,
|
||||
STROKE_LIST_CACERTS,
|
||||
|
||||
@@ -36,6 +36,7 @@ rekey, STROKE_REKEY
|
||||
loglevel, STROKE_LOGLEVEL
|
||||
status, STROKE_STATUS
|
||||
statusall, STROKE_STATUSALL
|
||||
statusallnb, STROKE_STATUSALL_NOBLK
|
||||
listpubkeys, STROKE_LIST_PUBKEYS
|
||||
listcerts, STROKE_LIST_CERTS
|
||||
listcacerts, STROKE_LIST_CACERTS
|
||||
|
||||
@@ -194,6 +194,8 @@ struct stroke_msg_t {
|
||||
STR_STATUS,
|
||||
/* show verbose connection status */
|
||||
STR_STATUS_ALL,
|
||||
/* show verbose connection status, non-blocking variant */
|
||||
STR_STATUS_ALL_NOBLK,
|
||||
/* add a ca information record */
|
||||
STR_ADD_CA,
|
||||
/* delete ca information record */
|
||||
|
||||
Reference in New Issue
Block a user