removed send_queue, handled internally in sender_t know

do header parsing in receiver, ready for cookie integration
This commit is contained in:
Martin Willi
2007-03-28 13:34:02 +00:00
parent 077a6fff95
commit 4deb89485c
20 changed files with 419 additions and 653 deletions
@@ -100,7 +100,6 @@ static status_t build(private_eap_authenticator_t *this, chunk_t ike_sa_init,
{
chunk_t auth_data;
identification_t *my_id = this->ike_sa->get_my_id(this->ike_sa);
prf_t *prf = this->ike_sa->get_auth_build(this->ike_sa);
DBG1(DBG_IKE, "authentication of '%D' (myself) with %N",
my_id, auth_method_names, AUTH_EAP);
+2 -2
View File
@@ -422,7 +422,7 @@ static void send_keepalive(private_ike_sa_t *this)
data.ptr[0] = 0xFF;
data.len = 1;
packet->set_data(packet, data);
charon->send_queue->add(charon->send_queue, packet);
charon->sender->send(charon->sender, packet);
DBG1(DBG_IKE, "sending keep alive");
diff = 0;
}
@@ -625,7 +625,7 @@ static void send_notify_response(private_ike_sa_t *this, message_t *request,
}
if (generate_message(this, response, &packet) == SUCCESS)
{
charon->send_queue->add(charon->send_queue, packet);
charon->sender->send(charon->sender, packet);
}
response->destroy(response);
}
+39
View File
@@ -729,6 +729,44 @@ static status_t checkin_and_destroy(private_ike_sa_manager_t *this, ike_sa_t *ik
return retval;
}
/**
* Implementation of ike_sa_manager_t.get_half_open_count.
*/
static int get_half_open_count(private_ike_sa_manager_t *this, host_t *ip)
{
iterator_t *iterator;
entry_t *entry;
int count = 0;
pthread_mutex_lock(&(this->mutex));
iterator = this->ike_sa_list->create_iterator(this->ike_sa_list, TRUE);
while (iterator->iterate(iterator, (void**)&entry))
{
/* we check if we have a responder CONNECTING IKE_SA without checkout */
if (!entry->ike_sa_id->is_initiator(entry->ike_sa_id) &&
entry->ike_sa->get_state(entry->ike_sa) == IKE_CONNECTING)
{
/* if we have a host, we have wait until no other uses the IKE_SA */
if (ip)
{
if (wait_for_entry(this, entry) && ip->ip_equals(ip,
entry->ike_sa->get_other_host(entry->ike_sa)))
{
count++;
}
}
else
{
count++;
}
}
}
iterator->destroy(iterator);
pthread_mutex_unlock(&(this->mutex));
return count;
}
/**
* Implementation of ike_sa_manager_t.destroy.
*/
@@ -798,6 +836,7 @@ ike_sa_manager_t *ike_sa_manager_create()
this->public.create_iterator = (iterator_t*(*)(ike_sa_manager_t*))create_iterator;
this->public.checkin = (status_t(*)(ike_sa_manager_t*,ike_sa_t*))checkin;
this->public.checkin_and_destroy = (status_t(*)(ike_sa_manager_t*,ike_sa_t*))checkin_and_destroy;
this->public.get_half_open_count = (int(*)(ike_sa_manager_t*,host_t*))get_half_open_count;
/* initialize private variables */
this->ike_sa_list = linked_list_create();
+16
View File
@@ -166,6 +166,22 @@ struct ike_sa_manager_t {
*/
status_t (*checkin_and_destroy) (ike_sa_manager_t* this, ike_sa_t *ike_sa);
/**
* @brief Get the number of IKE_SAs which are in the connecting state.
*
* To prevent the server from resource exhaustion, cookies and other
* mechanisms are used. The number of half open IKE_SAs is a good
* indicator to see if a peer is flooding the server.
* If a host is supplied, only the number of half open IKE_SAs initiated
* from this IP are counted.
* Only SAs for which we are the responder are counted.
*
* @param this the manager object
* @param ip NULL for all, IP for half open IKE_SAs with IP
* @return number of half open IKE_SAs
*/
int (*get_half_open_count) (ike_sa_manager_t *this, host_t *ip);
/**
* @brief Destroys the manager with all associated SAs.
*
+5 -6
View File
@@ -226,7 +226,7 @@ static status_t retransmit(private_task_manager_t *this, u_int32_t message_id)
}
this->initiating.retransmitted++;
charon->send_queue->add(charon->send_queue,
charon->sender->send(charon->sender,
this->initiating.packet->clone(this->initiating.packet));
job = (job_t*)retransmit_job_create(this->initiating.mid,
this->ike_sa->get_id(this->ike_sa));
@@ -541,8 +541,8 @@ static status_t build_response(private_task_manager_t *this,
return DESTROY_ME;
}
charon->send_queue->add(charon->send_queue,
this->responding.packet->clone(this->responding.packet));
charon->sender->send(charon->sender,
this->responding.packet->clone(this->responding.packet));
if (delete)
{
return DESTROY_ME;
@@ -711,9 +711,8 @@ static status_t process_message(private_task_manager_t *this, message_t *msg)
{
DBG1(DBG_IKE, "received retransmit of request with ID %d, "
"retransmitting response", mid);
charon->send_queue->add(charon->send_queue,
this->responding.packet->clone(
this->responding.packet));
charon->sender->send(charon->sender,
this->responding.packet->clone(this->responding.packet));
}
else
{