added verbosity level to stroke

This commit is contained in:
Martin Willi
2006-10-24 08:44:47 +00:00
parent 22d0ab1343
commit 5c4cc9a4e3
4 changed files with 31 additions and 8 deletions
+19 -4
View File
@@ -495,8 +495,11 @@ static void stroke_initiate(private_stroke_t *this, stroke_msg_t *msg)
connection = charon->connections->get_connection_by_name(charon->connections, connection = charon->connections->get_connection_by_name(charon->connections,
msg->initiate.name); msg->initiate.name);
if (connection == NULL) if (connection == NULL)
{
if (msg->output_verbosity >= 0)
{ {
fprintf(this->out, "no connection named '%s'\n", msg->initiate.name); fprintf(this->out, "no connection named '%s'\n", msg->initiate.name);
}
return; return;
} }
if (!connection->is_ikev2(connection)) if (!connection->is_ikev2(connection))
@@ -508,12 +511,18 @@ static void stroke_initiate(private_stroke_t *this, stroke_msg_t *msg)
policy = charon->policies->get_policy_by_name(charon->policies, policy = charon->policies->get_policy_by_name(charon->policies,
msg->initiate.name); msg->initiate.name);
if (policy == NULL) if (policy == NULL)
{
if (msg->output_verbosity >= 0)
{ {
fprintf(this->out, "no policy named '%s'\n", msg->initiate.name); fprintf(this->out, "no policy named '%s'\n", msg->initiate.name);
}
connection->destroy(connection); connection->destroy(connection);
return; return;
} }
if (msg->output_verbosity >= 0)
{
fprintf(this->out, "initiating connection '%s'\n", msg->initiate.name); fprintf(this->out, "initiating connection '%s'\n", msg->initiate.name);
}
job = initiate_job_create(connection, policy); 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); 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 || if (vfprintf(this->out, format, args) < 0 ||
fprintf(this->out, "\n") < 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_UP:
case SIG_IKE_FAILED: case SIG_IKE_FAILED:
case SIG_IKE_DOWN: case SIG_CHILD_UP:
case SIG_CHILD_FAILED:
if (ike_sa == init_ike_sa) if (ike_sa == init_ike_sa)
{ {
charon->bus->set_listen_state(charon->bus, FALSE); charon->bus->set_listen_state(charon->bus, FALSE);
}
return; return;
}
continue;
case SIG_INITIATE: case SIG_INITIATE:
if (init_ike_sa == NULL)
{
init_ike_sa = ike_sa; init_ike_sa = ike_sa;
/* fall through */ }
continue;
default: default:
continue; continue;
} }
+3
View File
@@ -84,6 +84,9 @@ static int send_stroke_msg (stroke_msg_t *msg)
int byte_count; int byte_count;
char buffer[64]; 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); int sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) if (sock < 0)
+2
View File
@@ -57,6 +57,8 @@ static int send_stroke_msg (stroke_msg_t *msg)
char buffer[64]; char buffer[64];
int byte_count; int byte_count;
msg->output_verbosity = 1; /* CONTROL */
sock = socket(AF_UNIX, SOCK_STREAM, 0); sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) if (sock < 0)
{ {
+3
View File
@@ -123,6 +123,9 @@ struct stroke_msg_t {
/* more to come */ /* more to come */
} type; } type;
/* verbosity of output returned from charon (-from -1=silent to 4=private)*/
int output_verbosity;
union { union {
/* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */ /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
struct { struct {