- allready partly working
This commit is contained in:
@@ -52,7 +52,7 @@ static status_t get_remote_host(private_configuration_manager_t *this, char *nam
|
|||||||
/* some hard coded users for testing */
|
/* some hard coded users for testing */
|
||||||
host_t *remote;
|
host_t *remote;
|
||||||
if (strcmp(name, "pinflb30") == 0) {
|
if (strcmp(name, "pinflb30") == 0) {
|
||||||
remote = host_create(AF_INET, "152.96.193.130", 500);
|
remote = host_create(AF_INET, "152.96.193.131", 500);
|
||||||
if (remote == NULL) {
|
if (remote == NULL) {
|
||||||
return OUT_OF_RES;
|
return OUT_OF_RES;
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-20
@@ -95,6 +95,7 @@ static status_t process_message (protected_ike_sa_t *this, message_t *message)
|
|||||||
|
|
||||||
/* now the message is processed by the current state object */
|
/* now the message is processed by the current state object */
|
||||||
status = this->current_state->process_message(this->current_state,message,&new_state);
|
status = this->current_state->process_message(this->current_state,message,&new_state);
|
||||||
|
|
||||||
if (status == SUCCESS)
|
if (status == SUCCESS)
|
||||||
{
|
{
|
||||||
this->current_state = new_state;
|
this->current_state = new_state;
|
||||||
@@ -285,25 +286,27 @@ static status_t destroy (protected_ike_sa_t *this)
|
|||||||
this->logger->log(this->logger, CONTROL | MOST, "Destroy randomizer");
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy randomizer");
|
||||||
this->randomizer->destroy(this->randomizer);
|
this->randomizer->destroy(this->randomizer);
|
||||||
|
|
||||||
// if (this->me.host != NULL)
|
if (this->me.host != NULL)
|
||||||
// {
|
{
|
||||||
// this->logger->log(this->logger, CONTROL | MOST, "Destroy host informations of me");
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy host informations of me");
|
||||||
// this->me.host->destroy(this->me.host);
|
this->me.host->destroy(this->me.host);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (this->other.host != NULL)
|
if (this->other.host != NULL)
|
||||||
// {
|
{
|
||||||
// this->logger->log(this->logger, CONTROL | MOST, "Destroy host informations of other");
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy host informations of other");
|
||||||
// this->other.host->destroy(this->other.host);
|
this->other.host->destroy(this->other.host);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// this->logger->log(this->logger, CONTROL | MOST, "Destroy current state object");
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy current state object");
|
||||||
// this->current_state->destroy(this->current_state);
|
this->current_state->destroy(this->current_state);
|
||||||
//
|
|
||||||
// this->logger->log(this->logger, CONTROL | MOST, "Destroy logger of IKE_SA");
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy logger of IKE_SA");
|
||||||
// global_logger_manager->destroy_logger(global_logger_manager, this->logger);
|
|
||||||
//
|
|
||||||
// allocator_free(this);
|
global_logger_manager->destroy_logger(global_logger_manager, this->logger);
|
||||||
|
|
||||||
|
allocator_free(this);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,6 +383,16 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
|
|||||||
this->current_state = (state_t *) responder_init_create(this);
|
this->current_state = (state_t *) responder_init_create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->current_state == NULL)
|
||||||
|
{
|
||||||
|
this->logger->log(this->logger, ERROR, "Fatal error: Could not create state object");
|
||||||
|
this->child_sas->destroy(this->child_sas);
|
||||||
|
this->ike_sa_id->destroy(this->ike_sa_id);
|
||||||
|
global_logger_manager->destroy_logger(global_logger_manager,this->logger);
|
||||||
|
this->randomizer->destroy(this->randomizer);
|
||||||
|
allocator_free(this);
|
||||||
|
}
|
||||||
|
|
||||||
return (&this->public);
|
|
||||||
|
return &(this->public);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-10
@@ -458,12 +458,6 @@ static status_t generate(private_message_t *this, packet_t **packet)
|
|||||||
this->logger->log(this->logger, CONTROL, "generating message, contains %d payloads",
|
this->logger->log(this->logger, CONTROL, "generating message, contains %d payloads",
|
||||||
this->payloads->get_count(this->payloads));
|
this->payloads->get_count(this->payloads));
|
||||||
|
|
||||||
if (this->packet != NULL)
|
|
||||||
{
|
|
||||||
/* already generated packet is just cloned */
|
|
||||||
this->packet->clone(this->packet, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->exchange_type == EXCHANGE_TYPE_UNDEFINED)
|
if (this->exchange_type == EXCHANGE_TYPE_UNDEFINED)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "exchange type is not defined");
|
this->logger->log(this->logger, ERROR, "exchange type is not defined");
|
||||||
@@ -754,10 +748,8 @@ static status_t destroy (private_message_t *this)
|
|||||||
{
|
{
|
||||||
linked_list_iterator_t *iterator;
|
linked_list_iterator_t *iterator;
|
||||||
|
|
||||||
if (this->packet != NULL)
|
this->packet->destroy(this->packet);
|
||||||
{
|
|
||||||
this->packet->destroy(this->packet);
|
|
||||||
}
|
|
||||||
if (this->ike_sa_id != NULL)
|
if (this->ike_sa_id != NULL)
|
||||||
{
|
{
|
||||||
this->ike_sa_id->destroy(this->ike_sa_id);
|
this->ike_sa_id->destroy(this->ike_sa_id);
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
|||||||
|
|
||||||
this->logger->log_chunk(this->logger, RAW, "Shared secret", &shared_secret);
|
this->logger->log_chunk(this->logger, RAW, "Shared secret", &shared_secret);
|
||||||
|
|
||||||
|
allocator_free_chunk(shared_secret);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NONCE:
|
case NONCE:
|
||||||
@@ -196,14 +198,17 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
|||||||
}
|
}
|
||||||
payloads->destroy(payloads);
|
payloads->destroy(payloads);
|
||||||
|
|
||||||
/* set up the reply */
|
|
||||||
status = this->ike_sa->build_message(this->ike_sa, IKE_SA_INIT, FALSE, &response);
|
|
||||||
if (status != SUCCESS)
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
response->destroy(response);
|
/* set up the reply */
|
||||||
|
// status = this->ike_sa->build_message(this->ike_sa, IKE_SA_INIT, FALSE, &response);
|
||||||
|
// if (status != SUCCESS)
|
||||||
|
// {
|
||||||
|
// return status;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// response->destroy(response);
|
||||||
|
|
||||||
|
*new_state = this;
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -221,6 +226,19 @@ static ike_sa_state_t get_state(private_ike_sa_init_requested_t *this)
|
|||||||
*/
|
*/
|
||||||
static status_t destroy(private_ike_sa_init_requested_t *this)
|
static status_t destroy(private_ike_sa_init_requested_t *this)
|
||||||
{
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MORE, "Going to destroy state of type ike_sa_init_requested_t");
|
||||||
|
this->diffie_hellman->destroy(this->diffie_hellman);
|
||||||
|
if (this->sent_nonce.ptr != NULL)
|
||||||
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy sent nonce");
|
||||||
|
allocator_free(this->sent_nonce.ptr);
|
||||||
|
}
|
||||||
|
if (this->received_nonce.ptr != NULL)
|
||||||
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy received nonce");
|
||||||
|
allocator_free(this->received_nonce.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
allocator_free(this);
|
allocator_free(this);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ static status_t build_sa_payload(private_initiator_init_t *this, payload_t **pay
|
|||||||
if (status != SUCCESS)
|
if (status != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "Could not get current proposal needed to copy");
|
this->logger->log(this->logger, ERROR, "Could not get current proposal needed to copy");
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
sa_payload->destroy(sa_payload);
|
sa_payload->destroy(sa_payload);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -311,6 +312,7 @@ static status_t build_sa_payload(private_initiator_init_t *this, payload_t **pay
|
|||||||
if (status != SUCCESS)
|
if (status != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "Could not clone current proposal");
|
this->logger->log(this->logger, ERROR, "Could not clone current proposal");
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
sa_payload->destroy(sa_payload);
|
sa_payload->destroy(sa_payload);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -319,11 +321,13 @@ static status_t build_sa_payload(private_initiator_init_t *this, payload_t **pay
|
|||||||
if (status != SUCCESS)
|
if (status != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "Could not add cloned proposal to SA payload");
|
this->logger->log(this->logger, ERROR, "Could not add cloned proposal to SA payload");
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
sa_payload->destroy(sa_payload);
|
sa_payload->destroy(sa_payload);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
|
|
||||||
this->logger->log(this->logger, CONTROL|MORE, "sa payload builded");
|
this->logger->log(this->logger, CONTROL|MORE, "sa payload builded");
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,17 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
|||||||
/* iterator can be destroyed */
|
/* iterator can be destroyed */
|
||||||
payloads->destroy(payloads);
|
payloads->destroy(payloads);
|
||||||
|
|
||||||
|
/********************/
|
||||||
|
diffie_hellman_t *dh = this->diffie_hellman;
|
||||||
|
chunk_t shared_secret;
|
||||||
|
|
||||||
|
status = dh->get_shared_secret(dh, &shared_secret);
|
||||||
|
this->logger->log_chunk(this->logger, RAW, "Shared secret", &shared_secret);
|
||||||
|
|
||||||
|
allocator_free_chunk(shared_secret);
|
||||||
|
/********************/
|
||||||
|
|
||||||
|
|
||||||
this->logger->log(this->logger, CONTROL | MORE, "Request successfully handled. Going to create reply.");
|
this->logger->log(this->logger, CONTROL | MORE, "Request successfully handled. Going to create reply.");
|
||||||
|
|
||||||
this->logger->log(this->logger, CONTROL | MOST, "Going to create nonce.");
|
this->logger->log(this->logger, CONTROL | MOST, "Going to create nonce.");
|
||||||
@@ -351,6 +362,7 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
|||||||
/* state has NOW changed :-) */
|
/* state has NOW changed :-) */
|
||||||
// this ->logger->log(this->logger, CONTROL|MORE, "Change state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,this->state),mapping_find(ike_sa_state_m,IKE_SA_INIT_REQUESTED) );
|
// this ->logger->log(this->logger, CONTROL|MORE, "Change state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,this->state),mapping_find(ike_sa_state_m,IKE_SA_INIT_REQUESTED) );
|
||||||
|
|
||||||
|
*new_state = &(this->public.state_interface);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -391,6 +403,7 @@ static status_t build_sa_payload(private_responder_init_t *this, payload_t **pay
|
|||||||
if (status != SUCCESS)
|
if (status != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "Could not get current proposal needed to copy");
|
this->logger->log(this->logger, ERROR, "Could not get current proposal needed to copy");
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
sa_payload->destroy(sa_payload);
|
sa_payload->destroy(sa_payload);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -398,6 +411,7 @@ static status_t build_sa_payload(private_responder_init_t *this, payload_t **pay
|
|||||||
if (status != SUCCESS)
|
if (status != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "Could not clone current proposal");
|
this->logger->log(this->logger, ERROR, "Could not clone current proposal");
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
sa_payload->destroy(sa_payload);
|
sa_payload->destroy(sa_payload);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -406,12 +420,15 @@ static status_t build_sa_payload(private_responder_init_t *this, payload_t **pay
|
|||||||
if (status != SUCCESS)
|
if (status != SUCCESS)
|
||||||
{
|
{
|
||||||
this->logger->log(this->logger, ERROR, "Could not add cloned proposal to SA payload");
|
this->logger->log(this->logger, ERROR, "Could not add cloned proposal to SA payload");
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
sa_payload->destroy(sa_payload);
|
sa_payload->destroy(sa_payload);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proposal_iterator->destroy(proposal_iterator);
|
||||||
|
|
||||||
this->logger->log(this->logger, CONTROL|MORE, "sa payload builded");
|
this->logger->log(this->logger, CONTROL|MORE, "sa payload builded");
|
||||||
|
|
||||||
*payload = (payload_t *) sa_payload;
|
*payload = (payload_t *) sa_payload;
|
||||||
@@ -505,6 +522,8 @@ static ike_sa_state_t get_state(private_responder_init_t *this)
|
|||||||
*/
|
*/
|
||||||
static status_t destroy(private_responder_init_t *this)
|
static status_t destroy(private_responder_init_t *this)
|
||||||
{
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MORE, "Going to destroy responder init state object");
|
||||||
|
|
||||||
/* destroy stored proposal */
|
/* destroy stored proposal */
|
||||||
this->logger->log(this->logger, CONTROL | MOST, "Destroy stored proposals");
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy stored proposals");
|
||||||
while (this->proposals->get_count(this->proposals) > 0)
|
while (this->proposals->get_count(this->proposals) > 0)
|
||||||
@@ -514,8 +533,30 @@ static status_t destroy(private_responder_init_t *this)
|
|||||||
current_proposal->destroy(current_proposal);
|
current_proposal->destroy(current_proposal);
|
||||||
}
|
}
|
||||||
this->proposals->destroy(this->proposals);
|
this->proposals->destroy(this->proposals);
|
||||||
|
|
||||||
|
if (this->sent_nonce.ptr != NULL)
|
||||||
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy sent nonce");
|
||||||
|
allocator_free(this->sent_nonce.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->received_nonce.ptr != NULL)
|
||||||
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy received nonce");
|
||||||
|
allocator_free(this->received_nonce.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* destroy diffie hellman object */
|
||||||
|
if (this->diffie_hellman != NULL)
|
||||||
|
{
|
||||||
|
this->logger->log(this->logger, CONTROL | MOST, "Destroy diffie_hellman_t object");
|
||||||
|
this->diffie_hellman->destroy(this->diffie_hellman);
|
||||||
|
}
|
||||||
|
|
||||||
allocator_free(this);
|
allocator_free(this);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -143,12 +143,8 @@ static void job_processing(private_thread_pool_t *this)
|
|||||||
message->destroy(message);
|
message->destroy(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* we must switch the initiator flag when receiving a request
|
|
||||||
*/
|
ike_sa_id->switch_initiator(ike_sa_id);
|
||||||
if (message->get_request(message))
|
|
||||||
{
|
|
||||||
ike_sa_id->switch_initiator(ike_sa_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->worker_logger->log(this->worker_logger, CONTROL|MOST, "checking out IKE SA %lld:%lld, role %s",
|
this->worker_logger->log(this->worker_logger, CONTROL|MOST, "checking out IKE SA %lld:%lld, role %s",
|
||||||
ike_sa_id->get_initiator_spi(ike_sa_id),
|
ike_sa_id->get_initiator_spi(ike_sa_id),
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ static status_t destroy_logger (private_logger_manager_t *this,logger_t *logger)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
iterator->destroy(iterator);
|
||||||
|
|
||||||
pthread_mutex_unlock(&(this->mutex));
|
pthread_mutex_unlock(&(this->mutex));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user