- applied andreas's patch

- logger output improvements
  - testin gupdates
  - and a lot more
This commit is contained in:
Martin Willi
2006-05-18 06:02:28 +00:00
parent 1e93135408
commit b5e1560659
151 changed files with 348 additions and 203 deletions
@@ -57,69 +57,84 @@ struct private_local_connection_store_t {
*/
static connection_t *get_connection_by_hosts(private_local_connection_store_t *this, host_t *my_host, host_t *other_host)
{
typedef enum {
PRIO_UNDEFINED= 0x00,
PRIO_ADDR_ANY= 0x01,
PRIO_ADDR_MATCH= 0x02
} prio_t;
prio_t best_prio = PRIO_UNDEFINED;
iterator_t *iterator;
connection_t *current, *found = NULL;
connection_t *candidate;
connection_t *found = NULL;
this->logger->log(this->logger, CONTROL|LEVEL1, "getting config for hosts %s - %s",
this->logger->log(this->logger, CONTROL|LEVEL1, "searching connection for host pair %s...%s",
my_host->get_address(my_host), other_host->get_address(other_host));
iterator = this->connections->create_iterator(this->connections, TRUE);
/* determine closest matching connection */
while (iterator->has_next(iterator))
{
host_t *config_my_host, *config_other_host;
host_t *candidate_my_host;
host_t *candidate_other_host;
iterator->current(iterator, (void**)&current);
iterator->current(iterator, (void**)&candidate);
config_my_host = current->get_my_host(current);
config_other_host = current->get_other_host(current);
candidate_my_host = candidate->get_my_host(candidate);
candidate_other_host = candidate->get_other_host(candidate);
/* first check if ip is equal */
if(config_other_host->ip_equals(config_other_host, other_host))
/* my_host addresses must match*/
if (my_host->ip_equals(my_host, candidate_my_host))
{
this->logger->log(this->logger, CONTROL|LEVEL2, "config entry with remote host %s",
config_other_host->get_address(config_other_host));
/* could be right one, check my_host for default route*/
if (config_my_host->is_default_route(config_my_host))
prio_t prio = PRIO_UNDEFINED;
/* exact match of peer host address or wildcard address? */
if (other_host->ip_equals(other_host, candidate_other_host))
{
found = current->clone(current);
break;
prio |= PRIO_ADDR_MATCH;
}
/* check now if host informations are the same */
else if (config_my_host->ip_equals(config_my_host,my_host))
else if (candidate_other_host->is_anyaddr(candidate_other_host))
{
found = current->clone(current);
break;
prio |= PRIO_ADDR_ANY;
}
}
/* Then check for wildcard hosts!
* TODO
* actually its only checked if other host with default route can be found! */
else if (config_other_host->is_default_route(config_other_host))
{
/* could be right one, check my_host for default route*/
if (config_my_host->is_default_route(config_my_host))
this->logger->log(this->logger, CONTROL|LEVEL2,
"candidate connection \"%s\": %s...%s (prio=%d)",
candidate->get_name(candidate),
candidate_my_host->get_address(candidate_my_host),
candidate_other_host->get_address(candidate_other_host),
prio);
if (prio > best_prio)
{
found = current->clone(current);
break;
}
/* check now if host informations are the same */
else if (config_my_host->ip_equals(config_my_host,my_host))
{
found = current->clone(current);
break;
}
found = candidate;
best_prio = prio;
}
}
}
iterator->destroy(iterator);
/* apply hosts as they are supplied since my_host may be %defaultroute, and other_host may be %any. */
if (found)
{
found->update_my_host(found, my_host->clone(my_host));
found->update_other_host(found, other_host->clone(other_host));
host_t *found_my_host = found->get_my_host(found);
host_t *found_other_host = found->get_other_host(found);
this->logger->log(this->logger, CONTROL|LEVEL1,
"found matching connection \"%s\": %s...%s (prio=%d)",
found->get_name(found),
found_my_host->get_address(found_my_host),
found_other_host->get_address(found_other_host),
best_prio);
found = found->clone(found);
if (best_prio & PRIO_ADDR_ANY)
{
/* replace %any by the peer's address */
found->update_other_host(found, other_host->clone(other_host));
}
}
return found;
}
+3 -5
View File
@@ -390,11 +390,9 @@ static bool is_listening_on(private_socket_t *this, host_t *host)
{
iterator_t *iterator;
/* listening on 0.0.0.0 is always TRUE */
if (host->is_default_route(host))
{
return TRUE;
}
/* listening on wildcard 0.0.0.0 is always FALSE */
if (host->is_anyaddr(host))
return FALSE;
/* compare host with all interfaces */
iterator = this->interfaces->create_iterator(this->interfaces, TRUE);
+3 -3
View File
@@ -507,9 +507,9 @@ static status_t checkout_by_hosts(private_ike_sa_manager_t *this, host_t *me, ho
sa_other = current->ike_sa->get_other_host(current->ike_sa);
/* one end may be default/any, but not both */
if (me->is_default_route(me))
if (me->is_anyaddr(me))
{
if (other->is_default_route(other))
if (other->is_anyaddr(other))
{
break;
}
@@ -519,7 +519,7 @@ static status_t checkout_by_hosts(private_ike_sa_manager_t *this, host_t *me, ho
ike_sa_id = current->ike_sa_id;
}
}
else if (other->is_default_route(other))
else if (other->is_anyaddr(other))
{
if (me->equals(me, sa_me))
{
+1 -1
View File
@@ -74,7 +74,7 @@ static void receive_packets(private_receiver_t * this)
/* cancellation disabled by default */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
this->logger->log(this->logger, CONTROL, "Receiver thread running, thread_id %u", (int)pthread_self());
this->logger->log(this->logger, CONTROL, "receiver thread running, thread_ID: %06d", (int)pthread_self());
while (1)
{
+1 -1
View File
@@ -72,7 +72,7 @@ static void get_events(private_scheduler_t * this)
/* cancellation disabled by default */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
this->logger->log(this->logger, CONTROL, "Scheduler thread running, thread_id %u", (int)pthread_self());
this->logger->log(this->logger, CONTROL, "scheduler thread running, thread_ID: %06d", (int)pthread_self());
for (;;)
{
+1 -1
View File
@@ -73,7 +73,7 @@ static void send_packets(private_sender_t * this)
/* cancellation disabled by default */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
this->logger->log(this->logger, CONTROL, "Sender thread running, thread_id %u", (int)pthread_self());
this->logger->log(this->logger, CONTROL, "sender thread running, thread_ID: %06d", (int)pthread_self());
while (1)
{
+8 -7
View File
@@ -240,9 +240,6 @@ static void stroke_add_conn(private_stroke_t *this, stroke_msg_t *msg)
my_id = cert->get_subject(cert);
my_id = my_id->clone(my_id);
cert->destroy(cert);
this->logger->log(this->logger, CONTROL,
"valid certificate with ID \"%s\"",
my_id->get_string(my_id));
}
}
if (msg->add_conn.other.cert)
@@ -256,9 +253,6 @@ static void stroke_add_conn(private_stroke_t *this, stroke_msg_t *msg)
other_id = cert->get_subject(cert);
other_id = other_id->clone(other_id);
cert->destroy(cert);
this->logger->log(this->logger, CONTROL,
"valid certificate with ID \"%s\"",
other_id->get_string(other_id));
}
}
@@ -278,8 +272,15 @@ static void stroke_add_conn(private_stroke_t *this, stroke_msg_t *msg)
proposal->add_algorithm(proposal, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_4096_BIT, 0);
proposal->add_algorithm(proposal, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_8192_BIT, 0);
connection->add_proposal(connection, proposal);
/* add to global connection list */
charon->connections->add_connection(charon->connections, connection);
this->logger->log(this->logger, CONTROL, "added connection \"%s\": %s[%s]...%s[%s]",
msg->add_conn.name,
my_host->get_address(my_host),
my_id->get_string(my_id),
other_host->get_address(other_host),
other_id->get_string(other_id));
policy = policy_create(my_id, other_id);
proposal = proposal_create(1);
@@ -289,10 +290,10 @@ static void stroke_add_conn(private_stroke_t *this, stroke_msg_t *msg)
policy->add_proposal(policy, proposal);
policy->add_my_traffic_selector(policy, my_ts);
policy->add_other_traffic_selector(policy, other_ts);
/* add to global policy list */
charon->policies->add_policy(charon->policies, policy);
this->stroke_logger->log(this->stroke_logger, CONTROL|LEVEL1, "connection \"%s\" added", msg->add_conn.name);
}
/**
+2 -2
View File
@@ -144,7 +144,7 @@ static void process_jobs(private_thread_pool_t *this)
/* cancellation disabled by default */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
this->worker_logger->log(this->worker_logger, CONTROL, "Worker thread running, thread_id: %u", (int)pthread_self());
this->worker_logger->log(this->worker_logger, CONTROL, "worker thread running, thread_ID: %06d", (int)pthread_self());
for (;;) {
@@ -600,7 +600,7 @@ thread_pool_t *thread_pool_create(size_t pool_size)
{
if (pthread_create(&(this->threads[current]), NULL, (void*(*)(void*))this->process_jobs, this) == 0)
{
this->pool_logger->log(this->pool_logger, CONTROL, "Created worker thread #%d", current+1);
this->pool_logger->log(this->pool_logger, CONTROL, "created worker thread #%d", current+1);
}
else
{