- changed interface of ike_sa
- states can access ike_sa fields now just with functions
This commit is contained in:
@@ -47,9 +47,8 @@ struct private_ike_auth_requested_t {
|
||||
/**
|
||||
* Implements state_t.get_state
|
||||
*/
|
||||
static status_t process_message(private_ike_auth_requested_t *this, message_t *message, state_t **new_state)
|
||||
static status_t process_message(private_ike_auth_requested_t *this, message_t *message)
|
||||
{
|
||||
*new_state = (state_t *) this;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -83,7 +82,7 @@ ike_auth_requested_t *ike_auth_requested_create(protected_ike_sa_t *ike_sa)
|
||||
}
|
||||
|
||||
/* interface functions */
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
|
||||
this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
|
||||
this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
|
||||
|
||||
|
||||
@@ -47,9 +47,8 @@ struct private_ike_sa_established_t {
|
||||
/**
|
||||
* Implements state_t.get_state
|
||||
*/
|
||||
static status_t process_message(private_ike_sa_established_t *this, message_t *message, state_t **new_state)
|
||||
static status_t process_message(private_ike_sa_established_t *this, message_t *message)
|
||||
{
|
||||
*new_state = (state_t *) this;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -83,7 +82,7 @@ ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa)
|
||||
}
|
||||
|
||||
/* interface functions */
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
|
||||
this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
|
||||
this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
|
||||
|
||||
|
||||
@@ -85,12 +85,14 @@ struct private_ike_sa_init_requested_t {
|
||||
/**
|
||||
* Implements state_t.get_state
|
||||
*/
|
||||
static status_t process_message(private_ike_sa_init_requested_t *this, message_t *message, state_t **new_state)
|
||||
static status_t process_message(private_ike_sa_init_requested_t *this, message_t *message)
|
||||
{
|
||||
status_t status;
|
||||
iterator_t *payloads;
|
||||
exchange_type_t exchange_type;
|
||||
u_int64_t responder_spi;
|
||||
status_t status;
|
||||
iterator_t *payloads;
|
||||
exchange_type_t exchange_type;
|
||||
u_int64_t responder_spi;
|
||||
ike_sa_id_t *ike_sa_id;
|
||||
|
||||
|
||||
exchange_type = message->get_exchange_type(message);
|
||||
if (exchange_type != IKE_SA_INIT)
|
||||
@@ -114,7 +116,8 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
||||
}
|
||||
|
||||
responder_spi = message->get_responder_spi(message);
|
||||
this->ike_sa->ike_sa_id->set_responder_spi(this->ike_sa->ike_sa_id,responder_spi);
|
||||
ike_sa_id = this->ike_sa->public.get_id(&(this->ike_sa->public));
|
||||
ike_sa_id->set_responder_spi(ike_sa_id,responder_spi);
|
||||
|
||||
/* iterate over incoming payloads */
|
||||
status = message->get_payload_iterator(message, &payloads);
|
||||
@@ -138,7 +141,9 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
||||
encryption_algorithm_t encryption_algorithm = ENCR_UNDEFINED;
|
||||
pseudo_random_function_t pseudo_random_function = PRF_UNDEFINED;
|
||||
integrity_algorithm_t integrity_algorithm = AUTH_UNDEFINED;
|
||||
|
||||
prf_t *prf;
|
||||
|
||||
|
||||
/* get the list of suggested proposals */
|
||||
status = sa_payload->create_proposal_substructure_iterator(sa_payload, &suggested_proposals, TRUE);
|
||||
if (status != SUCCESS)
|
||||
@@ -151,7 +156,7 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
||||
/* now let the configuration-manager return the transforms for the given proposal*/
|
||||
this->logger->log(this->logger, CONTROL | MOST, "Get transforms for suggested proposal");
|
||||
status = global_configuration_manager->get_transforms_for_host_and_proposals(global_configuration_manager,
|
||||
this->ike_sa->other.host, suggested_proposals, &encryption_algorithm,&pseudo_random_function,&integrity_algorithm);
|
||||
this->ike_sa->get_other_host(this->ike_sa), suggested_proposals, &encryption_algorithm,&pseudo_random_function,&integrity_algorithm);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR | MORE, "Suggested proposals not supported!");
|
||||
@@ -161,13 +166,14 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
||||
}
|
||||
suggested_proposals->destroy(suggested_proposals);
|
||||
|
||||
this->ike_sa->prf = prf_create(pseudo_random_function);
|
||||
if (this->ike_sa->prf == NULL)
|
||||
prf = prf_create(pseudo_random_function);
|
||||
if (prf == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR | MORE, "PRF type not supported");
|
||||
payloads->destroy(payloads);
|
||||
return FAILED;
|
||||
}
|
||||
this->ike_sa->set_prf(this->ike_sa,prf);
|
||||
|
||||
|
||||
/* ok, we have what we need for sa_payload */
|
||||
@@ -251,12 +257,10 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
* Create PRF+ object
|
||||
*
|
||||
* Create Keys for next process
|
||||
*
|
||||
* Send IKE_SA_AUTH request
|
||||
*
|
||||
* Make state change
|
||||
*
|
||||
****************************/
|
||||
|
||||
|
||||
@@ -269,7 +273,7 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
|
||||
|
||||
// response->destroy(response);
|
||||
|
||||
*new_state = (state_t *) this;
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -325,7 +329,7 @@ ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa
|
||||
}
|
||||
|
||||
/* interface functions */
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
|
||||
this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
|
||||
this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
|
||||
|
||||
@@ -335,7 +339,7 @@ ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa
|
||||
this->received_nonce.len = 0;
|
||||
this->shared_secret.ptr = NULL;
|
||||
this->shared_secret.len = 0;
|
||||
this->logger = this->ike_sa->logger;
|
||||
this->logger = this->ike_sa->get_logger(this->ike_sa);
|
||||
this->diffie_hellman = diffie_hellman;
|
||||
this->sent_nonce = sent_nonce;
|
||||
this->dh_group_priority = dh_group_priority;
|
||||
|
||||
@@ -71,9 +71,8 @@ struct private_ike_sa_init_responded_t {
|
||||
/**
|
||||
* Implements state_t.get_state
|
||||
*/
|
||||
static status_t process_message(private_ike_sa_init_responded_t *this, message_t *message, state_t **new_state)
|
||||
static status_t process_message(private_ike_sa_init_responded_t *this, message_t *message)
|
||||
{
|
||||
*new_state = (state_t *) this;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -119,13 +118,13 @@ ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa
|
||||
}
|
||||
|
||||
/* interface functions */
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
|
||||
this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
|
||||
this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
|
||||
|
||||
/* private data */
|
||||
this->ike_sa = ike_sa;
|
||||
this->logger = this->ike_sa->logger;
|
||||
this->logger = this->ike_sa->get_logger(this->ike_sa);
|
||||
this->shared_secret = shared_secret;
|
||||
this->received_nonce = received_nonce;
|
||||
this->sent_nonce = sent_nonce;
|
||||
|
||||
@@ -146,29 +146,35 @@ struct private_initiator_init_t {
|
||||
/**
|
||||
* Implements function initiator_init_t.initiate_connection.
|
||||
*/
|
||||
static status_t initiate_connection (private_initiator_init_t *this, char *name, state_t **new_state)
|
||||
static status_t initiate_connection (private_initiator_init_t *this, char *name)
|
||||
{
|
||||
iterator_t *proposal_iterator;
|
||||
ike_sa_init_requested_t *next_state;
|
||||
message_t *message;
|
||||
packet_t *packet;
|
||||
status_t status;
|
||||
host_t *my_host;
|
||||
host_t *other_host;
|
||||
randomizer_t *randomizer;
|
||||
|
||||
|
||||
this->logger->log(this->logger, CONTROL, "Initializing connection %s",name);
|
||||
|
||||
status = global_configuration_manager->get_local_host(global_configuration_manager, name, &(this->ike_sa->me.host));
|
||||
status = global_configuration_manager->get_local_host(global_configuration_manager, name, &my_host);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR | MORE, "Could not retrieve local host configuration information for %s",name);
|
||||
return INVALID_ARG;
|
||||
}
|
||||
this->ike_sa->set_my_host(this->ike_sa,my_host);
|
||||
|
||||
status = global_configuration_manager->get_remote_host(global_configuration_manager, name, &(this->ike_sa->other.host));
|
||||
status = global_configuration_manager->get_remote_host(global_configuration_manager, name, &other_host);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR | MORE, "Could not retrieve remote host configuration information for %s",name);
|
||||
return INVALID_ARG;
|
||||
}
|
||||
this->ike_sa->set_other_host(this->ike_sa,other_host);
|
||||
|
||||
status = global_configuration_manager->get_dh_group_number(global_configuration_manager, name, &(this->dh_group_number), this->dh_group_priority);
|
||||
if (status != SUCCESS)
|
||||
@@ -184,7 +190,7 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name,
|
||||
return status;
|
||||
}
|
||||
|
||||
status = global_configuration_manager->get_proposals_for_host(global_configuration_manager, this->ike_sa->other.host, proposal_iterator);
|
||||
status = global_configuration_manager->get_proposals_for_host(global_configuration_manager, this->ike_sa->get_other_host(this->ike_sa), proposal_iterator);
|
||||
/* not needed anymore */
|
||||
proposal_iterator->destroy(proposal_iterator);
|
||||
if (status != SUCCESS)
|
||||
@@ -214,7 +220,8 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name,
|
||||
}
|
||||
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "Get pseudo random bytes for nonce");
|
||||
if (this->ike_sa->randomizer->allocate_pseudo_random_bytes(this->ike_sa->randomizer, NONCE_SIZE, &(this->sent_nonce)) != SUCCESS)
|
||||
randomizer = this->ike_sa->get_randomizer(this->ike_sa);
|
||||
if (randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce)) != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "Could not create nonce!");
|
||||
return OUT_OF_RES;
|
||||
@@ -253,29 +260,27 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name,
|
||||
/* state can now be changed */
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "Create next state object");
|
||||
next_state = ike_sa_init_requested_create(this->ike_sa, this->dh_group_number, this->diffie_hellman, this->sent_nonce);
|
||||
|
||||
if (next_state == NULL)
|
||||
{
|
||||
this ->logger->log(this->logger, ERROR, "Fatal error: could not create next state object of type ike_sa_init_requested_t");
|
||||
message->destroy(message);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if ( this->ike_sa->last_requested_message != NULL)
|
||||
/* last message can now be set */
|
||||
status = this->ike_sa->set_last_requested_message(this->ike_sa, message);
|
||||
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
/* destroy message */
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "Destroy stored last requested message");
|
||||
this->ike_sa->last_requested_message->destroy(this->ike_sa->last_requested_message);
|
||||
this->logger->log(this->logger, ERROR, "Could not set last requested message");
|
||||
(next_state->state_interface).destroy(&(next_state->state_interface));
|
||||
message->destroy(message);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* message is set after state create */
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "replace last requested message with current one");
|
||||
this->ike_sa->last_requested_message = message;
|
||||
/* state can now be changed */
|
||||
this->ike_sa->set_new_state(this->ike_sa,(state_t *) next_state);
|
||||
|
||||
/* message counter can now be increased */
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "Increate message counter for outgoing messages");
|
||||
this->ike_sa->message_id_out++;
|
||||
|
||||
*new_state = (state_t *) next_state;
|
||||
/* state has NOW changed :-) */
|
||||
this ->logger->log(this->logger, CONTROL|MORE, "Changed state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,INITIATOR_INIT),mapping_find(ike_sa_state_m,IKE_SA_INIT_REQUESTED) );
|
||||
|
||||
@@ -589,12 +594,12 @@ initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa)
|
||||
}
|
||||
|
||||
/* interface functions */
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
|
||||
this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
|
||||
this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
|
||||
|
||||
/* public functions */
|
||||
this->public.initiate_connection = (status_t (*)(initiator_init_t *, char *, state_t **)) initiate_connection;
|
||||
this->public.initiate_connection = (status_t (*)(initiator_init_t *, char *)) initiate_connection;
|
||||
|
||||
/* private functions */
|
||||
this->destroy_after_state_change = destroy_after_state_change;
|
||||
@@ -606,7 +611,7 @@ initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa)
|
||||
/* private data */
|
||||
this->ike_sa = ike_sa;
|
||||
this->dh_group_priority = 1;
|
||||
this->logger = this->ike_sa->logger;
|
||||
this->logger = this->ike_sa->get_logger(this->ike_sa);
|
||||
this->proposals = linked_list_create();
|
||||
this->sent_nonce = CHUNK_INITIALIZER;
|
||||
if (this->proposals == NULL)
|
||||
|
||||
@@ -46,10 +46,9 @@ struct initiator_init_t {
|
||||
*
|
||||
* @param this calling object
|
||||
* @param name name of the configuration
|
||||
* @param new_state new state if call succeeded
|
||||
* @return TODO
|
||||
*/
|
||||
status_t (*initiate_connection) (initiator_init_t *this, char *name, state_t **new_state);
|
||||
status_t (*initiate_connection) (initiator_init_t *this, char *name);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,7 +142,7 @@ struct private_responder_init_t {
|
||||
/**
|
||||
* Implements state_t.get_state
|
||||
*/
|
||||
static status_t process_message(private_responder_init_t *this, message_t *message, state_t **new_state)
|
||||
static status_t process_message(private_responder_init_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *payloads;
|
||||
host_t *source, *destination;
|
||||
@@ -153,6 +153,9 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
chunk_t shared_secret;
|
||||
exchange_type_t exchange_type;
|
||||
ike_sa_init_responded_t *next_state;
|
||||
host_t *my_host;
|
||||
host_t *other_host;
|
||||
randomizer_t *randomizer;
|
||||
|
||||
exchange_type = message->get_exchange_type(message);
|
||||
if (exchange_type != IKE_SA_INIT)
|
||||
@@ -172,8 +175,23 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
message->get_destination(message, &destination);
|
||||
|
||||
/* we need to clone them, since we destroy the message later */
|
||||
destination->clone(destination, &(this->ike_sa->me.host));
|
||||
source->clone(source, &(this->ike_sa->other.host));
|
||||
status = destination->clone(destination, &my_host);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "Fatal error: could not clone my host informations");
|
||||
return status;
|
||||
}
|
||||
status = source->clone(source, &other_host);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "Fatal error: could not clone other host informations");
|
||||
my_host->destroy(my_host);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
this->ike_sa->set_my_host(this->ike_sa, my_host);
|
||||
this->ike_sa->set_other_host(this->ike_sa, other_host);
|
||||
|
||||
/* parse incoming message */
|
||||
status = message->parse_body(message);
|
||||
@@ -205,9 +223,10 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
{
|
||||
sa_payload_t *sa_payload = (sa_payload_t*)payload;
|
||||
iterator_t *suggested_proposals, *accepted_proposals;
|
||||
encryption_algorithm_t encryption_algorithm = ENCR_UNDEFINED;
|
||||
pseudo_random_function_t pseudo_random_function = PRF_UNDEFINED;
|
||||
integrity_algorithm_t integrity_algorithm = AUTH_UNDEFINED;
|
||||
encryption_algorithm_t encryption_algorithm = ENCR_UNDEFINED;
|
||||
pseudo_random_function_t pseudo_random_function = PRF_UNDEFINED;
|
||||
integrity_algorithm_t integrity_algorithm = AUTH_UNDEFINED;
|
||||
prf_t *prf;
|
||||
|
||||
status = this->proposals->create_iterator(this->proposals, &accepted_proposals, FALSE);
|
||||
if (status != SUCCESS)
|
||||
@@ -229,7 +248,7 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
|
||||
/* now let the configuration-manager select a subset of the proposals */
|
||||
status = global_configuration_manager->select_proposals_for_host(global_configuration_manager,
|
||||
this->ike_sa->other.host, suggested_proposals, accepted_proposals);
|
||||
this->ike_sa->get_other_host(this->ike_sa), suggested_proposals, accepted_proposals);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL | MORE, "No proposal of suggested proposals selected");
|
||||
@@ -246,7 +265,7 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
/* now let the configuration-manager return the transforms for the given proposal*/
|
||||
this->logger->log(this->logger, CONTROL | MOST, "Get transforms for accepted proposal");
|
||||
status = global_configuration_manager->get_transforms_for_host_and_proposals(global_configuration_manager,
|
||||
this->ike_sa->other.host, accepted_proposals, &encryption_algorithm,&pseudo_random_function,&integrity_algorithm);
|
||||
this->ike_sa->get_other_host(this->ike_sa), accepted_proposals, &encryption_algorithm,&pseudo_random_function,&integrity_algorithm);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR | MORE, "Accepted proposals not supported?!");
|
||||
@@ -256,13 +275,14 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
}
|
||||
accepted_proposals->destroy(accepted_proposals);
|
||||
|
||||
this->ike_sa->prf = prf_create(pseudo_random_function);
|
||||
if (this->ike_sa->prf == NULL)
|
||||
prf = prf_create(pseudo_random_function);
|
||||
if (prf == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR | MORE, "PRF type not supported");
|
||||
payloads->destroy(payloads);
|
||||
return FAILED;
|
||||
}
|
||||
this->ike_sa->set_prf(this->ike_sa,prf);
|
||||
|
||||
this->logger->log(this->logger, CONTROL | MORE, "SA Payload processed");
|
||||
/* ok, we have what we need for sa_payload (proposals are stored in this->proposals)*/
|
||||
@@ -278,7 +298,7 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
group = ke_payload->get_dh_group_number(ke_payload);
|
||||
|
||||
status = global_configuration_manager->is_dh_group_allowed_for_host(global_configuration_manager,
|
||||
this->ike_sa->other.host, group, &allowed_group);
|
||||
this->ike_sa->get_other_host(this->ike_sa), group, &allowed_group);
|
||||
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
@@ -355,8 +375,11 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
|
||||
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.");
|
||||
if (this->ike_sa->randomizer->allocate_pseudo_random_bytes(this->ike_sa->randomizer, NONCE_SIZE, &(this->sent_nonce)) != SUCCESS)
|
||||
this->logger->log(this->logger, CONTROL | MOST, "Going to create nonce.");
|
||||
|
||||
randomizer = this->ike_sa->get_randomizer(this->ike_sa);
|
||||
|
||||
if (randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce)) != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "Could not create nonce!");
|
||||
return OUT_OF_RES;
|
||||
@@ -447,6 +470,7 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "Could not add packet to send queue");
|
||||
packet->destroy(packet);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -462,19 +486,19 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if ( this->ike_sa->last_responded_message != NULL)
|
||||
/* last message can now be set */
|
||||
status = this->ike_sa->set_last_responded_message(this->ike_sa, response);
|
||||
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
/* destroy message */
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "Destroy stored last responded message");
|
||||
this->ike_sa->last_responded_message->destroy(this->ike_sa->last_responded_message);
|
||||
this->logger->log(this->logger, ERROR, "Could not set last responded message");
|
||||
response->destroy(response);
|
||||
(next_state->state_interface).destroy(&(next_state->state_interface));
|
||||
return status;
|
||||
}
|
||||
this->ike_sa->last_responded_message = response;
|
||||
|
||||
/* message counter can now be increased */
|
||||
this ->logger->log(this->logger, CONTROL|MOST, "Increate message counter for incoming messages");
|
||||
this->ike_sa->message_id_in++;
|
||||
|
||||
*new_state = (state_t *) next_state;
|
||||
/* state can now be changed */
|
||||
this->ike_sa->set_new_state(this->ike_sa, (state_t *) next_state);
|
||||
/* state has NOW changed :-) */
|
||||
this ->logger->log(this->logger, CONTROL|MORE, "Changed state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,RESPONDER_INIT),mapping_find(ike_sa_state_m,IKE_SA_INIT_RESPONDED) );
|
||||
|
||||
@@ -717,7 +741,7 @@ responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa)
|
||||
}
|
||||
|
||||
/* interface functions */
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
|
||||
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
|
||||
this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
|
||||
this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
|
||||
|
||||
@@ -729,7 +753,7 @@ responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa)
|
||||
|
||||
/* private data */
|
||||
this->ike_sa = ike_sa;
|
||||
this->logger = this->ike_sa->logger;
|
||||
this->logger = this->ike_sa->get_logger(this->ike_sa);
|
||||
this->sent_nonce.ptr = NULL;
|
||||
this->sent_nonce.len = 0;
|
||||
this->received_nonce.ptr = NULL;
|
||||
|
||||
@@ -87,13 +87,11 @@ struct state_t {
|
||||
*
|
||||
* @param this state_t object
|
||||
* @param[in] message message_t object to process
|
||||
* @param this state_t pointer to the new state_t object
|
||||
* @return
|
||||
* - SUCCESSFUL if succeeded
|
||||
* - FAILED otherwise
|
||||
*/
|
||||
status_t (*process_message) (state_t *this,message_t *message,state_t **new_state);
|
||||
|
||||
status_t (*process_message) (state_t *this,message_t *message);
|
||||
|
||||
/**
|
||||
* @brief Get the current state
|
||||
|
||||
Reference in New Issue
Block a user