aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-10-24 08:44:47 +0000
committerMartin Willi <martin@strongswan.org>2006-10-24 08:44:47 +0000
commit5c4cc9a4e328d86867959dec0e082f7e4f098a6e (patch)
tree7cdd2ae9d2c608867189699154e4507313a2a56b
parent22d0ab1343f721a07e66f1c033f59d5fa66a5d9b (diff)
downloadstrongswan-5c4cc9a4e328d86867959dec0e082f7e4f098a6e.tar.bz2
strongswan-5c4cc9a4e328d86867959dec0e082f7e4f098a6e.tar.xz
added verbosity level to stroke
-rwxr-xr-xsrc/charon/threads/stroke_interface.c31
-rw-r--r--src/starter/starterstroke.c3
-rw-r--r--src/stroke/stroke.c2
-rw-r--r--src/stroke/stroke.h3
4 files changed, 31 insertions, 8 deletions
diff --git a/src/charon/threads/stroke_interface.c b/src/charon/threads/stroke_interface.c
index 988390ef5..111ef8472 100755
--- a/src/charon/threads/stroke_interface.c
+++ b/src/charon/threads/stroke_interface.c
@@ -496,7 +496,10 @@ static void stroke_initiate(private_stroke_t *this, stroke_msg_t *msg)
msg->initiate.name);
if (connection == NULL)
{
- fprintf(this->out, "no connection named '%s'\n", msg->initiate.name);
+ if (msg->output_verbosity >= 0)
+ {
+ fprintf(this->out, "no connection named '%s'\n", msg->initiate.name);
+ }
return;
}
if (!connection->is_ikev2(connection))
@@ -509,11 +512,17 @@ static void stroke_initiate(private_stroke_t *this, stroke_msg_t *msg)
msg->initiate.name);
if (policy == NULL)
{
- fprintf(this->out, "no policy named '%s'\n", msg->initiate.name);
+ if (msg->output_verbosity >= 0)
+ {
+ fprintf(this->out, "no policy named '%s'\n", msg->initiate.name);
+ }
connection->destroy(connection);
return;
}
- fprintf(this->out, "initiating connection '%s'\n", msg->initiate.name);
+ if (msg->output_verbosity >= 0)
+ {
+ fprintf(this->out, "initiating connection '%s'\n", msg->initiate.name);
+ }
job = initiate_job_create(connection, policy);
@@ -529,7 +538,8 @@ static void stroke_initiate(private_stroke_t *this, stroke_msg_t *msg)
signal = charon->bus->listen(charon->bus, &level, &thread, &ike_sa, &format, &args);
- if (ike_sa == init_ike_sa && level <= LEVEL_CTRL)
+ if ((init_ike_sa == NULL || ike_sa == init_ike_sa) &&
+ level <= msg->output_verbosity)
{
if (vfprintf(this->out, format, args) < 0 ||
fprintf(this->out, "\n") < 0 ||
@@ -544,15 +554,20 @@ static void stroke_initiate(private_stroke_t *this, stroke_msg_t *msg)
{
case SIG_IKE_UP:
case SIG_IKE_FAILED:
- case SIG_IKE_DOWN:
+ case SIG_CHILD_UP:
+ case SIG_CHILD_FAILED:
if (ike_sa == init_ike_sa)
{
charon->bus->set_listen_state(charon->bus, FALSE);
+ return;
}
- return;
+ continue;
case SIG_INITIATE:
- init_ike_sa = ike_sa;
- /* fall through */
+ if (init_ike_sa == NULL)
+ {
+ init_ike_sa = ike_sa;
+ }
+ continue;
default:
continue;
}
diff --git a/src/starter/starterstroke.c b/src/starter/starterstroke.c
index 752ebc13f..aae8d5b59 100644
--- a/src/starter/starterstroke.c
+++ b/src/starter/starterstroke.c
@@ -83,6 +83,9 @@ static int send_stroke_msg (stroke_msg_t *msg)
struct sockaddr_un ctl_addr = { AF_UNIX, CHARON_CTL_FILE };
int byte_count;
char buffer[64];
+
+ /* starter is not called from commandline, and therefore absolutely silent */
+ msg->output_verbosity = -1;
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
diff --git a/src/stroke/stroke.c b/src/stroke/stroke.c
index 1d4d11894..3cc297afb 100644
--- a/src/stroke/stroke.c
+++ b/src/stroke/stroke.c
@@ -57,6 +57,8 @@ static int send_stroke_msg (stroke_msg_t *msg)
char buffer[64];
int byte_count;
+ msg->output_verbosity = 1; /* CONTROL */
+
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
{
diff --git a/src/stroke/stroke.h b/src/stroke/stroke.h
index 048ee0813..42a8a9616 100644
--- a/src/stroke/stroke.h
+++ b/src/stroke/stroke.h
@@ -122,6 +122,9 @@ struct stroke_msg_t {
STR_REREAD
/* more to come */
} type;
+
+ /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
+ int output_verbosity;
union {
/* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */