diff options
Diffstat (limited to 'src/charon/config')
-rw-r--r-- | src/charon/config/attributes/attribute_manager.c | 30 | ||||
-rw-r--r-- | src/charon/config/attributes/attribute_manager.h | 3 | ||||
-rw-r--r-- | src/charon/config/attributes/attribute_provider.h | 3 | ||||
-rw-r--r-- | src/charon/config/backend_manager.c | 65 | ||||
-rw-r--r-- | src/charon/config/child_cfg.c | 4 | ||||
-rw-r--r-- | src/charon/config/proposal.c | 9 | ||||
-rw-r--r-- | src/charon/config/traffic_selector.c | 19 | ||||
-rw-r--r-- | src/charon/config/traffic_selector.h | 2 |
8 files changed, 67 insertions, 68 deletions
diff --git a/src/charon/config/attributes/attribute_manager.c b/src/charon/config/attributes/attribute_manager.c index 0ec84c7be..b919c4261 100644 --- a/src/charon/config/attributes/attribute_manager.c +++ b/src/charon/config/attributes/attribute_manager.c @@ -38,9 +38,9 @@ struct private_attribute_manager_t { linked_list_t *providers; /** - * mutex to lock provider list + * rwlock provider list */ - mutex_t *mutex; + rwlock_t *lock; }; /** @@ -54,7 +54,7 @@ static host_t* acquire_address(private_attribute_manager_t *this, attribute_provider_t *current; host_t *host = NULL; - this->mutex->lock(this->mutex); + this->lock->read_lock(this->lock); enumerator = this->providers->create_enumerator(this->providers); while (enumerator->enumerate(enumerator, ¤t)) { @@ -65,7 +65,7 @@ static host_t* acquire_address(private_attribute_manager_t *this, } } enumerator->destroy(enumerator); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); return host; } @@ -74,22 +74,22 @@ static host_t* acquire_address(private_attribute_manager_t *this, * Implementation of attribute_manager_t.release_address. */ static void release_address(private_attribute_manager_t *this, - char *pool, host_t *address) + char *pool, host_t *address, identification_t *id) { enumerator_t *enumerator; attribute_provider_t *current; - this->mutex->lock(this->mutex); + this->lock->read_lock(this->lock); enumerator = this->providers->create_enumerator(this->providers); while (enumerator->enumerate(enumerator, ¤t)) { - if (current->release_address(current, pool, address)) + if (current->release_address(current, pool, address, id)) { break; } } enumerator->destroy(enumerator); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); } /** @@ -98,9 +98,9 @@ static void release_address(private_attribute_manager_t *this, static void add_provider(private_attribute_manager_t *this, attribute_provider_t *provider) { - this->mutex->lock(this->mutex); + this->lock->write_lock(this->lock); this->providers->insert_last(this->providers, provider); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); } /** @@ -109,9 +109,9 @@ static void add_provider(private_attribute_manager_t *this, static void remove_provider(private_attribute_manager_t *this, attribute_provider_t *provider) { - this->mutex->lock(this->mutex); + this->lock->write_lock(this->lock); this->providers->remove(this->providers, provider, NULL); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); } /** @@ -120,7 +120,7 @@ static void remove_provider(private_attribute_manager_t *this, static void destroy(private_attribute_manager_t *this) { this->providers->destroy(this->providers); - this->mutex->destroy(this->mutex); + this->lock->destroy(this->lock); free(this); } @@ -132,13 +132,13 @@ attribute_manager_t *attribute_manager_create() private_attribute_manager_t *this = malloc_thing(private_attribute_manager_t); this->public.acquire_address = (host_t*(*)(attribute_manager_t*, char*, identification_t*,auth_info_t*,host_t*))acquire_address; - this->public.release_address = (void(*)(attribute_manager_t*, char *, host_t*))release_address; + this->public.release_address = (void(*)(attribute_manager_t*, char *, host_t*, identification_t*))release_address; this->public.add_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))add_provider; this->public.remove_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))remove_provider; this->public.destroy = (void(*)(attribute_manager_t*))destroy; this->providers = linked_list_create(); - this->mutex = mutex_create(MUTEX_DEFAULT); + this->lock = rwlock_create(RWLOCK_DEFAULT); return &this->public; } diff --git a/src/charon/config/attributes/attribute_manager.h b/src/charon/config/attributes/attribute_manager.h index 540e054fd..d2b69e02d 100644 --- a/src/charon/config/attributes/attribute_manager.h +++ b/src/charon/config/attributes/attribute_manager.h @@ -50,9 +50,10 @@ struct attribute_manager_t { * * @param pool pool name from which the address was acquired * @param address address to release + * @param id peer identity to get address for */ void (*release_address)(attribute_manager_t *this, - char *pool, host_t *address); + char *pool, host_t *address, identification_t *id); /** * Register an attribute provider to the manager. diff --git a/src/charon/config/attributes/attribute_provider.h b/src/charon/config/attributes/attribute_provider.h index 1712bd188..9810c0354 100644 --- a/src/charon/config/attributes/attribute_provider.h +++ b/src/charon/config/attributes/attribute_provider.h @@ -51,10 +51,11 @@ struct attribute_provider_t { * * @param pool name of the pool this address was acquired from * @param address address to release + * @param id peer ID * @return TRUE if the address has been released by the provider */ bool (*release_address)(attribute_provider_t *this, - char *pool, host_t *address); + char *pool, host_t *address, identification_t *id); }; #endif /* ATTRIBUTE_PROVIDER_H_ @}*/ diff --git a/src/charon/config/backend_manager.c b/src/charon/config/backend_manager.c index 3f92ee96a..a9fe974af 100644 --- a/src/charon/config/backend_manager.c +++ b/src/charon/config/backend_manager.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: backend_manager.c 4610 2008-11-11 06:19:37Z andreas $ + * $Id: backend_manager.c 4758 2008-12-04 23:16:10Z andreas $ */ #include "backend_manager.h" @@ -43,9 +43,9 @@ struct private_backend_manager_t { linked_list_t *backends; /** - * locking mutex + * rwlock for backends */ - mutex_t *mutex; + rwlock_t *lock; }; /** @@ -77,24 +77,6 @@ typedef struct { } peer_data_t; /** - * destroy IKE enumerator data and unlock list - */ -static void ike_enum_destroy(ike_data_t *data) -{ - data->this->mutex->unlock(data->this->mutex); - free(data); -} - -/** - * destroy PEER enumerator data and unlock list - */ -static void peer_enum_destroy(peer_data_t *data) -{ - data->this->mutex->unlock(data->this->mutex); - free(data); -} - -/** * inner enumerator constructor for IKE cfgs */ static enumerator_t *ike_enum_create(backend_t *backend, ike_data_t *data) @@ -177,14 +159,14 @@ static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this, DBG2(DBG_CFG, "looking for an ike config for %H...%H", me, other); - this->mutex->lock(this->mutex); + this->lock->read_lock(this->lock); enumerator = enumerator_create_nested( this->backends->create_enumerator(this->backends), - (void*)ike_enum_create, data, (void*)ike_enum_destroy); + (void*)ike_enum_create, data, (void*)free); while (enumerator->enumerate(enumerator, (void**)¤t)) { match = get_match(current, me, other); - + if (match) { DBG2(DBG_CFG, " candidate: %s...%s, prio %d", @@ -200,7 +182,7 @@ static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this, } } enumerator->destroy(enumerator); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); if (found) { DBG2(DBG_CFG, "found matching ike config: %s...%s with prio %d", @@ -212,11 +194,11 @@ static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this, static enumerator_t *create_peer_cfg_enumerator(private_backend_manager_t *this) { - this->mutex->lock(this->mutex); + this->lock->read_lock(this->lock); return enumerator_create_nested( this->backends->create_enumerator(this->backends), - (void*)peer_enum_create_all, this->mutex, - (void*)this->mutex->unlock); + (void*)peer_enum_create_all, this->lock, + (void*)this->lock->unlock); } /** @@ -240,16 +222,16 @@ static peer_cfg_t *get_peer_cfg(private_backend_manager_t *this, host_t *me, data->me = my_id; data->other = other_id; - this->mutex->lock(this->mutex); + this->lock->read_lock(this->lock); enumerator = enumerator_create_nested( this->backends->create_enumerator(this->backends), - (void*)peer_enum_create, data, (void*)peer_enum_destroy); + (void*)peer_enum_create, data, (void*)free); while (enumerator->enumerate(enumerator, ¤t)) { identification_t *my_cand, *other_cand; id_match_t m1, m2, match_peer; ike_cfg_match_t match_ike; - + my_cand = current->get_my_id(current); other_cand = current->get_other_id(current); @@ -270,7 +252,8 @@ static peer_cfg_t *get_peer_cfg(private_backend_manager_t *this, host_t *me, DBG2(DBG_CFG, " candidate \"%s\": %D...%D with prio %d.%d", current->get_name(current), my_cand, other_cand, match_peer, match_ike); - if (match_peer >= best_peer && match_ike > best_ike) + if ((match_peer > best_peer && match_ike >= best_ike) || + (match_peer >= best_peer && match_ike > best_ike)) { DESTROY_IF(found); found = current; @@ -287,7 +270,7 @@ static peer_cfg_t *get_peer_cfg(private_backend_manager_t *this, host_t *me, found->get_other_id(found), best_peer, best_ike); } enumerator->destroy(enumerator); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); return found; } @@ -300,14 +283,14 @@ static peer_cfg_t *get_peer_cfg_by_name(private_backend_manager_t *this, char *n peer_cfg_t *config = NULL; enumerator_t *enumerator; - this->mutex->lock(this->mutex); + this->lock->read_lock(this->lock); enumerator = this->backends->create_enumerator(this->backends); while (config == NULL && enumerator->enumerate(enumerator, (void**)&backend)) { config = backend->get_peer_cfg_by_name(backend, name); } enumerator->destroy(enumerator); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); return config; } @@ -316,9 +299,9 @@ static peer_cfg_t *get_peer_cfg_by_name(private_backend_manager_t *this, char *n */ static void remove_backend(private_backend_manager_t *this, backend_t *backend) { - this->mutex->lock(this->mutex); + this->lock->write_lock(this->lock); this->backends->remove(this->backends, backend, NULL); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); } /** @@ -326,9 +309,9 @@ static void remove_backend(private_backend_manager_t *this, backend_t *backend) */ static void add_backend(private_backend_manager_t *this, backend_t *backend) { - this->mutex->lock(this->mutex); + this->lock->write_lock(this->lock); this->backends->insert_last(this->backends, backend); - this->mutex->unlock(this->mutex); + this->lock->unlock(this->lock); } /** @@ -337,7 +320,7 @@ static void add_backend(private_backend_manager_t *this, backend_t *backend) static void destroy(private_backend_manager_t *this) { this->backends->destroy(this->backends); - this->mutex->destroy(this->mutex); + this->lock->destroy(this->lock); free(this); } @@ -357,7 +340,7 @@ backend_manager_t *backend_manager_create() this->public.destroy = (void (*)(backend_manager_t*))destroy; this->backends = linked_list_create(); - this->mutex = mutex_create(MUTEX_RECURSIVE); + this->lock = rwlock_create(RWLOCK_DEFAULT); return &this->public; } diff --git a/src/charon/config/child_cfg.c b/src/charon/config/child_cfg.c index ab083b212..737a38e89 100644 --- a/src/charon/config/child_cfg.c +++ b/src/charon/config/child_cfg.c @@ -14,7 +14,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: child_cfg.c 4611 2008-11-11 06:29:25Z andreas $ + * $Id: child_cfg.c 4862 2009-02-11 16:41:37Z andreas $ */ #include "child_cfg.h" @@ -301,7 +301,7 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca else { DBG2(DBG_CFG, " config: %R, received: %R => no match", - ts1, ts2, selected); + ts1, ts2); } } e2->destroy(e2); diff --git a/src/charon/config/proposal.c b/src/charon/config/proposal.c index 202dc913a..8fcbdc960 100644 --- a/src/charon/config/proposal.c +++ b/src/charon/config/proposal.c @@ -13,7 +13,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: proposal.c 4635 2008-11-12 08:27:48Z martin $ + * $Id: proposal.c 4685 2008-11-22 16:14:55Z martin $ */ #include <string.h> @@ -739,6 +739,10 @@ static status_t add_string_algo(private_proposal_t *this, chunk_t alg) add_algorithm(this, PSEUDO_RANDOM_FUNCTION, PRF_AES128_XCBC, 0); } } + else if (strncmp(alg.ptr, "modpnull", alg.len) == 0) + { + add_algorithm(this, DIFFIE_HELLMAN_GROUP, MODP_NULL, 0); + } else if (strncmp(alg.ptr, "modp768", alg.len) == 0) { add_algorithm(this, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0); @@ -1030,6 +1034,9 @@ static void proposal_add_supported_ike(private_proposal_t *this) { switch (group) { + case MODP_NULL: + /* only for testing purposes */ + break; case MODP_768_BIT: /* weak */ break; diff --git a/src/charon/config/traffic_selector.c b/src/charon/config/traffic_selector.c index d4235c32a..7442fc7ef 100644 --- a/src/charon/config/traffic_selector.c +++ b/src/charon/config/traffic_selector.c @@ -14,7 +14,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: traffic_selector.c 4639 2008-11-12 15:09:24Z martin $ + * $Id: traffic_selector.c 4860 2009-02-11 13:09:52Z martin $ */ #include <arpa/inet.h> @@ -196,8 +196,7 @@ static int print(FILE *stream, const struct printf_info *info, memeq(this->from, from, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16) && memeq(this->to, to, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16)) { - written += fprintf(stream, "dynamic/%d", - this->type == TS_IPV4_ADDR_RANGE ? 32 : 128); + written += fprintf(stream, "dynamic"); } else { @@ -521,9 +520,17 @@ static void set_address(private_traffic_selector_t *this, host_t *host) this->type = host->get_family(host) == AF_INET ? TS_IPV4_ADDR_RANGE : TS_IPV6_ADDR_RANGE; - chunk_t from = host->get_address(host); - memcpy(this->from, from.ptr, from.len); - memcpy(this->to, from.ptr, from.len); + if (host->is_anyaddr(host)) + { + memset(this->from6, 0x00, sizeof(this->from6)); + memset(this->to6, 0xFF, sizeof(this->to6)); + } + else + { + chunk_t from = host->get_address(host); + memcpy(this->from, from.ptr, from.len); + memcpy(this->to, from.ptr, from.len); + } } } diff --git a/src/charon/config/traffic_selector.h b/src/charon/config/traffic_selector.h index d97ffdea0..69c04c605 100644 --- a/src/charon/config/traffic_selector.h +++ b/src/charon/config/traffic_selector.h @@ -14,7 +14,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: traffic_selector.h 4643 2008-11-12 22:57:46Z andreas $ + * $Id: traffic_selector.h 4860 2009-02-11 13:09:52Z martin $ */ /** |