added name property in CHILD_SA, allows proper status output
This commit is contained in:
@@ -69,6 +69,11 @@ struct private_child_sa_t {
|
|||||||
*/
|
*/
|
||||||
child_sa_t public;
|
child_sa_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the policy used by this CHILD_SA
|
||||||
|
*/
|
||||||
|
char *name;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
/** address of peer */
|
/** address of peer */
|
||||||
host_t *addr;
|
host_t *addr;
|
||||||
@@ -157,6 +162,23 @@ struct private_child_sa_t {
|
|||||||
logger_t *logger;
|
logger_t *logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of child_sa_t.get_name.
|
||||||
|
*/
|
||||||
|
static char *get_name(private_child_sa_t *this)
|
||||||
|
{
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of child_sa_t.set_name.
|
||||||
|
*/
|
||||||
|
static void set_name(private_child_sa_t *this, char* name)
|
||||||
|
{
|
||||||
|
free(this->name);
|
||||||
|
this->name = strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements child_sa_t.get_reqid
|
* Implements child_sa_t.get_reqid
|
||||||
*/
|
*/
|
||||||
@@ -588,7 +610,7 @@ static status_t get_use_time(private_child_sa_t *this, bool inbound, time_t *use
|
|||||||
/**
|
/**
|
||||||
* Implementation of child_sa_t.log_status.
|
* Implementation of child_sa_t.log_status.
|
||||||
*/
|
*/
|
||||||
static void log_status(private_child_sa_t *this, logger_t *logger, char* name)
|
static void log_status(private_child_sa_t *this, logger_t *logger)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
iterator_t *iterator;
|
||||||
char use_in_str[12] = "unused";
|
char use_in_str[12] = "unused";
|
||||||
@@ -657,20 +679,20 @@ static void log_status(private_child_sa_t *this, logger_t *logger, char* name)
|
|||||||
|
|
||||||
logger->log(logger, CONTROL|LEVEL1,
|
logger->log(logger, CONTROL|LEVEL1,
|
||||||
" \"%s\": state: %s, reqid: %d, ",
|
" \"%s\": state: %s, reqid: %d, ",
|
||||||
name, mapping_find(child_sa_state_m, this->state), this->reqid);
|
this->name, mapping_find(child_sa_state_m, this->state), this->reqid);
|
||||||
logger->log(logger, CONTROL|LEVEL1,
|
logger->log(logger, CONTROL|LEVEL1,
|
||||||
" \"%s\": %s (%s%s), SPIs (in/out): 0x%x/0x%x",
|
" \"%s\": %s (%s%s), SPIs (in/out): 0x%x/0x%x",
|
||||||
name, this->protocol == PROTO_ESP ? "ESP" : "AH",
|
this->name, this->protocol == PROTO_ESP ? "ESP" : "AH",
|
||||||
enc_str, int_str,
|
enc_str, int_str,
|
||||||
htonl(this->me.spi), htonl(this->other.spi));
|
htonl(this->me.spi), htonl(this->other.spi));
|
||||||
logger->log(logger, CONTROL|LEVEL1,
|
logger->log(logger, CONTROL|LEVEL1,
|
||||||
" \"%s\": rekeying: %s, key age (in/out): %s/%s",
|
" \"%s\": rekeying: %s, key age (in/out): %s/%s",
|
||||||
name, rekey_str, use_in_str, use_out_str);
|
this->name, rekey_str, use_in_str, use_out_str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger->log(logger, CONTROL|LEVEL1, " \"%s\": state: %s, reqid: %d",
|
logger->log(logger, CONTROL|LEVEL1, " \"%s\": state: %s, reqid: %d",
|
||||||
name, mapping_find(child_sa_state_m, this->state),
|
this->name, mapping_find(child_sa_state_m, this->state),
|
||||||
this->reqid);
|
this->reqid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,7 +733,7 @@ static void log_status(private_child_sa_t *this, logger_t *logger, char* name)
|
|||||||
|
|
||||||
logger->log(logger, CONTROL,
|
logger->log(logger, CONTROL,
|
||||||
" \"%s\": %s====%s, last use (in/out/fwd): %s/%s/%s",
|
" \"%s\": %s====%s, last use (in/out/fwd): %s/%s/%s",
|
||||||
name, my_str, other_str, pol_in_str, pol_out_str, pol_fwd_str);
|
this->name, my_str, other_str, pol_in_str, pol_out_str, pol_fwd_str);
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
iterator->destroy(iterator);
|
||||||
}
|
}
|
||||||
@@ -911,6 +933,7 @@ static void destroy(private_child_sa_t *this)
|
|||||||
this->other_ts->destroy(this->other_ts);
|
this->other_ts->destroy(this->other_ts);
|
||||||
this->me.addr->destroy(this->me.addr);
|
this->me.addr->destroy(this->me.addr);
|
||||||
this->other.addr->destroy(this->other.addr);
|
this->other.addr->destroy(this->other.addr);
|
||||||
|
free(this->name);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -925,6 +948,8 @@ child_sa_t * child_sa_create(u_int32_t rekey, host_t *me, host_t* other,
|
|||||||
private_child_sa_t *this = malloc_thing(private_child_sa_t);
|
private_child_sa_t *this = malloc_thing(private_child_sa_t);
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
this->public.get_name = (char*(*)(child_sa_t*))get_name;
|
||||||
|
this->public.set_name = (void(*)(child_sa_t*,char*))set_name;
|
||||||
this->public.get_reqid = (u_int32_t(*)(child_sa_t*))get_reqid;
|
this->public.get_reqid = (u_int32_t(*)(child_sa_t*))get_reqid;
|
||||||
this->public.get_spi = (u_int32_t(*)(child_sa_t*, bool))get_spi;
|
this->public.get_spi = (u_int32_t(*)(child_sa_t*, bool))get_spi;
|
||||||
this->public.get_protocol = (protocol_id_t(*)(child_sa_t*))get_protocol;
|
this->public.get_protocol = (protocol_id_t(*)(child_sa_t*))get_protocol;
|
||||||
@@ -940,11 +965,12 @@ child_sa_t * child_sa_create(u_int32_t rekey, host_t *me, host_t* other,
|
|||||||
this->public.get_rekeying_transaction = (void* (*)(child_sa_t*))get_rekeying_transaction;
|
this->public.get_rekeying_transaction = (void* (*)(child_sa_t*))get_rekeying_transaction;
|
||||||
this->public.set_state = (void(*)(child_sa_t*,child_sa_state_t))set_state;
|
this->public.set_state = (void(*)(child_sa_t*,child_sa_state_t))set_state;
|
||||||
this->public.get_state = (child_sa_state_t(*)(child_sa_t*))get_state;
|
this->public.get_state = (child_sa_state_t(*)(child_sa_t*))get_state;
|
||||||
this->public.log_status = (void (*)(child_sa_t*, logger_t*, char*))log_status;
|
this->public.log_status = (void (*)(child_sa_t*, logger_t*))log_status;
|
||||||
this->public.destroy = (void(*)(child_sa_t*))destroy;
|
this->public.destroy = (void(*)(child_sa_t*))destroy;
|
||||||
|
|
||||||
/* private data */
|
/* private data */
|
||||||
this->logger = logger_manager->get_logger(logger_manager, CHILD_SA);
|
this->logger = logger_manager->get_logger(logger_manager, CHILD_SA);
|
||||||
|
this->name = strdup("(uninitialized)");
|
||||||
this->me.addr = me->clone(me);
|
this->me.addr = me->clone(me);
|
||||||
this->other.addr = other->clone(other);
|
this->other.addr = other->clone(other);
|
||||||
this->me.spi = 0;
|
this->me.spi = 0;
|
||||||
|
|||||||
@@ -101,6 +101,22 @@ typedef struct child_sa_t child_sa_t;
|
|||||||
*/
|
*/
|
||||||
struct child_sa_t {
|
struct child_sa_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the name of the policy this CHILD_SA uses.
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
char* (*get_name) (child_sa_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the name of the policy this IKE_SA uses.
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @param name name, gets cloned
|
||||||
|
*/
|
||||||
|
void (*set_name) (child_sa_t *this, char* name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the unique reqid of the CHILD SA.
|
* @brief Get the unique reqid of the CHILD SA.
|
||||||
*
|
*
|
||||||
@@ -267,14 +283,12 @@ struct child_sa_t {
|
|||||||
* The status of ESP/AH SAs is logged with the supplied logger in
|
* The status of ESP/AH SAs is logged with the supplied logger in
|
||||||
* a human readable form.
|
* a human readable form.
|
||||||
* Supplying NULL as logger uses the internal child_sa logger
|
* Supplying NULL as logger uses the internal child_sa logger
|
||||||
* to do the logging. The name is only a log-prefix without further
|
* to do the logging.
|
||||||
* meaning.
|
|
||||||
*
|
*
|
||||||
* @param this calling object
|
* @param this calling object
|
||||||
* @param logger logger to use for logging
|
* @param logger logger to use for logging
|
||||||
* @param name connection name
|
|
||||||
*/
|
*/
|
||||||
void (*log_status) (child_sa_t *this, logger_t *logger, char *name);
|
void (*log_status) (child_sa_t *this, logger_t *logger);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a child_sa.
|
* @brief Destroys a child_sa.
|
||||||
|
|||||||
+20
-3
@@ -1726,14 +1726,31 @@ static void log_status(private_ike_sa_t *this, logger_t *logger, char *name)
|
|||||||
{
|
{
|
||||||
iterator_t *iterator;
|
iterator_t *iterator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
bool contains_child = FALSE;
|
||||||
|
|
||||||
if (name == NULL || streq(name, this->name))
|
/* check for a CHILD_SA with specified name. We then print the IKE_SA,
|
||||||
|
* even it has another name */
|
||||||
|
if (name != NULL)
|
||||||
|
{
|
||||||
|
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
||||||
|
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||||
|
{
|
||||||
|
if (streq(name, child_sa->get_name(child_sa)))
|
||||||
|
{
|
||||||
|
contains_child = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iterator->destroy(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == NULL || contains_child || streq(name, this->name))
|
||||||
{
|
{
|
||||||
if (logger == NULL)
|
if (logger == NULL)
|
||||||
{
|
{
|
||||||
logger = this->logger;
|
logger = this->logger;
|
||||||
}
|
}
|
||||||
logger->log(logger, CONTROL|LEVEL1,
|
logger->log(logger, CONTROL|LEVEL1,
|
||||||
" \"%s\": IKE_SA in state %s, SPIs: 0x%.16llx 0x%.16llx",
|
" \"%s\": IKE_SA in state %s, SPIs: 0x%.16llx 0x%.16llx",
|
||||||
this->name,
|
this->name,
|
||||||
mapping_find(ike_sa_state_m, this->state),
|
mapping_find(ike_sa_state_m, this->state),
|
||||||
@@ -1750,7 +1767,7 @@ static void log_status(private_ike_sa_t *this, logger_t *logger, char *name)
|
|||||||
while (iterator->has_next(iterator))
|
while (iterator->has_next(iterator))
|
||||||
{
|
{
|
||||||
iterator->current(iterator, (void**)&child_sa);
|
iterator->current(iterator, (void**)&child_sa);
|
||||||
child_sa->log_status(child_sa, logger, this->name);
|
child_sa->log_status(child_sa, logger);
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
iterator->destroy(iterator);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ static status_t get_request(private_create_child_sa_t *this, message_t **result)
|
|||||||
this->policy->get_soft_lifetime(this->policy),
|
this->policy->get_soft_lifetime(this->policy),
|
||||||
this->policy->get_hard_lifetime(this->policy),
|
this->policy->get_hard_lifetime(this->policy),
|
||||||
use_natt);
|
use_natt);
|
||||||
|
this->child_sa->set_name(this->child_sa, this->policy->get_name(this->policy));
|
||||||
if (this->child_sa->alloc(this->child_sa, proposals) != SUCCESS)
|
if (this->child_sa->alloc(this->child_sa, proposals) != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR,
|
this->logger->log(this->logger, ERROR,
|
||||||
@@ -697,6 +698,7 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
|||||||
this->child_sa = child_sa_create(reqid, me, other,
|
this->child_sa = child_sa_create(reqid, me, other,
|
||||||
soft_lifetime, hard_lifetime,
|
soft_lifetime, hard_lifetime,
|
||||||
use_natt);
|
use_natt);
|
||||||
|
this->child_sa->set_name(this->child_sa, this->policy->get_name(this->policy));
|
||||||
if (install_child_sa(this, FALSE) != SUCCESS)
|
if (install_child_sa(this, FALSE) != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR,
|
this->logger->log(this->logger, ERROR,
|
||||||
|
|||||||
@@ -305,6 +305,7 @@ static status_t get_request(private_ike_auth_t *this, message_t **result)
|
|||||||
hard_lifetime = this->policy->get_hard_lifetime(this->policy);
|
hard_lifetime = this->policy->get_hard_lifetime(this->policy);
|
||||||
this->child_sa = child_sa_create(0, me, other, soft_lifetime, hard_lifetime,
|
this->child_sa = child_sa_create(0, me, other, soft_lifetime, hard_lifetime,
|
||||||
this->ike_sa->is_natt_enabled(this->ike_sa));
|
this->ike_sa->is_natt_enabled(this->ike_sa));
|
||||||
|
this->child_sa->set_name(this->child_sa, this->policy->get_name(this->policy));
|
||||||
if (this->child_sa->alloc(this->child_sa, proposal_list) != SUCCESS)
|
if (this->child_sa->alloc(this->child_sa, proposal_list) != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR,
|
this->logger->log(this->logger, ERROR,
|
||||||
@@ -770,6 +771,7 @@ static status_t get_response(private_ike_auth_t *this, message_t *request,
|
|||||||
this->child_sa = child_sa_create(0, me, other,
|
this->child_sa = child_sa_create(0, me, other,
|
||||||
soft_lifetime, hard_lifetime,
|
soft_lifetime, hard_lifetime,
|
||||||
use_natt);
|
use_natt);
|
||||||
|
this->child_sa->set_name(this->child_sa, this->policy->get_name(this->policy));
|
||||||
if (install_child_sa(this, FALSE) != SUCCESS)
|
if (install_child_sa(this, FALSE) != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR,
|
this->logger->log(this->logger, ERROR,
|
||||||
|
|||||||
Reference in New Issue
Block a user