aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/config
diff options
context:
space:
mode:
Diffstat (limited to 'Source/charon/config')
-rw-r--r--Source/charon/config/connections/connection.c21
-rw-r--r--Source/charon/config/connections/connection.h26
-rw-r--r--Source/charon/config/policies/local_policy_store.c14
-rw-r--r--Source/charon/config/policies/policy.h2
4 files changed, 51 insertions, 12 deletions
diff --git a/Source/charon/config/connections/connection.c b/Source/charon/config/connections/connection.c
index 2ce544cc9..74e6762b4 100644
--- a/Source/charon/config/connections/connection.c
+++ b/Source/charon/config/connections/connection.c
@@ -111,6 +111,24 @@ static identification_t *get_other_id(private_connection_t *this)
}
/**
+ * Implementation of connection_t.update_my_id
+ */
+static void update_my_id(private_connection_t *this, identification_t *my_id)
+{
+ this->my_id->destroy(this->my_id);
+ this->my_id = my_id;
+}
+
+/**
+ * Implementation of connection_t.update_other_id
+ */
+static void update_other_id(private_connection_t *this, identification_t *other_id)
+{
+ this->other_id->destroy(this->other_id);
+ this->other_id = other_id;
+}
+
+/**
* Implementation of connection_t.get_my_host.
*/
static host_t * get_my_host (private_connection_t *this)
@@ -305,6 +323,7 @@ static void destroy (private_connection_t *this)
this->other_host->destroy(this->other_host);
this->my_id->destroy(this->my_id);
this->other_id->destroy(this->other_id);
+ free(this->name);
free(this);
}
@@ -322,6 +341,8 @@ connection_t * connection_create(char *name, host_t *my_host, host_t *other_host
this->public.get_my_host = (host_t*(*)(connection_t*))get_my_host;
this->public.update_my_host = (void(*)(connection_t*,host_t*))update_my_host;
this->public.update_other_host = (void(*)(connection_t*,host_t*))update_other_host;
+ this->public.update_my_id = (void(*)(connection_t*,identification_t*))update_my_id;
+ this->public.update_other_id = (void(*)(connection_t*,identification_t*))update_other_id;
this->public.get_other_host = (host_t*(*)(connection_t*))get_other_host;
this->public.get_proposals = (linked_list_t*(*)(connection_t*))get_proposals;
this->public.select_proposal = (proposal_t*(*)(connection_t*,linked_list_t*))select_proposal;
diff --git a/Source/charon/config/connections/connection.h b/Source/charon/config/connections/connection.h
index fb960d1a0..2cb3c20b8 100644
--- a/Source/charon/config/connections/connection.h
+++ b/Source/charon/config/connections/connection.h
@@ -143,6 +143,32 @@ struct connection_t {
* @param my_host new host to set as other_host
*/
void (*update_other_host) (connection_t *this, host_t *other_host);
+
+ /**
+ * @brief Update own ID.
+ *
+ * It may be necessary to uptdate own ID, as it
+ * is set to %any or to e.g. *@strongswan.org in
+ * some cases.
+ * Old ID is destroyed, new one NOT cloned.
+ *
+ * @param this calling object
+ * @param my_id new ID to set as my_id
+ */
+ void (*update_my_id) (connection_t *this, identification_t *my_id);
+
+ /**
+ * @brief Update others ID.
+ *
+ * It may be necessary to uptdate others ID, as it
+ * is set to %any or to e.g. *@strongswan.org in
+ * some cases.
+ * Old ID is destroyed, new one NOT cloned.
+ *
+ * @param this calling object
+ * @param other_id new ID to set as other_id
+ */
+ void (*update_other_id) (connection_t *this, identification_t *other_id);
/**
* @brief Returns a list of all supported proposals.
diff --git a/Source/charon/config/policies/local_policy_store.c b/Source/charon/config/policies/local_policy_store.c
index 7dcdf1728..ae02357ea 100644
--- a/Source/charon/config/policies/local_policy_store.c
+++ b/Source/charon/config/policies/local_policy_store.c
@@ -66,7 +66,7 @@ static policy_t *get_policy(private_local_policy_store_t *this, identification_t
iterator_t *iterator;
policy_t *current, *found = NULL;
- this->logger->log(this->logger, CONTROL|LEVEL0, "Looking for policy for IDs %s - %s",
+ this->logger->log(this->logger, CONTROL|LEVEL1, "Looking for policy for IDs %s - %s",
my_id ? my_id->get_string(my_id) : "%any",
other_id->get_string(other_id));
iterator = this->policies->create_iterator(this->policies, TRUE);
@@ -76,7 +76,7 @@ static policy_t *get_policy(private_local_policy_store_t *this, identification_t
identification_t *config_my_id = current->get_my_id(current);
identification_t *config_other_id = current->get_other_id(current);
- this->logger->log(this->logger, CONTROL|LEVEL0, "Found one for %s - %s",
+ this->logger->log(this->logger, CONTROL|LEVEL2, "Found one for %s - %s",
config_my_id->get_string(config_my_id),
config_other_id->get_string(config_other_id));
@@ -84,11 +84,6 @@ static policy_t *get_policy(private_local_policy_store_t *this, identification_t
if (other_id->belongs_to(other_id, config_other_id))
{
/* get it if my_id not specified */
- if (my_id == NULL)
- {
- found = current->clone(current);
- break;
- }
if (my_id->belongs_to(my_id, config_my_id))
{
found = current->clone(current);
@@ -101,10 +96,7 @@ static policy_t *get_policy(private_local_policy_store_t *this, identification_t
/* apply IDs as they are requsted, since they may be configured as %any or such */
if (found)
{
- if (my_id)
- {
- found->update_my_id(found, my_id->clone(my_id));
- }
+ found->update_my_id(found, my_id->clone(my_id));
found->update_other_id(found, other_id->clone(other_id));
}
return found;
diff --git a/Source/charon/config/policies/policy.h b/Source/charon/config/policies/policy.h
index 5a0823758..78cda1e8b 100644
--- a/Source/charon/config/policies/policy.h
+++ b/Source/charon/config/policies/policy.h
@@ -79,7 +79,7 @@ struct policy_t {
void (*update_my_id) (policy_t *this, identification_t *my_id);
/**
- * @brief Update others id.
+ * @brief Update others ID.
*
* It may be necessary to uptdate others ID, as it
* is set to %any or to e.g. *@strongswan.org in