stroke: Don't log unspecified options of conn and ca sections

This commit is contained in:
Tobias Brunner 2014-06-25 17:53:10 +02:00
parent e79dbda390
commit 28a79e4e0c
1 changed files with 50 additions and 37 deletions

View File

@ -106,6 +106,19 @@ struct private_stroke_socket_t {
bool prevent_loglevel_changes;
};
/**
* Helper macro to log configuration options, but only if they are defined.
*/
#define DBG_OPT(...) VA_ARGS_DISPATCH(DBG_OPT, __VA_ARGS__)(__VA_ARGS__)
#define DBG_OPT2(fmt, val) ({ \
typeof(val) _val = val; \
if (_val) { DBG2(DBG_CFG, fmt, _val); } \
})
#define DBG_OPT3(fmt, label, val) ({ \
typeof(val) _val = val; \
if (_val) { DBG2(DBG_CFG, fmt, label, _val); } \
})
/**
* Helper function which corrects the string pointers
* in a stroke_msg_t. Strings in a stroke_msg sent over "wire"
@ -157,22 +170,22 @@ static void pop_end(stroke_msg_t *msg, const char* label, stroke_end_t *end)
pop_string(msg, &end->cert_policy);
pop_string(msg, &end->updown);
DBG2(DBG_CFG, " %s=%s", label, end->address);
DBG2(DBG_CFG, " %ssubnet=%s", label, end->subnets);
DBG2(DBG_CFG, " %ssourceip=%s", label, end->sourceip);
DBG2(DBG_CFG, " %sdns=%s", label, end->dns);
DBG2(DBG_CFG, " %sauth=%s", label, end->auth);
DBG2(DBG_CFG, " %sauth2=%s", label, end->auth2);
DBG2(DBG_CFG, " %sid=%s", label, end->id);
DBG2(DBG_CFG, " %sid2=%s", label, end->id2);
DBG2(DBG_CFG, " %srsakey=%s", label, end->rsakey);
DBG2(DBG_CFG, " %scert=%s", label, end->cert);
DBG2(DBG_CFG, " %scert2=%s", label, end->cert2);
DBG2(DBG_CFG, " %sca=%s", label, end->ca);
DBG2(DBG_CFG, " %sca2=%s", label, end->ca2);
DBG2(DBG_CFG, " %sgroups=%s", label, end->groups);
DBG2(DBG_CFG, " %sgroups2=%s", label, end->groups2);
DBG2(DBG_CFG, " %supdown=%s", label, end->updown);
DBG_OPT(" %s=%s", label, end->address);
DBG_OPT(" %ssubnet=%s", label, end->subnets);
DBG_OPT(" %ssourceip=%s", label, end->sourceip);
DBG_OPT(" %sdns=%s", label, end->dns);
DBG_OPT(" %sauth=%s", label, end->auth);
DBG_OPT(" %sauth2=%s", label, end->auth2);
DBG_OPT(" %sid=%s", label, end->id);
DBG_OPT(" %sid2=%s", label, end->id2);
DBG_OPT(" %srsakey=%s", label, end->rsakey);
DBG_OPT(" %scert=%s", label, end->cert);
DBG_OPT(" %scert2=%s", label, end->cert2);
DBG_OPT(" %sca=%s", label, end->ca);
DBG_OPT(" %sca2=%s", label, end->ca2);
DBG_OPT(" %sgroups=%s", label, end->groups);
DBG_OPT(" %sgroups2=%s", label, end->groups2);
DBG_OPT(" %supdown=%s", label, end->updown);
}
/**
@ -194,20 +207,20 @@ static void stroke_add_conn(private_stroke_socket_t *this, stroke_msg_t *msg)
pop_string(msg, &msg->add_conn.algorithms.ah);
pop_string(msg, &msg->add_conn.ikeme.mediated_by);
pop_string(msg, &msg->add_conn.ikeme.peerid);
DBG2(DBG_CFG, " eap_identity=%s", msg->add_conn.eap_identity);
DBG2(DBG_CFG, " aaa_identity=%s", msg->add_conn.aaa_identity);
DBG2(DBG_CFG, " xauth_identity=%s", msg->add_conn.xauth_identity);
DBG2(DBG_CFG, " ike=%s", msg->add_conn.algorithms.ike);
DBG2(DBG_CFG, " esp=%s", msg->add_conn.algorithms.esp);
DBG2(DBG_CFG, " ah=%s", msg->add_conn.algorithms.ah);
DBG2(DBG_CFG, " dpddelay=%d", msg->add_conn.dpd.delay);
DBG2(DBG_CFG, " dpdtimeout=%d", msg->add_conn.dpd.timeout);
DBG2(DBG_CFG, " dpdaction=%d", msg->add_conn.dpd.action);
DBG2(DBG_CFG, " closeaction=%d", msg->add_conn.close_action);
DBG2(DBG_CFG, " mediation=%s", msg->add_conn.ikeme.mediation ? "yes" : "no");
DBG2(DBG_CFG, " mediated_by=%s", msg->add_conn.ikeme.mediated_by);
DBG2(DBG_CFG, " me_peerid=%s", msg->add_conn.ikeme.peerid);
DBG2(DBG_CFG, " keyexchange=ikev%u", msg->add_conn.version);
DBG_OPT(" eap_identity=%s", msg->add_conn.eap_identity);
DBG_OPT(" aaa_identity=%s", msg->add_conn.aaa_identity);
DBG_OPT(" xauth_identity=%s", msg->add_conn.xauth_identity);
DBG_OPT(" ike=%s", msg->add_conn.algorithms.ike);
DBG_OPT(" esp=%s", msg->add_conn.algorithms.esp);
DBG_OPT(" ah=%s", msg->add_conn.algorithms.ah);
DBG_OPT(" dpddelay=%d", msg->add_conn.dpd.delay);
DBG_OPT(" dpdtimeout=%d", msg->add_conn.dpd.timeout);
DBG_OPT(" dpdaction=%d", msg->add_conn.dpd.action);
DBG_OPT(" closeaction=%d", msg->add_conn.close_action);
DBG_OPT(" mediation=%s", msg->add_conn.ikeme.mediation ? "yes" : "no");
DBG_OPT(" mediated_by=%s", msg->add_conn.ikeme.mediated_by);
DBG_OPT(" me_peerid=%s", msg->add_conn.ikeme.peerid);
DBG_OPT(" keyexchange=ikev%u", msg->add_conn.version);
this->config->add(this->config, msg);
this->attribute->add_dns(this->attribute, msg);
@ -311,13 +324,13 @@ static void stroke_add_ca(private_stroke_socket_t *this,
pop_string(msg, &msg->add_ca.ocspuri);
pop_string(msg, &msg->add_ca.ocspuri2);
pop_string(msg, &msg->add_ca.certuribase);
DBG2(DBG_CFG, "ca %s", msg->add_ca.name);
DBG2(DBG_CFG, " cacert=%s", msg->add_ca.cacert);
DBG2(DBG_CFG, " crluri=%s", msg->add_ca.crluri);
DBG2(DBG_CFG, " crluri2=%s", msg->add_ca.crluri2);
DBG2(DBG_CFG, " ocspuri=%s", msg->add_ca.ocspuri);
DBG2(DBG_CFG, " ocspuri2=%s", msg->add_ca.ocspuri2);
DBG2(DBG_CFG, " certuribase=%s", msg->add_ca.certuribase);
DBG2(DBG_CFG, "ca %s", msg->add_ca.name);
DBG_OPT(" cacert=%s", msg->add_ca.cacert);
DBG_OPT(" crluri=%s", msg->add_ca.crluri);
DBG_OPT(" crluri2=%s", msg->add_ca.crluri2);
DBG_OPT(" ocspuri=%s", msg->add_ca.ocspuri);
DBG_OPT(" ocspuri2=%s", msg->add_ca.ocspuri2);
DBG_OPT(" certuribase=%s", msg->add_ca.certuribase);
this->ca->add(this->ca, msg);
}