842 lines
27 KiB
C
842 lines
27 KiB
C
/*
|
|
******************************************************************************
|
|
* SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipike_configuration_api.c,v $ $Revision: 1.21.16.5 $
|
|
* $Source: /home/interpeak/CVSRoot/ipike/src/ipike_configuration_api.c,v $
|
|
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:26 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipike_config.h"
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipike_h.h"
|
|
#include "ipike_configuration.h"
|
|
#include "ipike_configuration_api.h"
|
|
#include "ipike_configuration_file.h"
|
|
#include "ipike_util.h"
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
typedef struct Ipike_config_api_ike_struct
|
|
{
|
|
Ipike_config_ike conf;
|
|
Ip_bool validated;
|
|
Ip_bool no_free_config;
|
|
}
|
|
Ipike_config_api_ike;
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 LOCAL PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 8 DATA
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 LOCAL FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 PUBLIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_new
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void *
|
|
ipike_config_api_new(Ip_bool load_current)
|
|
{
|
|
Ipike_config_api_ike *ctx;
|
|
Ip_size_t buf_len = 0;
|
|
|
|
IPIKE_CODE_LOCK();
|
|
|
|
ctx = (Ipike_config_api_ike*)ipcom_calloc(1, sizeof(*ctx));
|
|
if (ctx != IP_NULL && load_current)
|
|
{
|
|
if (ipike_config_file_export_content(&ipike.config, IP_NULL, &buf_len) == IPIKE_SUCCESS && buf_len != 0)
|
|
{
|
|
char *buf;
|
|
|
|
buf = ipcom_calloc(1, buf_len);
|
|
if (buf == IP_NULL
|
|
|| ipike_config_file_export_content(&ipike.config, buf, &buf_len) != IPIKE_SUCCESS
|
|
|| ipike_config_file_import_content(&ctx->conf, buf, buf_len) != IPIKE_SUCCESS)
|
|
{
|
|
ipcom_free(ctx);
|
|
ctx = IP_NULL;
|
|
}
|
|
else
|
|
{
|
|
/* Reset updated status for initial SAs */
|
|
int i;
|
|
|
|
if (ctx->conf.ike_sa != IP_NULL)
|
|
for (i = 0; ctx->conf.ike_sa[i] != IP_NULL; i++)
|
|
ctx->conf.ike_sa[i]->updated = IP_FALSE;
|
|
if (ctx->conf.ipsec_sa != IP_NULL)
|
|
for (i = 0; ctx->conf.ipsec_sa[i] != IP_NULL; i++)
|
|
ctx->conf.ipsec_sa[i]->updated = IP_FALSE;
|
|
}
|
|
ipcom_free(buf);
|
|
}
|
|
}
|
|
|
|
IPIKE_CODE_UNLOCK();
|
|
|
|
return ctx;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_free
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void
|
|
ipike_config_api_free(void* p)
|
|
{
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL != ctx)
|
|
{
|
|
if (!ctx->no_free_config)
|
|
ipike_config_free(&ctx->conf);
|
|
ipcom_free(ctx);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_import
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_import(void* p, const char* buf, Ip_size_t buf_len)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_set(&ctx->conf, buf, buf_len)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_import - Failed to set");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_export
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_export(void* p, char* buf, Ip_size_t* buf_len)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_get(&ctx->conf, buf, buf_len)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_export - Failed to get");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_validate
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_validate(void* p)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_validate(&ctx->conf)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_validate - Failed");
|
|
}
|
|
else
|
|
{
|
|
ctx->validated = IP_TRUE;
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_commit
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_commit(void* p)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
/* Make sure we have the IKE daemon up and running */
|
|
if ( ipcom_atomic_get(&ipike.initialized) == 0 )
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_commit - IKE daemon is not running");
|
|
return IPIKE_FAILED;
|
|
}
|
|
|
|
IPIKE_CODE_LOCK();
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else
|
|
{
|
|
if (!ctx->validated
|
|
&& (IPIKE_SUCCESS != (err = ipike_config_api_validate(ctx))))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_commit - Failed to validate");
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_commit(&ctx->conf)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_commit - Failed");
|
|
}
|
|
else
|
|
{
|
|
IPCOM_LOG0(INFO, "Configuration successfully committed");
|
|
}
|
|
}
|
|
IPIKE_CODE_UNLOCK();
|
|
|
|
|
|
if (IPIKE_SUCCESS == err && ipike.disp.initialized)
|
|
{
|
|
/* Reconfigure the dispatcher */
|
|
ipike_dispatcher_reconfigure();
|
|
|
|
/* Initiate eventual new exchanges (if running) */
|
|
(void)ipike_dispatch_start_sa_negotiation(IP_NULL);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_general
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_set_general(void* p, Ipike_config_api_general* general)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_set_general(&ctx->conf.general,
|
|
general)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_set_general - Failed to set");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_ike_sa
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_set_ike_sa(
|
|
void* p,
|
|
const char ike_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
Ipike_config_api_ike_sa* ike)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IP_NULL == ike)
|
|
{
|
|
ipike_config_remove_ike_sa(&ctx->conf, ike_id);
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_set_ike_sa(&ctx->conf.ike_sa,
|
|
ike_id,
|
|
ike)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_set_ike_sa - Failed to set");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_ipsec_sa
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_set_ipsec_sa(
|
|
void* p,
|
|
const char ipsec_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
Ipike_config_api_ipsec_sa* ipsec)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IP_NULL == ipsec)
|
|
{
|
|
ipike_config_remove_ipsec_sa(&ctx->conf, ipsec_id);
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_set_ipsec_sa(&ctx->conf.ipsec_sa,
|
|
ipsec_id,
|
|
ipsec)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_set_ike_sa - Failed to set");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_ike_sa_proposal
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_set_ike_sa_proposal(
|
|
void* p,
|
|
const char ike_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
int* proposal_id,
|
|
Ipike_config_api_proposal* proposal)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_set_ike_sa_proposal(&ctx->conf.ike_sa,
|
|
ike_id,
|
|
proposal_id,
|
|
proposal)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_set_ike_sa_proposal - Failed to set");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_ipsec_sa_proposal
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_set_ipsec_sa_proposal(
|
|
void* p,
|
|
const char ipsec_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
int* proposal_id,
|
|
Ipike_config_api_proposal* proposal)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_set_ipsec_sa_proposal(&ctx->conf.ipsec_sa,
|
|
ipsec_id,
|
|
proposal_id,
|
|
proposal)))
|
|
{
|
|
IPCOM_LOG0(ERR, "ipike_config_api_set_ipsec_sa_proposal - Failed to set");
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_ipsec_sa_rohc
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_set_ipsec_sa_rohc(
|
|
void* p,
|
|
const char ipsec_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
Ipike_config_api_rohc * rohc)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
#ifdef IPIKE_USE_ROHC
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
return IPIKE_FAILED; /* Should never happen */
|
|
|
|
err = ipike_config_set_ipsec_sa_rohc(&ctx->conf.ipsec_sa,
|
|
ipsec_id,
|
|
rohc);
|
|
|
|
if (err != IPIKE_SUCCESS)
|
|
IPCOM_LOG0(ERR, "ipike_config_api_set_ipsec_sa_rohc() :: failed to set");
|
|
#else
|
|
IPCOM_UNUSED_ARG(p);
|
|
IPCOM_UNUSED_ARG(ipsec_id);
|
|
IPCOM_UNUSED_ARG(rohc);
|
|
|
|
IPCOM_LOG0(WARNING, "ipike_config_api_set_ipsec_sa_rohc() :: ROHC not enabled");
|
|
#endif
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_get_general
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_get_general(void* p, Ipike_config_api_general* general)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
ipcom_memset(general, 0, sizeof(*general));
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_get_general(&ctx->conf.general,
|
|
general)))
|
|
{
|
|
ipike_config_api_release_general(general);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_get_next_ike_sa
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_get_next_ike_sa(
|
|
void* p,
|
|
char ike_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
Ipike_config_api_ike_sa* ike,
|
|
int* pos)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
ipcom_memset(ike, 0, sizeof(*ike));
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_get_next_ike_sa(ctx->conf.general.def_ike_sa,
|
|
ctx->conf.ike_sa,
|
|
ike_id,
|
|
ike,
|
|
pos)))
|
|
{
|
|
ipike_config_api_release_ike_sa(ike);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_get_next_ipsec_sa
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_get_next_ipsec_sa(
|
|
void* p,
|
|
char ipsec_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
Ipike_config_api_ipsec_sa* ipsec,
|
|
int* pos)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
ipcom_memset(ipsec, 0, sizeof(*ipsec));
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_get_next_ipsec_sa(ctx->conf.general.def_ipsec_sa,
|
|
ctx->conf.ipsec_sa,
|
|
ipsec_id,
|
|
ipsec,
|
|
pos)))
|
|
{
|
|
ipike_config_api_release_ipsec_sa(ipsec);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_get_next_ike_sa_proposal
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_get_next_ike_sa_proposal(
|
|
void* p,
|
|
const char ike_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
int* proposal_id,
|
|
Ipike_config_api_proposal* proposal,
|
|
int* pos)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
ipcom_memset(proposal, 0, sizeof(*proposal));
|
|
if (IP_NULL == ctx)
|
|
{
|
|
err = IPIKE_FAILED; /* Should never happen */
|
|
}
|
|
else if (IPIKE_SUCCESS != (err = ipike_config_get_next_ike_sa_proposal(ctx->conf.general.def_ike_sa,
|
|
ctx->conf.ike_sa,
|
|
ike_id,
|
|
proposal_id,
|
|
proposal,
|
|
pos)))
|
|
{
|
|
ipike_config_api_release_proposal(proposal);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_get_next_ipsec_sa_proposal
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_get_next_ipsec_sa_proposal(
|
|
void* p,
|
|
const char ipsec_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
int* proposal_id,
|
|
Ipike_config_api_proposal* proposal,
|
|
int* pos)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
ipcom_memset(proposal, 0, sizeof(*proposal));
|
|
if (IP_NULL == ctx)
|
|
{
|
|
/* Should never happen */
|
|
return IPIKE_FAILED;
|
|
}
|
|
|
|
err = ipike_config_get_next_ipsec_sa_proposal(ctx->conf.general.def_ipsec_sa,
|
|
ctx->conf.ipsec_sa,
|
|
ipsec_id,
|
|
proposal_id,
|
|
proposal,
|
|
pos);
|
|
|
|
if (IPIKE_SUCCESS != err)
|
|
ipike_config_api_release_proposal(proposal);
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_set_ipsec_sa_rohc
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC Ipike_error
|
|
ipike_config_api_get_ipsec_sa_rohc(
|
|
void* p,
|
|
const char ipsec_id[IPIKE_CONFIG_MAX_ID_LEN],
|
|
Ipike_config_api_rohc * rohc)
|
|
{
|
|
Ipike_error err = IPIKE_SUCCESS;
|
|
#ifdef IPIKE_USE_ROHC
|
|
Ipike_config_api_ike* ctx = (Ipike_config_api_ike*)p;
|
|
|
|
if (IP_NULL == ctx)
|
|
return IPIKE_FAILED; /* Should never happen */
|
|
|
|
err = ipike_config_get_ipsec_sa_rohc(ctx->conf.general.def_ipsec_sa,
|
|
&ctx->conf.ipsec_sa,
|
|
ipsec_id,
|
|
rohc);
|
|
|
|
if (err != IPIKE_SUCCESS)
|
|
ipike_config_api_release_rohc(rohc);
|
|
|
|
#else
|
|
IPCOM_UNUSED_ARG(p);
|
|
IPCOM_UNUSED_ARG(ipsec_id);
|
|
IPCOM_UNUSED_ARG(rohc);
|
|
|
|
IPCOM_LOG0(WARNING, "ipike_config_api_get_ipsec_sa_rohc() :: ROHC not enabled");
|
|
#endif
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_release_general
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void
|
|
ipike_config_api_release_general(Ipike_config_api_general *general)
|
|
{
|
|
if (IP_NULL != general)
|
|
{
|
|
ipike_parse_delete_string(general->listen);
|
|
ipcom_memset(general, 0, sizeof(*general));
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_release_ike_sa
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void
|
|
ipike_config_api_release_ike_sa(Ipike_config_api_ike_sa *sa)
|
|
{
|
|
if (sa == IP_NULL)
|
|
return;
|
|
|
|
ipike_parse_delete_string(sa->version);
|
|
ipike_parse_delete_string(sa->mode);
|
|
ipike_parse_delete_string(sa->local_address);
|
|
ipike_parse_delete_string(sa->remote_address);
|
|
ipike_parse_delete_string(sa->local_id);
|
|
ipike_parse_delete_string(sa->remote_id);
|
|
ipike_parse_delete_string(sa->lifetime);
|
|
|
|
ipike_parse_delete_string(sa->authentication.method);
|
|
ipike_parse_delete_string(sa->authentication.psk_id);
|
|
ipike_parse_delete_string(sa->authentication.shared_key);
|
|
ipike_parse_delete_string(sa->authentication.certificate);
|
|
ipike_parse_delete_string(sa->authentication.certificate_uri);
|
|
ipike_parse_delete_string(sa->authentication.send_certificate);
|
|
ipike_parse_delete_string(sa->authentication.request_certificate);
|
|
ipike_parse_delete_string(sa->authentication.ocsp_response);
|
|
ipike_parse_delete_string(sa->authentication.remote_certificate);
|
|
ipike_parse_delete_string(sa->authentication.key_id);
|
|
ipike_parse_delete_string(sa->authentication.private_key);
|
|
ipike_parse_delete_string(sa->authentication.private_key_password);
|
|
ipike_parse_delete_string(sa->authentication.trusted_ca_store);
|
|
ipike_parse_delete_string(sa->authentication.crl_store);
|
|
ipike_parse_delete_string(sa->authentication.intermediate_ca_store);
|
|
ipike_parse_delete_string(sa->authentication.identity);
|
|
|
|
ipike_parse_delete_string(sa->radius.shared_secret);
|
|
ipike_parse_delete_string(sa->radius.server_address);
|
|
ipike_parse_delete_string(sa->radius.local_address);
|
|
|
|
ipcom_memset(sa, 0, sizeof(*sa));
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_release_ipsec_sa
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void
|
|
ipike_config_api_release_ipsec_sa(Ipike_config_api_ipsec_sa *sa)
|
|
{
|
|
if (sa == IP_NULL)
|
|
return;
|
|
|
|
ipike_parse_delete_string(sa->ike_id);
|
|
ipike_parse_delete_string(sa->encap_mode);
|
|
ipike_parse_delete_string(sa->use_tfc);
|
|
ipike_parse_delete_string(sa->lifetime);
|
|
ipike_parse_delete_string(sa->flowtype);
|
|
ipike_parse_delete_string(sa->granularity);
|
|
|
|
ipike_parse_delete_string(sa->dynamic_address);
|
|
|
|
ipike_parse_delete_string(sa->flow.src_address);
|
|
ipike_parse_delete_string(sa->flow.src_port);
|
|
ipike_parse_delete_string(sa->flow.dst_address);
|
|
ipike_parse_delete_string(sa->flow.dst_port);
|
|
ipike_parse_delete_string(sa->flow.protocol);
|
|
|
|
ipike_parse_delete_string(sa->flow_end.src_address);
|
|
ipike_parse_delete_string(sa->flow_end.src_port);
|
|
ipike_parse_delete_string(sa->flow_end.dst_address);
|
|
ipike_parse_delete_string(sa->flow_end.dst_port);
|
|
ipike_parse_delete_string(sa->flow_end.protocol);
|
|
|
|
ipcom_memset(sa, 0, sizeof(*sa));
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_release_proposal
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void
|
|
ipike_config_api_release_proposal(Ipike_config_api_proposal *proposal)
|
|
{
|
|
if (proposal == IP_NULL)
|
|
return;
|
|
|
|
ipike_parse_delete_string(proposal->dh_group);
|
|
ipike_parse_delete_string(proposal->encryption_alg);
|
|
ipike_parse_delete_string(proposal->hash_alg);
|
|
ipike_parse_delete_string(proposal->integrity_alg);
|
|
ipike_parse_delete_string(proposal->use_esn);
|
|
ipike_parse_delete_string(proposal->number);
|
|
ipike_parse_delete_string(proposal->v1.lifetime);
|
|
|
|
ipcom_memset(proposal, 0, sizeof(*proposal));
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_release_rohc
|
|
*===========================================================================
|
|
*/
|
|
IP_PUBLIC void
|
|
ipike_config_api_release_rohc(Ipike_config_api_rohc *rohc)
|
|
{
|
|
if (rohc == IP_NULL)
|
|
return;
|
|
|
|
ipike_parse_delete_string(rohc->max_cid);
|
|
ipike_parse_delete_string(rohc->mrru);
|
|
ipike_parse_delete_string(rohc->profiles);
|
|
ipike_parse_delete_string(rohc->integrity_alg);
|
|
ipike_parse_delete_string(rohc->icv_len);
|
|
|
|
ipcom_memset(rohc, 0, sizeof(Ipike_config_api_rohc));
|
|
}
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipike_config_api_from_config
|
|
*===========================================================================
|
|
*/
|
|
IP_GLOBAL void *
|
|
ipike_config_api_from_config(void* conf)
|
|
{
|
|
Ipike_config_ike *config = (Ipike_config_ike*)conf;
|
|
Ipike_config_api_ike *ctx;
|
|
|
|
ctx = ipcom_calloc(1, sizeof(*ctx));
|
|
if (IP_NULL != ctx)
|
|
{
|
|
ipcom_memcpy((void*)&ctx->conf, (void*)config, sizeof(*config));
|
|
ctx->no_free_config = IP_TRUE;
|
|
}
|
|
|
|
return ctx;
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|