aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2011-05-04 11:21:33 +0200
committerMartin Willi <martin@revosec.ch>2011-05-16 15:24:14 +0200
commita694b481eed8ffbbbfde899dfdee54a394ec49d8 (patch)
tree16ffc1fcc9714e56a7e6adb1682d149845f27495 /src
parenta2302d2322bea1e65079abede55e590035212d03 (diff)
downloadstrongswan-a694b481eed8ffbbbfde899dfdee54a394ec49d8.tar.bz2
strongswan-a694b481eed8ffbbbfde899dfdee54a394ec49d8.tar.xz
Added a statusallnb stroke command to show status non-blocking
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/plugins/stroke/stroke_list.c5
-rw-r--r--src/libcharon/plugins/stroke/stroke_list.h4
-rw-r--r--src/libcharon/plugins/stroke/stroke_socket.c11
-rw-r--r--src/stroke/stroke.c14
-rw-r--r--src/stroke/stroke_keywords.h1
-rw-r--r--src/stroke/stroke_keywords.txt1
-rw-r--r--src/stroke/stroke_msg.h2
7 files changed, 30 insertions, 8 deletions
diff --git a/src/libcharon/plugins/stroke/stroke_list.c b/src/libcharon/plugins/stroke/stroke_list.c
index 9dd1ca424..35571a0f2 100644
--- a/src/libcharon/plugins/stroke/stroke_list.c
+++ b/src/libcharon/plugins/stroke/stroke_list.c
@@ -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;
diff --git a/src/libcharon/plugins/stroke/stroke_list.h b/src/libcharon/plugins/stroke/stroke_list.h
index b5bedc6c2..a0d2d18cc 100644
--- a/src/libcharon/plugins/stroke/stroke_list.h
+++ b/src/libcharon/plugins/stroke/stroke_list.h
@@ -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.
diff --git a/src/libcharon/plugins/stroke/stroke_socket.c b/src/libcharon/plugins/stroke/stroke_socket.c
index 592c77623..d6846807b 100644
--- a/src/libcharon/plugins/stroke/stroke_socket.c
+++ b/src/libcharon/plugins/stroke/stroke_socket.c
@@ -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);
diff --git a/src/stroke/stroke.c b/src/stroke/stroke.c
index 6dbaf6464..7410f5cab 100644
--- a/src/stroke/stroke.c
+++ b/src/stroke/stroke.c
@@ -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:
diff --git a/src/stroke/stroke_keywords.h b/src/stroke/stroke_keywords.h
index dd00dc24c..3e55ef8f2 100644
--- a/src/stroke/stroke_keywords.h
+++ b/src/stroke/stroke_keywords.h
@@ -29,6 +29,7 @@ typedef enum {
STROKE_LOGLEVEL,
STROKE_STATUS,
STROKE_STATUSALL,
+ STROKE_STATUSALL_NOBLK,
STROKE_LIST_PUBKEYS,
STROKE_LIST_CERTS,
STROKE_LIST_CACERTS,
diff --git a/src/stroke/stroke_keywords.txt b/src/stroke/stroke_keywords.txt
index f87b15769..78212c2b8 100644
--- a/src/stroke/stroke_keywords.txt
+++ b/src/stroke/stroke_keywords.txt
@@ -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
diff --git a/src/stroke/stroke_msg.h b/src/stroke/stroke_msg.h
index 2fbacecf7..3c1221aee 100644
--- a/src/stroke/stroke_msg.h
+++ b/src/stroke/stroke_msg.h
@@ -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 */