- add connection names to connections
- stroke status / ipsec status shows them - added statusall for stroke - added status by connection name - some tests repaired, more to come
This commit is contained in:
@@ -467,7 +467,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
|
||||
/**
|
||||
* Implementation of child_sa_t.log_status.
|
||||
*/
|
||||
static void log_status(private_child_sa_t *this, logger_t *logger)
|
||||
static void log_status(private_child_sa_t *this, logger_t *logger, char* name)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
sa_policy_t *policy;
|
||||
@@ -479,7 +479,8 @@ static void log_status(private_child_sa_t *this, logger_t *logger)
|
||||
{
|
||||
logger = this->logger;
|
||||
}
|
||||
logger->log(logger, CONTROL, " protected with ESP (%x/%x), AH (%x,%x); traffic:",
|
||||
logger->log(logger, CONTROL|LEVEL1, "\"%s\": protected with ESP (%x/%x), AH (%x,%x):",
|
||||
name,
|
||||
htonl(this->my_esp_spi), htonl(this->other_esp_spi),
|
||||
htonl(this->my_ah_spi), htonl(this->other_ah_spi));
|
||||
iterator = this->policies->create_iterator(this->policies, TRUE);
|
||||
@@ -498,7 +499,8 @@ static void log_status(private_child_sa_t *this, logger_t *logger)
|
||||
snprintf(proto_buf, sizeof(proto_buf), "<%d>", policy->upper_proto);
|
||||
}
|
||||
}
|
||||
logger->log(logger, CONTROL, " %s/%d===%s===%s/%d",
|
||||
logger->log(logger, CONTROL, "\"%s\": %s/%d==%s==%s/%d",
|
||||
name,
|
||||
policy->my_net->get_address(policy->my_net), policy->my_net_mask,
|
||||
proto_name,
|
||||
policy->other_net->get_address(policy->other_net), policy->other_net_mask);
|
||||
@@ -570,7 +572,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other)
|
||||
this->public.add = (status_t(*)(child_sa_t*,proposal_t*,prf_plus_t*))add;
|
||||
this->public.update = (status_t(*)(child_sa_t*,proposal_t*,prf_plus_t*))update;
|
||||
this->public.add_policies = (status_t (*)(child_sa_t*, linked_list_t*,linked_list_t*))add_policies;
|
||||
this->public.log_status = (void (*)(child_sa_t*, logger_t*))log_status;
|
||||
this->public.log_status = (void (*)(child_sa_t*, logger_t*, char*))log_status;
|
||||
this->public.destroy = (void(*)(child_sa_t*))destroy;
|
||||
|
||||
/* private data */
|
||||
|
||||
@@ -118,12 +118,14 @@ struct child_sa_t {
|
||||
* The status of ESP/AH SAs is logged with the supplied logger in
|
||||
* a human readable form.
|
||||
* Supplying NULL as logger uses the internal child_sa logger
|
||||
* to do the logging.
|
||||
* to do the logging. The name is only a log-prefix without further
|
||||
* meaning.
|
||||
*
|
||||
* @param this calling object
|
||||
* @param logger logger to use for logging
|
||||
* @param name connection name
|
||||
*/
|
||||
void (*log_status) (child_sa_t *this, logger_t *logger);
|
||||
void (*log_status) (child_sa_t *this, logger_t *logger, char *name);
|
||||
|
||||
/**
|
||||
* @brief Destroys a child_sa.
|
||||
|
||||
@@ -979,11 +979,24 @@ static void reset_message_buffers (private_ike_sa_t *this)
|
||||
/**
|
||||
* Implementation of protected_ike_sa_t.log_status.
|
||||
*/
|
||||
static void log_status(private_ike_sa_t *this, logger_t *logger)
|
||||
static void log_status(private_ike_sa_t *this, logger_t *logger, char *name)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
child_sa_t *child_sa;
|
||||
|
||||
/* only log if name == NULL or name == connection_name */
|
||||
if (name)
|
||||
{
|
||||
if (strcmp(this->connection->get_name(this->connection), name) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = this->connection->get_name(this->connection);
|
||||
}
|
||||
|
||||
host_t *my_host = this->connection->get_my_host(this->connection);
|
||||
host_t *other_host = this->connection->get_other_host(this->connection);
|
||||
|
||||
@@ -994,11 +1007,13 @@ static void log_status(private_ike_sa_t *this, logger_t *logger)
|
||||
{
|
||||
logger = this->logger;
|
||||
}
|
||||
logger->log(logger, CONTROL, "IKE_SA in state %s, SPIs: %lld %lld",
|
||||
logger->log(logger, CONTROL|LEVEL1, "\"%s\": IKE_SA in state %s, SPIs: %llx %llx",
|
||||
name,
|
||||
mapping_find(ike_sa_state_m, this->current_state->get_state(this->current_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]; tunnels:",
|
||||
logger->log(logger, CONTROL, "\"%s\": %s[%s]...%s[%s]",
|
||||
name,
|
||||
my_host->get_address(my_host),
|
||||
my_id->get_string(my_id),
|
||||
other_host->get_address(other_host),
|
||||
@@ -1008,7 +1023,7 @@ static void log_status(private_ike_sa_t *this, logger_t *logger)
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
iterator->current(iterator, (void**)&child_sa);
|
||||
child_sa->log_status(child_sa, logger);
|
||||
child_sa->log_status(child_sa, logger, name);
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
}
|
||||
@@ -1109,10 +1124,11 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
|
||||
this->protected.public.get_other_host = (host_t*(*)(ike_sa_t*)) get_other_host;
|
||||
this->protected.public.get_my_id = (identification_t*(*)(ike_sa_t*)) get_my_id;
|
||||
this->protected.public.get_other_id = (identification_t*(*)(ike_sa_t*)) get_other_id;
|
||||
this->protected.public.get_connection = (connection_t*(*)(ike_sa_t*)) get_connection;
|
||||
this->protected.public.retransmit_request = (status_t (*) (ike_sa_t *, u_int32_t)) retransmit_request;
|
||||
this->protected.public.get_state = (ike_sa_state_t (*) (ike_sa_t *this)) get_state;
|
||||
this->protected.public.send_delete_ike_sa_request = (void (*)(ike_sa_t*)) send_delete_ike_sa_request;
|
||||
this->protected.public.log_status = (void (*) (ike_sa_t*,logger_t*))log_status;
|
||||
this->protected.public.log_status = (void (*) (ike_sa_t*,logger_t*,char*))log_status;
|
||||
this->protected.public.destroy = (void(*)(ike_sa_t*))destroy;
|
||||
|
||||
/* protected functions */
|
||||
|
||||
@@ -153,6 +153,19 @@ struct ike_sa_t {
|
||||
* @return remote identification_t
|
||||
*/
|
||||
identification_t* (*get_other_id) (ike_sa_t *this);
|
||||
|
||||
/**
|
||||
* @brief Get the connection of the IKE_SA.
|
||||
*
|
||||
* The internal used connection specification
|
||||
* can be queried to get some data of an IKE_SA.
|
||||
* The connection is still owned to the IKE_SA
|
||||
* and must not be manipulated.
|
||||
*
|
||||
* @param this calling object
|
||||
* @return connection_t
|
||||
*/
|
||||
connection_t* (*get_connection) (ike_sa_t *this);
|
||||
|
||||
/**
|
||||
* @brief Get the state of type of associated state object.
|
||||
@@ -167,12 +180,14 @@ struct ike_sa_t {
|
||||
*
|
||||
* The status of the IKE SA and all child SAs is logged.
|
||||
* Supplying NULL as logger uses the internal child_sa logger
|
||||
* to do the logging.
|
||||
* to do the logging. The log is only done if the supplied
|
||||
* connection name is NULL or matches the connections name.
|
||||
*
|
||||
* @param this calling object
|
||||
* @param logger logger to use for logging
|
||||
* @param name name of the connection
|
||||
*/
|
||||
void (*log_status) (ike_sa_t *this, logger_t *logger);
|
||||
void (*log_status) (ike_sa_t *this, logger_t *logger, char *name);
|
||||
|
||||
/**
|
||||
* @brief Destroys a ike_sa_t object.
|
||||
|
||||
@@ -573,6 +573,27 @@ linked_list_t *get_ike_sa_list(private_ike_sa_manager_t* this)
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ike_sa_manager_t.log_status.
|
||||
*/
|
||||
static void log_status(private_ike_sa_manager_t* this, logger_t* logger, char* name)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
|
||||
iterator = this->ike_sa_list->create_iterator(this->ike_sa_list, TRUE);
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
ike_sa_entry_t *entry;
|
||||
iterator->current(iterator, (void**)&entry);
|
||||
entry->ike_sa->log_status(entry->ike_sa, logger, name);
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ike_sa_manager_t.checkin.
|
||||
*/
|
||||
@@ -767,6 +788,7 @@ ike_sa_manager_t *ike_sa_manager_create()
|
||||
this->public.checkout = (status_t(*)(ike_sa_manager_t*, ike_sa_id_t*,ike_sa_t**))checkout;
|
||||
this->public.checkout_by_hosts = (status_t(*)(ike_sa_manager_t*,host_t*,host_t*,ike_sa_t**))checkout_by_hosts;
|
||||
this->public.get_ike_sa_list = (linked_list_t*(*)(ike_sa_manager_t*))get_ike_sa_list;
|
||||
this->public.log_status = (void(*)(ike_sa_manager_t*,logger_t*,char*))log_status;
|
||||
this->public.checkin = (status_t(*)(ike_sa_manager_t*,ike_sa_t*))checkin;
|
||||
this->public.delete = (status_t(*)(ike_sa_manager_t*,ike_sa_id_t*))delete;
|
||||
this->public.checkin_and_delete = (status_t(*)(ike_sa_manager_t*,ike_sa_t*))checkin_and_delete;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <types.h>
|
||||
#include <sa/ike_sa.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
|
||||
typedef struct ike_sa_manager_t ike_sa_manager_t;
|
||||
@@ -58,7 +59,7 @@ struct ike_sa_manager_t {
|
||||
* @warning checking out two times without checking in will
|
||||
* result in a deadlock!
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @param ike_sa_id[in/out] the SA identifier, will be updated
|
||||
* @param ike_sa[out] checked out SA
|
||||
* @returns
|
||||
@@ -66,7 +67,7 @@ struct ike_sa_manager_t {
|
||||
* - NOT_FOUND when no such SA is available
|
||||
* - CREATED if a new IKE_SA got created
|
||||
*/
|
||||
status_t (*checkout) (ike_sa_manager_t* ike_sa_manager, ike_sa_id_t *sa_id, ike_sa_t **ike_sa);
|
||||
status_t (*checkout) (ike_sa_manager_t* this, ike_sa_id_t *sa_id, ike_sa_t **ike_sa);
|
||||
|
||||
/**
|
||||
* @brief Create and checkout an IKE_SA as original initator.
|
||||
@@ -74,10 +75,10 @@ struct ike_sa_manager_t {
|
||||
* Creates and checks out a SA as initiator.
|
||||
* Management of SPIs is the managers job, he will set it.
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @param ike_sa[out] checked out SA
|
||||
*/
|
||||
void (*create_and_checkout) (ike_sa_manager_t* ike_sa_manager,ike_sa_t **ike_sa);
|
||||
void (*create_and_checkout) (ike_sa_manager_t* this,ike_sa_t **ike_sa);
|
||||
|
||||
/**
|
||||
* @brief Check out an IKE_SA, defined be the two peers.
|
||||
@@ -86,7 +87,7 @@ struct ike_sa_manager_t {
|
||||
* for kernel traps, status querying and so on... one of the hosts
|
||||
* may be 0.0.0.0 (defaultroute/any), but not both.
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @param me host on local side
|
||||
* @param other host on remote side
|
||||
* @param ike_sa[out] checked out SA
|
||||
@@ -94,7 +95,7 @@ struct ike_sa_manager_t {
|
||||
* - NOT_FOUND, if no such SA found
|
||||
* - SUCCESS, if SA found and ike_sa set appropriatly
|
||||
*/
|
||||
status_t (*checkout_by_hosts) (ike_sa_manager_t* ike_sa_manager, host_t *me, host_t *other, ike_sa_t **ike_sa);
|
||||
status_t (*checkout_by_hosts) (ike_sa_manager_t* this, host_t *me, host_t *other, ike_sa_t **ike_sa);
|
||||
|
||||
/**
|
||||
* @brief Get a list of all IKE_SA SAs currently set up.
|
||||
@@ -104,10 +105,23 @@ struct ike_sa_manager_t {
|
||||
* corrensponding ID really exists, since it may be deleted
|
||||
* in the meantime by another thread.
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @return a list with ike_sa_id_t s
|
||||
*/
|
||||
linked_list_t *(*get_ike_sa_list) (ike_sa_manager_t* ike_sa_manager);
|
||||
linked_list_t *(*get_ike_sa_list) (ike_sa_manager_t* this);
|
||||
|
||||
/**
|
||||
* @brief Log the status of the IKE_SA's in the manager.
|
||||
*
|
||||
* A informational log is done to the supplied logger. If logger is
|
||||
* NULL, an internal logger is used. If a name is supplied,
|
||||
* only connections with the matching name will be logged.
|
||||
*
|
||||
* @param this the manager object
|
||||
* @param logger logger to do the log, or NULL
|
||||
* @param name name of a connection, or NULL
|
||||
*/
|
||||
void (*log_status) (ike_sa_manager_t* this, logger_t* logger, char* name);
|
||||
|
||||
/**
|
||||
* @brief Checkin the SA after usage.
|
||||
@@ -115,14 +129,14 @@ struct ike_sa_manager_t {
|
||||
* @warning the SA pointer MUST NOT be used after checkin!
|
||||
* The SA must be checked out again!
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @param ike_sa_id[in/out] the SA identifier, will be updated
|
||||
* @param ike_sa[out] checked out SA
|
||||
* @returns
|
||||
* - SUCCESS if checked in
|
||||
* - NOT_FOUND when not found (shouldn't happen!)
|
||||
*/
|
||||
status_t (*checkin) (ike_sa_manager_t* ike_sa_manager, ike_sa_t *ike_sa);
|
||||
status_t (*checkin) (ike_sa_manager_t* this, ike_sa_t *ike_sa);
|
||||
|
||||
/**
|
||||
* @brief Delete a SA, which was not checked out.
|
||||
@@ -130,33 +144,33 @@ struct ike_sa_manager_t {
|
||||
* @warning do not use this when the SA is already checked out, this will
|
||||
* deadlock!
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @param ike_sa_id[in/out] the SA identifier
|
||||
* @returns
|
||||
* - SUCCESS if found
|
||||
* - NOT_FOUND when no such SA is available
|
||||
*/
|
||||
status_t (*delete) (ike_sa_manager_t* ike_sa_manager, ike_sa_id_t *ike_sa_id);
|
||||
status_t (*delete) (ike_sa_manager_t* this, ike_sa_id_t *ike_sa_id);
|
||||
|
||||
/**
|
||||
* @brief Delete a checked out SA.
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
* @param ike_sa SA to delete
|
||||
* @returns
|
||||
* - SUCCESS if found
|
||||
* - NOT_FOUND when no such SA is available
|
||||
*/
|
||||
status_t (*checkin_and_delete) (ike_sa_manager_t* ike_sa_manager, ike_sa_t *ike_sa);
|
||||
status_t (*checkin_and_delete) (ike_sa_manager_t* this, ike_sa_t *ike_sa);
|
||||
|
||||
/**
|
||||
* @brief Destroys the manager with all associated SAs.
|
||||
*
|
||||
* Threads will be driven out, so all SAs can be deleted cleanly.
|
||||
*
|
||||
* @param ike_sa_manager the manager object
|
||||
* @param this the manager object
|
||||
*/
|
||||
void (*destroy) (ike_sa_manager_t *ike_sa_manager);
|
||||
void (*destroy) (ike_sa_manager_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user