introduced printf() specifiers for:
host_t (%H) identification_t (%D) chunk pointers (%B) memory pointer/length (%b) added a signaling bus: receives event and debug messages, sends them to its listeners stream_logger, sys_logger, file_logger added, listen to bus some other tweaks here and there
This commit is contained in:
@@ -220,8 +220,9 @@ static status_t verify_auth_data (private_authenticator_t *this,
|
||||
&shared_key);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "no shared key found for '%s' and '%s'",
|
||||
my_id->get_string(my_id), other_id->get_string(other_id));
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"no shared key found for '%D' - '%D'",
|
||||
my_id, other_id);
|
||||
chunk_free(&shared_key);
|
||||
break;
|
||||
}
|
||||
@@ -234,7 +235,9 @@ static status_t verify_auth_data (private_authenticator_t *this,
|
||||
shared_key);
|
||||
chunk_free(&shared_key);
|
||||
|
||||
status = (auth_data.len == my_auth_data.len && memeq(auth_data.ptr, my_auth_data.ptr, my_auth_data.len))
|
||||
|
||||
status = (auth_data.len == my_auth_data.len &&
|
||||
memeq(auth_data.ptr, my_auth_data.ptr, my_auth_data.len))
|
||||
? SUCCESS : FAILED;
|
||||
chunk_free(&my_auth_data);
|
||||
break;
|
||||
@@ -248,8 +251,8 @@ static status_t verify_auth_data (private_authenticator_t *this,
|
||||
|
||||
if (public_key == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "no RSA public key found for '%s'",
|
||||
other_id->get_string(other_id));
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"no RSA public key found for '%D'", other_id);
|
||||
status = NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
@@ -266,9 +269,8 @@ static status_t verify_auth_data (private_authenticator_t *this,
|
||||
}
|
||||
}
|
||||
|
||||
this->logger->log(this->logger, CONTROL, "authentication of '%s' with %s %s",
|
||||
other_id->get_string(other_id),
|
||||
enum_name(&auth_method_names, auth_method),
|
||||
this->logger->log(this->logger, CONTROL, "authentication of '%D' with %s %s",
|
||||
other_id, enum_name(&auth_method_names, auth_method),
|
||||
(status == SUCCESS)? "successful":"failed");
|
||||
return status;
|
||||
}
|
||||
@@ -284,9 +286,9 @@ static status_t compute_auth_data (private_authenticator_t *this,
|
||||
identification_t *other_id,
|
||||
bool initiator)
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL, "authentication of '%s' with %s (myself)",
|
||||
my_id->get_string(my_id),
|
||||
enum_name(&auth_method_names, this->auth_method));
|
||||
this->logger->log(this->logger, CONTROL,
|
||||
"authentication of '%D' with %s (myself)",
|
||||
my_id, enum_name(&auth_method_names, this->auth_method));
|
||||
|
||||
switch (this->auth_method)
|
||||
{
|
||||
@@ -302,8 +304,9 @@ static status_t compute_auth_data (private_authenticator_t *this,
|
||||
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "no shared key found for '%s' and '%s'",
|
||||
my_id->get_string(my_id), other_id->get_string(other_id));
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"no shared key found for '%D' - '%D'",
|
||||
my_id, other_id);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -330,14 +333,15 @@ static status_t compute_auth_data (private_authenticator_t *this,
|
||||
rsa_public_key_t *my_pubkey;
|
||||
rsa_private_key_t *my_key;
|
||||
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "looking for RSA public key belonging to '%s'",
|
||||
my_id->get_string(my_id));
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1,
|
||||
"looking for RSA public key belonging to '%D'",
|
||||
my_id);
|
||||
|
||||
my_pubkey = charon->credentials->get_rsa_public_key(charon->credentials, my_id);
|
||||
if (my_pubkey == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "no RSA public key found for '%s'",
|
||||
my_id->get_string(my_id));
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"no RSA public key found for '%D'", my_id);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL2, "matching RSA public key found");
|
||||
@@ -351,8 +355,9 @@ static status_t compute_auth_data (private_authenticator_t *this,
|
||||
char buf[BUF_LEN];
|
||||
|
||||
chunk_to_hex(buf, BUF_LEN, my_pubkey->get_keyid(my_pubkey));
|
||||
this->logger->log(this->logger, ERROR, "no RSA private key found with for %s with keyid %s",
|
||||
my_id->get_string(my_id), buf);
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"no RSA private key found with for %D with keyid %s",
|
||||
my_id, buf);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL2, "matching RSA private key found");
|
||||
|
||||
+14
-17
@@ -296,15 +296,15 @@ static void updown(private_child_sa_t *this, bool up)
|
||||
"PLUTO_CONNECTION='%s' "
|
||||
"PLUTO_INTERFACE='%s' "
|
||||
"PLUTO_REQID='%u' "
|
||||
"PLUTO_ME='%s' "
|
||||
"PLUTO_MY_ID='%s' "
|
||||
"PLUTO_ME='%H' "
|
||||
"PLUTO_MY_ID='%D' "
|
||||
"PLUTO_MY_CLIENT='%s/%s' "
|
||||
"PLUTO_MY_CLIENT_NET='%s' "
|
||||
"PLUTO_MY_CLIENT_MASK='%s' "
|
||||
"PLUTO_MY_PORT='%u' "
|
||||
"PLUTO_MY_PROTOCOL='%u' "
|
||||
"PLUTO_PEER='%s' "
|
||||
"PLUTO_PEER_ID='%s' "
|
||||
"PLUTO_PEER='%H' "
|
||||
"PLUTO_PEER_ID='%D' "
|
||||
"PLUTO_PEER_CLIENT='%s/%s' "
|
||||
"PLUTO_PEER_CLIENT_NET='%s' "
|
||||
"PLUTO_PEER_CLIENT_MASK='%s' "
|
||||
@@ -313,20 +313,20 @@ static void updown(private_child_sa_t *this, bool up)
|
||||
"%s"
|
||||
"%s",
|
||||
up ? "up" : "down",
|
||||
streq(this->me.addr->get_string(this->me.addr),
|
||||
my_client) ? "-host" : "-client",
|
||||
/* TODO: fix it: streq(this->me.addr->get_string(this->me.addr),
|
||||
my_client) ? "-host" :*/ "-client",
|
||||
this->me.addr->get_family(this->me.addr) == AF_INET ? "" : "-ipv6",
|
||||
this->name,
|
||||
ifname,
|
||||
this->reqid,
|
||||
this->me.addr->get_string(this->me.addr),
|
||||
this->me.id->get_string(this->me.id),
|
||||
this->me.addr,
|
||||
this->me.id,
|
||||
my_client, my_client_mask,
|
||||
my_client, my_client_mask,
|
||||
policy->my_ts->get_from_port(policy->my_ts),
|
||||
policy->my_ts->get_protocol(policy->my_ts),
|
||||
this->other.addr->get_string(this->other.addr),
|
||||
this->other.id->get_string(this->other.id),
|
||||
this->other.addr,
|
||||
this->other.id,
|
||||
other_client, other_client_mask,
|
||||
other_client, other_client_mask,
|
||||
policy->other_ts->get_from_port(policy->other_ts),
|
||||
@@ -548,8 +548,8 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal, prf_plus
|
||||
|
||||
/* send SA down to the kernel */
|
||||
this->logger->log(this->logger, CONTROL|LEVEL2,
|
||||
" SPI 0x%.8x, src %s dst %s",
|
||||
ntohl(spi), src->get_string(src), dst->get_string(dst));
|
||||
" SPI 0x%.8x, src %H dst %H",
|
||||
ntohl(spi), src, dst);
|
||||
status = charon->kernel_interface->add_sa(charon->kernel_interface,
|
||||
src, dst,
|
||||
spi, this->protocol,
|
||||
@@ -937,12 +937,9 @@ static status_t update_sa_hosts(private_child_sa_t *this, host_t *new_me, host_t
|
||||
}
|
||||
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1,
|
||||
"updating %s SA 0x%x, from %s:%d..%s:%d to %s:%d..%s:%d",
|
||||
"updating %s SA 0x%x, from %#H..#H to %#H..%#H",
|
||||
mapping_find(protocol_id_m, this->protocol), ntohl(spi),
|
||||
src->get_string(src), src->get_port(src),
|
||||
dst->get_string(dst), dst->get_port(dst),
|
||||
new_src->get_string(new_src), new_src->get_port(new_src),
|
||||
new_dst->get_string(new_dst), new_dst->get_port(new_dst));
|
||||
src, dst, new_src, new_dst);
|
||||
|
||||
status = charon->kernel_interface->update_sa(charon->kernel_interface,
|
||||
dst, spi, this->protocol,
|
||||
|
||||
+12
-21
@@ -1363,11 +1363,9 @@ static void set_state(private_ike_sa_t *this, ike_sa_state_t state)
|
||||
if (state == IKE_ESTABLISHED)
|
||||
{
|
||||
this->time.established = time(NULL);
|
||||
this->logger->log(this->logger, AUDIT, "IKE_SA established: %s[%s]...%s[%s]",
|
||||
this->my_host->get_string(this->my_host),
|
||||
this->my_id->get_string(this->my_id),
|
||||
this->other_host->get_string(this->other_host),
|
||||
this->other_id->get_string(this->other_id));
|
||||
this->logger->log(this->logger, AUDIT, "IKE_SA established: %H[%D]...%H[%D]",
|
||||
this->my_host, this->my_id,
|
||||
this->other_host, this->other_id);
|
||||
/* start DPD checks */
|
||||
send_dpd(this);
|
||||
}
|
||||
@@ -1784,11 +1782,9 @@ static status_t rekey(private_ike_sa_t *this)
|
||||
rekey_ike_sa_t *rekey_ike_sa;
|
||||
|
||||
this->logger->log(this->logger, CONTROL,
|
||||
"rekeying IKE_SA between %s[%s]..%s[%s]",
|
||||
this->my_host->get_string(this->my_host),
|
||||
this->my_id->get_string(this->my_id),
|
||||
this->other_host->get_string(this->other_host),
|
||||
this->other_id->get_string(this->other_id));
|
||||
"rekeying IKE_SA between: %H[%D]...%H[%D]",
|
||||
this->my_host, this->my_id,
|
||||
this->other_host, this->other_id);
|
||||
|
||||
if (this->state != IKE_ESTABLISHED)
|
||||
{
|
||||
@@ -1869,12 +1865,9 @@ static void log_status(private_ike_sa_t *this, logger_t *logger, char *name)
|
||||
mapping_find(ike_sa_state_m, this->state),
|
||||
this->ike_sa_id->get_initiator_spi(this->ike_sa_id),
|
||||
this->ike_sa_id->get_responder_spi(this->ike_sa_id));
|
||||
logger->log(logger, CONTROL, " \"%s\": %s[%s]...%s[%s]",
|
||||
this->name,
|
||||
this->my_host->get_string(this->my_host),
|
||||
this->my_id->get_string(this->my_id),
|
||||
this->other_host->get_string(this->other_host),
|
||||
this->other_id->get_string(this->other_id));
|
||||
logger->log(logger, CONTROL, " \"%s\": %H[%D]...%H[%D]",
|
||||
this->name, this->my_host, this->my_id,
|
||||
this->other_host, this->other_id);
|
||||
|
||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
||||
while (iterator->has_next(iterator))
|
||||
@@ -1995,11 +1988,9 @@ static void destroy(private_ike_sa_t *this)
|
||||
DESTROY_IF(this->prf_auth_r);
|
||||
|
||||
this->logger->log(this->logger, AUDIT,
|
||||
"IKE_SA deleted between %s[%s]...%s[%s]",
|
||||
this->my_host->get_string(this->my_host),
|
||||
this->my_id->get_string(this->my_id),
|
||||
this->other_host->get_string(this->other_host),
|
||||
this->other_id->get_string(this->other_id));
|
||||
"IKE_SA deleted between: %H[%D]...%H[%D]",
|
||||
this->my_host, this->my_id,
|
||||
this->other_host, this->other_id);
|
||||
|
||||
DESTROY_IF(this->my_host);
|
||||
DESTROY_IF(this->other_host);
|
||||
|
||||
@@ -385,9 +385,8 @@ static ike_sa_t* checkout_by_id(private_ike_sa_manager_t *this,
|
||||
{
|
||||
/* looks good, we take this one */
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1,
|
||||
"found an existing IKE_SA for %s[%s]...%s[%s]",
|
||||
my_host->get_string(my_host), other_host->get_string(other_host),
|
||||
my_id->get_string(my_id), other_id->get_string(other_id));
|
||||
"found an existing IKE_SA for %H[%D]...%H[%D]",
|
||||
my_host, other_host, my_id, other_id);
|
||||
entry->checked_out = TRUE;
|
||||
ike_sa = entry->ike_sa;
|
||||
}
|
||||
@@ -417,13 +416,12 @@ static ike_sa_t* checkout_by_id(private_ike_sa_manager_t *this,
|
||||
|
||||
/* check ike_sa out */
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1,
|
||||
"new IKE_SA created for IDs %s - %s",
|
||||
my_id->get_string(my_id), other_id->get_string(other_id));
|
||||
"new IKE_SA created for IDs %D - %D", my_id, other_id);
|
||||
new_ike_sa_entry->checked_out = TRUE;
|
||||
ike_sa = new_ike_sa_entry->ike_sa;
|
||||
}
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
SIG_SA(ike_sa);
|
||||
return ike_sa;
|
||||
}
|
||||
|
||||
@@ -540,6 +538,8 @@ static ike_sa_t* checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
SIG_SA(ike_sa);
|
||||
return ike_sa;
|
||||
}
|
||||
|
||||
@@ -575,6 +575,7 @@ static ike_sa_t* checkout_by_child(private_ike_sa_manager_t *this,
|
||||
iterator->destroy(iterator);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
SIG_SA(ike_sa);
|
||||
return ike_sa;
|
||||
}
|
||||
|
||||
@@ -679,6 +680,8 @@ static status_t checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
|
||||
this->logger->log(this->logger, CONTROL|LEVEL2, "%d IKE_SAs in manager now",
|
||||
this->ike_sa_list->get_count(this->ike_sa_list));
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
SIG_SA(NULL);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -725,6 +728,7 @@ static status_t checkin_and_destroy(private_ike_sa_manager_t *this, ike_sa_t *ik
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
SIG_SA(NULL);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -694,8 +694,8 @@ static status_t get_response(private_ike_auth_t *this, message_t *request,
|
||||
if (this->policy == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, AUDIT,
|
||||
"no acceptable policy for IDs %s - %s found, deleting IKE_SA",
|
||||
my_id->get_string(my_id), other_id->get_string(other_id));
|
||||
"no acceptable policy for IDs %D - %D found, deleting IKE_SA",
|
||||
my_id, other_id);
|
||||
my_id->destroy(my_id);
|
||||
other_id->destroy(other_id);
|
||||
build_notify(AUTHENTICATION_FAILED, response, TRUE);
|
||||
@@ -939,9 +939,8 @@ static status_t conclude(private_ike_auth_t *this, message_t *response,
|
||||
{
|
||||
other_id->destroy(other_id);
|
||||
this->logger->log(this->logger, AUDIT,
|
||||
"other peer uses unacceptable ID (%s, excepted %s), deleting IKE_SA",
|
||||
other_id->get_string(other_id),
|
||||
configured_other_id->get_string(configured_other_id));
|
||||
"other peer uses unacceptable ID (%D, excepted %D), deleting IKE_SA",
|
||||
other_id, configured_other_id);
|
||||
return DESTROY_ME;
|
||||
}
|
||||
/* update other ID. It was already set, but may contain wildcards */
|
||||
|
||||
@@ -570,8 +570,8 @@ static status_t get_response(private_ike_sa_init_t *this,
|
||||
response->add_payload(response, (payload_t*)notify);
|
||||
|
||||
this->logger->log(this->logger, AUDIT,
|
||||
"no connection for hosts %s...%s found, deleting IKE_SA",
|
||||
me->get_string(me), other->get_string(other));
|
||||
"no connection for hosts %H...%H found, deleting IKE_SA",
|
||||
me, other);
|
||||
return DESTROY_ME;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user