child-cfg: Use struct to pass data to constructor
This commit is contained in:
committed by
Andreas Steffen
parent
fd8f1194f3
commit
8a00a8452d
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 Tobias Brunner
|
||||
* Copyright (C) 2008-2016 Tobias Brunner
|
||||
* Copyright (C) 2005-2007 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -512,13 +512,6 @@ METHOD(child_cfg_t, set_replay_window, void,
|
||||
this->replay_window = replay_window;
|
||||
}
|
||||
|
||||
METHOD(child_cfg_t, set_mipv6_options, void,
|
||||
private_child_cfg_t *this, bool proxy_mode, bool install_policy)
|
||||
{
|
||||
this->proxy_mode = proxy_mode;
|
||||
this->install_policy = install_policy;
|
||||
}
|
||||
|
||||
METHOD(child_cfg_t, use_proxy_mode, bool,
|
||||
private_child_cfg_t *this)
|
||||
{
|
||||
@@ -609,12 +602,7 @@ METHOD(child_cfg_t, destroy, void,
|
||||
/*
|
||||
* Described in header-file
|
||||
*/
|
||||
child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
|
||||
char *updown, bool hostaccess,
|
||||
ipsec_mode_t mode, action_t start_action,
|
||||
action_t dpd_action, action_t close_action,
|
||||
bool ipcomp, uint32_t inactivity, uint32_t reqid,
|
||||
mark_t *mark_in, mark_t *mark_out, uint32_t tfc)
|
||||
child_cfg_t *child_cfg_create(char *name, child_cfg_create_t *data)
|
||||
{
|
||||
private_child_cfg_t *this;
|
||||
|
||||
@@ -634,7 +622,6 @@ child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
|
||||
.get_close_action = _get_close_action,
|
||||
.get_lifetime = _get_lifetime,
|
||||
.get_dh_group = _get_dh_group,
|
||||
.set_mipv6_options = _set_mipv6_options,
|
||||
.use_ipcomp = _use_ipcomp,
|
||||
.get_inactivity = _get_inactivity,
|
||||
.get_reqid = _get_reqid,
|
||||
@@ -649,35 +636,28 @@ child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.name = strdup(name),
|
||||
.updown = strdupnull(updown),
|
||||
.hostaccess = hostaccess,
|
||||
.mode = mode,
|
||||
.start_action = start_action,
|
||||
.dpd_action = dpd_action,
|
||||
.close_action = close_action,
|
||||
.use_ipcomp = ipcomp,
|
||||
.inactivity = inactivity,
|
||||
.reqid = reqid,
|
||||
.proxy_mode = FALSE,
|
||||
.install_policy = TRUE,
|
||||
.updown = strdupnull(data->updown),
|
||||
.hostaccess = data->hostaccess,
|
||||
.reqid = data->reqid,
|
||||
.mode = data->mode,
|
||||
.proxy_mode = data->proxy_mode,
|
||||
.start_action = data->start_action,
|
||||
.dpd_action = data->dpd_action,
|
||||
.close_action = data->close_action,
|
||||
.mark_in = data->mark_in,
|
||||
.mark_out = data->mark_out,
|
||||
.lifetime = data->lifetime,
|
||||
.inactivity = data->inactivity,
|
||||
.use_ipcomp = data->ipcomp,
|
||||
.tfc = data->tfc,
|
||||
.install_policy = !data->suppress_policies,
|
||||
.refcount = 1,
|
||||
.proposals = linked_list_create(),
|
||||
.my_ts = linked_list_create(),
|
||||
.other_ts = linked_list_create(),
|
||||
.tfc = tfc,
|
||||
.replay_window = lib->settings->get_int(lib->settings,
|
||||
"%s.replay_window", DEFAULT_REPLAY_WINDOW, lib->ns),
|
||||
"%s.replay_window", DEFAULT_REPLAY_WINDOW, lib->ns),
|
||||
);
|
||||
|
||||
if (mark_in)
|
||||
{
|
||||
this->mark_in = *mark_in;
|
||||
}
|
||||
if (mark_out)
|
||||
{
|
||||
this->mark_out = *mark_out;
|
||||
}
|
||||
memcpy(&this->lifetime, lifetime, sizeof(lifetime_cfg_t));
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 Tobias Brunner
|
||||
* Copyright (C) 2008-2016 Tobias Brunner
|
||||
* Copyright (C) 2005-2007 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
typedef enum action_t action_t;
|
||||
typedef struct child_cfg_t child_cfg_t;
|
||||
typedef struct child_cfg_create_t child_cfg_create_t;
|
||||
|
||||
#include <library.h>
|
||||
#include <selectors/traffic_selector.h>
|
||||
@@ -248,15 +249,6 @@ struct child_cfg_t {
|
||||
*/
|
||||
void (*set_replay_window)(child_cfg_t *this, uint32_t window);
|
||||
|
||||
/**
|
||||
* Sets two options needed for Mobile IPv6 interoperability.
|
||||
*
|
||||
* @param proxy_mode use IPsec transport proxy mode (default FALSE)
|
||||
* @param install_policy install IPsec kernel policies (default TRUE)
|
||||
*/
|
||||
void (*set_mipv6_options)(child_cfg_t *this, bool proxy_mode,
|
||||
bool install_policy);
|
||||
|
||||
/**
|
||||
* Check whether IPsec transport SA should be set up in proxy mode.
|
||||
*
|
||||
@@ -297,38 +289,52 @@ struct child_cfg_t {
|
||||
void (*destroy) (child_cfg_t *this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Data passed to the constructor of a child_cfg_t object.
|
||||
*/
|
||||
struct child_cfg_create_t {
|
||||
/** Specific reqid to use for CHILD_SA, 0 for auto assignment */
|
||||
uint32_t reqid;
|
||||
/** Optional inbound mark */
|
||||
mark_t mark_in;
|
||||
/** Optional outbound mark */
|
||||
mark_t mark_out;
|
||||
/** Mode to propose for CHILD_SA */
|
||||
ipsec_mode_t mode;
|
||||
/** Use IPsec transport proxy mode */
|
||||
bool proxy_mode;
|
||||
/** Use IPComp, if peer supports it */
|
||||
bool ipcomp;
|
||||
/** TFC padding size, 0 to disable, -1 to pad to PMTU */
|
||||
uint32_t tfc;
|
||||
/** lifetime_cfg_t for this child_cfg */
|
||||
lifetime_cfg_t lifetime;
|
||||
/** Inactivity timeout in s before closing a CHILD_SA */
|
||||
uint32_t inactivity;
|
||||
/** Start action */
|
||||
action_t start_action;
|
||||
/** DPD action */
|
||||
action_t dpd_action;
|
||||
/** Close action */
|
||||
action_t close_action;
|
||||
/** updown script to execute on up/down event (cloned) */
|
||||
char *updown;
|
||||
/** TRUE to allow access to the local host */
|
||||
bool hostaccess;
|
||||
/** Don't install IPsec policies */
|
||||
bool suppress_policies;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a configuration template for CHILD_SA setup.
|
||||
*
|
||||
* The "name" string gets cloned.
|
||||
*
|
||||
* The lifetime_cfg_t object gets cloned.
|
||||
* To prevent two peers to start rekeying at the same time, a jitter may be
|
||||
* specified. Rekeying of an SA starts at (x.rekey - random(0, x.jitter)).
|
||||
*
|
||||
* After a call to create, a reference is obtained (refcount = 1).
|
||||
*
|
||||
* @param name name of the child_cfg
|
||||
* @param lifetime lifetime_cfg_t for this child_cfg
|
||||
* @param updown updown script to execute on up/down event
|
||||
* @param hostaccess TRUE to allow access to the local host
|
||||
* @param mode mode to propose for CHILD_SA, transport, tunnel or BEET
|
||||
* @param start_action start action
|
||||
* @param dpd_action DPD action
|
||||
* @param close_action close action
|
||||
* @param ipcomp use IPComp, if peer supports it
|
||||
* @param inactivity inactivity timeout in s before closing a CHILD_SA
|
||||
* @param reqid specific reqid to use for CHILD_SA, 0 for auto assign
|
||||
* @param mark_in optional inbound mark (can be NULL)
|
||||
* @param mark_out optional outbound mark (can be NULL)
|
||||
* @param tfc TFC padding size, 0 to disable, -1 to pad to PMTU
|
||||
* @param name name of the child_cfg (cloned)
|
||||
* @param data data for this child_cfg
|
||||
* @return child_cfg_t object
|
||||
*/
|
||||
child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
|
||||
char *updown, bool hostaccess,
|
||||
ipsec_mode_t mode, action_t start_action,
|
||||
action_t dpd_action, action_t close_action,
|
||||
bool ipcomp, uint32_t inactivity, uint32_t reqid,
|
||||
mark_t *mark_in, mark_t *mark_out, uint32_t tfc);
|
||||
child_cfg_t *child_cfg_create(char *name, child_cfg_create_t *data);
|
||||
|
||||
#endif /** CHILD_CFG_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user