better split up of library files "types.h" & "definitions.h"
centralized all printf specifier character definitions reuse of arginfo handlers more cleanups fixed more AMD64 issues added DEBUG_LEVEL compile flag to exclude DBGn() statements
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
typedef enum auth_method_t auth_method_t;
|
||||
typedef struct authenticator_t authenticator_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <sa/ike_sa.h>
|
||||
#include <encoding/payloads/auth_payload.h>
|
||||
|
||||
|
||||
@@ -856,24 +856,12 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
return written;
|
||||
}
|
||||
|
||||
/**
|
||||
* arginfo handler in printf()
|
||||
*/
|
||||
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* register printf() handlers
|
||||
*/
|
||||
static void __attribute__ ((constructor))print_register()
|
||||
{
|
||||
register_printf_function(CHILD_SA_PRINTF_SPEC, print, print_arginfo);
|
||||
register_printf_function(PRINTF_CHILD_SA, print, arginfo_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
typedef enum child_sa_state_t child_sa_state_t;
|
||||
typedef struct child_sa_t child_sa_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <crypto/prf_plus.h>
|
||||
#include <encoding/payloads/proposal_substructure.h>
|
||||
#include <config/proposal.h>
|
||||
@@ -39,11 +39,6 @@ typedef struct child_sa_t child_sa_t;
|
||||
*/
|
||||
#define REQID_START 2000000000
|
||||
|
||||
/**
|
||||
* Printf() specifier for child_sa_t
|
||||
*/
|
||||
#define CHILD_SA_PRINTF_SPEC 'P'
|
||||
|
||||
/**
|
||||
* @brief States of a CHILD_SA
|
||||
*/
|
||||
|
||||
+4
-17
@@ -28,9 +28,8 @@
|
||||
|
||||
#include "ike_sa.h"
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <daemon.h>
|
||||
#include <definitions.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/prf_plus.h>
|
||||
@@ -1897,24 +1896,12 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
this->ike_sa_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* arginfo handler in printf()
|
||||
*/
|
||||
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* register printf() handlers
|
||||
*/
|
||||
static void __attribute__ ((constructor))print_register()
|
||||
{
|
||||
register_printf_function(IKE_SA_PRINTF_SPEC, print, print_arginfo);
|
||||
register_printf_function(PRINTF_IKE_SA, print, arginfo_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2006,8 +1993,8 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
|
||||
this->child_sas = linked_list_create();
|
||||
this->my_host = host_create_from_string("0.0.0.0", 0);
|
||||
this->other_host = host_create_from_string("0.0.0.0", 0);
|
||||
this->my_id = identification_create_from_encoding(ID_ANY, CHUNK_INITIALIZER);
|
||||
this->other_id = identification_create_from_encoding(ID_ANY, CHUNK_INITIALIZER);
|
||||
this->my_id = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||
this->other_id = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||
this->crypter_in = NULL;
|
||||
this->crypter_out = NULL;
|
||||
this->signer_in = NULL;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
typedef enum ike_sa_state_t ike_sa_state_t;
|
||||
typedef struct ike_sa_t ike_sa_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <encoding/message.h>
|
||||
#include <encoding/payloads/proposal_substructure.h>
|
||||
#include <sa/ike_sa_id.h>
|
||||
@@ -43,8 +43,6 @@ typedef struct ike_sa_t ike_sa_t;
|
||||
#include <config/policies/policy.h>
|
||||
#include <config/proposal.h>
|
||||
|
||||
#define IKE_SA_PRINTF_SPEC 'K'
|
||||
|
||||
/**
|
||||
* @brief State of an IKE_SA.
|
||||
*
|
||||
|
||||
@@ -169,27 +169,14 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
this->is_initiator_flag ? 'i' : 'r');
|
||||
}
|
||||
|
||||
/**
|
||||
* arginfo handler in printf()
|
||||
*/
|
||||
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* register printf() handlers
|
||||
*/
|
||||
static void __attribute__ ((constructor))print_register()
|
||||
{
|
||||
register_printf_function(IKE_SA_ID_PRINTF_SPEC, print, print_arginfo);
|
||||
register_printf_function(PRINTF_IKE_SA_ID, print, arginfo_ptr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ike_sa_id_t.destroy.
|
||||
*/
|
||||
|
||||
@@ -27,12 +27,8 @@
|
||||
|
||||
typedef struct ike_sa_id_t ike_sa_id_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
|
||||
/**
|
||||
* printf() specifier to print a ike_sa_id.
|
||||
*/
|
||||
#define IKE_SA_ID_PRINTF_SPEC 'J'
|
||||
|
||||
/**
|
||||
* @brief An object of type ike_sa_id_t is used to identify an IKE_SA.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
typedef struct ike_sa_manager_t ike_sa_manager_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <sa/ike_sa.h>
|
||||
|
||||
/**
|
||||
|
||||
@@ -540,7 +540,7 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_REKEYING ||
|
||||
this->ike_sa->get_state(this->ike_sa) == IKE_DELETING)
|
||||
{
|
||||
build_notify(NO_ADDITIONAL_SAS, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_ADDITIONAL_SAS, chunk_empty, response, TRUE);
|
||||
DBG1(DBG_IKE, "unable to create new CHILD_SAs, as rekeying in progress");
|
||||
return FAILED;
|
||||
}
|
||||
@@ -605,7 +605,7 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
||||
/* check if we have all payloads */
|
||||
if (!(sa_request && nonce_request && tsi_request && tsr_request))
|
||||
{
|
||||
build_notify(INVALID_SYNTAX, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(INVALID_SYNTAX, chunk_empty, response, TRUE);
|
||||
SIG(this->failsig, "request message incomplete, no CHILD_SA created");
|
||||
return FAILED;
|
||||
}
|
||||
@@ -615,7 +615,7 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
||||
if (this->randomizer->allocate_pseudo_random_bytes(this->randomizer,
|
||||
NONCE_SIZE, &this->nonce_r) != SUCCESS)
|
||||
{
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
SIG(this->failsig, "nonce generation failed, no CHILD_SA created");
|
||||
return FAILED;
|
||||
}
|
||||
@@ -649,7 +649,7 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
||||
if (this->policy == NULL)
|
||||
{
|
||||
SIG(this->failsig, "no acceptable policy found, sending TS_UNACCEPTABLE notify");
|
||||
build_notify(TS_UNACCEPTABLE, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(TS_UNACCEPTABLE, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
}
|
||||
@@ -672,14 +672,14 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
||||
if (this->proposal == NULL)
|
||||
{
|
||||
SIG(this->failsig, "CHILD_SA proposals unacceptable, sending NO_PROPOSAL_CHOSEN notify");
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
/* do we have traffic selectors? */
|
||||
else if (this->tsi->get_count(this->tsi) == 0 || this->tsr->get_count(this->tsr) == 0)
|
||||
{
|
||||
SIG(this->failsig, "CHILD_SA traffic selectors unacceptable, sending TS_UNACCEPTABLE notify");
|
||||
build_notify(TS_UNACCEPTABLE, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(TS_UNACCEPTABLE, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
else
|
||||
@@ -700,7 +700,7 @@ static status_t get_response(private_create_child_sa_t *this, message_t *request
|
||||
if (install_child_sa(this, FALSE) != SUCCESS)
|
||||
{
|
||||
SIG(this->failsig, "installing CHILD_SA failed, sending NO_PROPOSAL_CHOSEN notify");
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
/* add proposal to sa payload */
|
||||
@@ -975,9 +975,9 @@ create_child_sa_t *create_child_sa_create(ike_sa_t *ike_sa)
|
||||
this->requested = 0;
|
||||
this->rekey_spi = 0;
|
||||
this->reqid = 0;
|
||||
this->nonce_i = CHUNK_INITIALIZER;
|
||||
this->nonce_r = CHUNK_INITIALIZER;
|
||||
this->nonce_s = CHUNK_INITIALIZER;
|
||||
this->nonce_i = chunk_empty;
|
||||
this->nonce_r = chunk_empty;
|
||||
this->nonce_s = chunk_empty;
|
||||
this->child_sa = NULL;
|
||||
this->rekeyed_sa = NULL;
|
||||
this->lost = FALSE;
|
||||
|
||||
@@ -685,7 +685,7 @@ static status_t get_response(private_ike_auth_t *this, message_t *request,
|
||||
}
|
||||
else
|
||||
{
|
||||
my_id = identification_create_from_encoding(ID_ANY, CHUNK_INITIALIZER);
|
||||
my_id = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1116,10 +1116,10 @@ ike_auth_t *ike_auth_create(ike_sa_t *ike_sa)
|
||||
this->message_id = 0;
|
||||
this->message = NULL;
|
||||
this->requested = 0;
|
||||
this->nonce_i = CHUNK_INITIALIZER;
|
||||
this->nonce_r = CHUNK_INITIALIZER;
|
||||
this->init_request = CHUNK_INITIALIZER;
|
||||
this->init_response = CHUNK_INITIALIZER;
|
||||
this->nonce_i = chunk_empty;
|
||||
this->nonce_r = chunk_empty;
|
||||
this->init_request = chunk_empty;
|
||||
this->init_response = chunk_empty;
|
||||
this->child_sa = NULL;
|
||||
this->proposal = NULL;
|
||||
this->tsi = NULL;
|
||||
|
||||
@@ -1099,8 +1099,8 @@ ike_sa_init_t *ike_sa_init_create(ike_sa_t *ike_sa)
|
||||
this->message = NULL;
|
||||
this->requested = 0;
|
||||
this->diffie_hellman = NULL;
|
||||
this->nonce_i = CHUNK_INITIALIZER;
|
||||
this->nonce_r = CHUNK_INITIALIZER;
|
||||
this->nonce_i = chunk_empty;
|
||||
this->nonce_r = chunk_empty;
|
||||
this->connection = NULL;
|
||||
this->policy = NULL;
|
||||
this->proposal = NULL;
|
||||
@@ -1108,8 +1108,8 @@ ike_sa_init_t *ike_sa_init_create(ike_sa_t *ike_sa)
|
||||
this->reqid = 0;
|
||||
this->randomizer = randomizer_create();
|
||||
this->nat_hasher = hasher_create(HASH_SHA1);
|
||||
this->natd_src_hash = CHUNK_INITIALIZER;
|
||||
this->natd_dst_hash = CHUNK_INITIALIZER;
|
||||
this->natd_src_hash = chunk_empty;
|
||||
this->natd_dst_hash = chunk_empty;
|
||||
this->natd_src_seen = FALSE;
|
||||
this->natd_dst_seen = FALSE;
|
||||
this->natd_src_matched = FALSE;
|
||||
|
||||
@@ -445,7 +445,7 @@ static status_t get_response(private_rekey_ike_sa_t *this, message_t *request,
|
||||
/* if we already initiate a delete, we do not allow rekeying */
|
||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_DELETING)
|
||||
{
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
DBG1(DBG_IKE, "unable to rekey, as delete in progress. Sending NO_PROPOSAL_CHOSEN");
|
||||
return FAILED;
|
||||
}
|
||||
@@ -459,7 +459,7 @@ static status_t get_response(private_rekey_ike_sa_t *this, message_t *request,
|
||||
state == CHILD_REKEYING ||
|
||||
state == CHILD_DELETING)
|
||||
{
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
DBG1(DBG_IKE, "unable to rekey, one CHILD_SA is half open. Sending NO_PROPOSAL_CHOSEN");
|
||||
iterator->destroy(iterator);
|
||||
return FAILED;
|
||||
@@ -482,7 +482,7 @@ static status_t get_response(private_rekey_ike_sa_t *this, message_t *request,
|
||||
if (this->connection == NULL)
|
||||
{
|
||||
DBG1(DBG_IKE, "no connection found to rekey IKE_SA, sending NO_RROPOSAL_CHOSEN");
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
}
|
||||
@@ -527,7 +527,7 @@ static status_t get_response(private_rekey_ike_sa_t *this, message_t *request,
|
||||
/* check if we have all payloads */
|
||||
if (!(sa_request && nonce_request && ke_request))
|
||||
{
|
||||
build_notify(INVALID_SYNTAX, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(INVALID_SYNTAX, chunk_empty, response, TRUE);
|
||||
DBG1(DBG_IKE, "request message incomplete, IKE_SA rekeying failed");
|
||||
return FAILED;
|
||||
}
|
||||
@@ -537,7 +537,7 @@ static status_t get_response(private_rekey_ike_sa_t *this, message_t *request,
|
||||
if (this->randomizer->allocate_pseudo_random_bytes(this->randomizer,
|
||||
NONCE_SIZE, &this->nonce_r) != SUCCESS)
|
||||
{
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
nonce_response = nonce_payload_create();
|
||||
@@ -561,7 +561,7 @@ static status_t get_response(private_rekey_ike_sa_t *this, message_t *request,
|
||||
if (this->proposal == NULL)
|
||||
{
|
||||
DBG1(DBG_IKE, "no proposals acceptable to rekey IKE_SA, sending NO_PROPOSAL_CHOSEN");
|
||||
build_notify(NO_PROPOSAL_CHOSEN, CHUNK_INITIALIZER, response, TRUE);
|
||||
build_notify(NO_PROPOSAL_CHOSEN, chunk_empty, response, TRUE);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
@@ -874,9 +874,9 @@ rekey_ike_sa_t *rekey_ike_sa_create(ike_sa_t *ike_sa)
|
||||
this->message_id = 0;
|
||||
this->message = NULL;
|
||||
this->requested = 0;
|
||||
this->nonce_i = CHUNK_INITIALIZER;
|
||||
this->nonce_r = CHUNK_INITIALIZER;
|
||||
this->nonce_s = CHUNK_INITIALIZER;
|
||||
this->nonce_i = chunk_empty;
|
||||
this->nonce_r = chunk_empty;
|
||||
this->nonce_s = chunk_empty;
|
||||
this->new_sa = NULL;
|
||||
this->lost = FALSE;
|
||||
this->connection = NULL;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
typedef struct transaction_t transaction_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <encoding/message.h>
|
||||
#include <sa/ike_sa.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user