ike-cfg: Pass arguments as struct
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2018 Tobias Brunner
|
||||
* Copyright (C) 2012-2019 Tobias Brunner
|
||||
* Copyright (C) 2005-2007 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
@@ -609,13 +609,10 @@ bool ike_cfg_has_address(ike_cfg_t *cfg, host_t *addr, bool local)
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Described in header.
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
|
||||
char *me, uint16_t my_port,
|
||||
char *other, uint16_t other_port,
|
||||
fragmentation_t fragmentation, uint8_t dscp)
|
||||
ike_cfg_t *ike_cfg_create(ike_cfg_create_t *data)
|
||||
{
|
||||
private_ike_cfg_t *this;
|
||||
|
||||
@@ -644,24 +641,24 @@ ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.refcount = 1,
|
||||
.version = version,
|
||||
.certreq = certreq,
|
||||
.force_encap = force_encap,
|
||||
.fragmentation = fragmentation,
|
||||
.me = strdup(me),
|
||||
.version = data->version,
|
||||
.certreq = !data->no_certreq,
|
||||
.force_encap = data->force_encap,
|
||||
.fragmentation = data->fragmentation,
|
||||
.me = strdup(data->local),
|
||||
.my_ranges = linked_list_create(),
|
||||
.my_hosts = linked_list_create(),
|
||||
.other = strdup(other),
|
||||
.other = strdup(data->remote),
|
||||
.other_ranges = linked_list_create(),
|
||||
.other_hosts = linked_list_create(),
|
||||
.my_port = my_port,
|
||||
.other_port = other_port,
|
||||
.dscp = dscp,
|
||||
.my_port = data->local_port,
|
||||
.other_port = data->remote_port,
|
||||
.dscp = data->dscp,
|
||||
.proposals = linked_list_create(),
|
||||
);
|
||||
|
||||
parse_addresses(me, this->my_hosts, this->my_ranges);
|
||||
parse_addresses(other, this->other_hosts, this->other_ranges);
|
||||
parse_addresses(data->local, this->my_hosts, this->my_ranges);
|
||||
parse_addresses(data->remote, this->other_hosts, this->other_ranges);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2018 Tobias Brunner
|
||||
* Copyright (C) 2012-2019 Tobias Brunner
|
||||
* Copyright (C) 2005-2007 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
@@ -26,6 +26,7 @@
|
||||
typedef enum ike_version_t ike_version_t;
|
||||
typedef enum fragmentation_t fragmentation_t;
|
||||
typedef struct ike_cfg_t ike_cfg_t;
|
||||
typedef struct ike_cfg_create_t ike_cfg_create_t;
|
||||
|
||||
#include <library.h>
|
||||
#include <networking/host.h>
|
||||
@@ -241,30 +242,41 @@ struct ike_cfg_t {
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a ike_cfg_t object.
|
||||
* Data passed to the constructor of an ike_cfg_t object.
|
||||
*
|
||||
* Supplied hosts become owned by ike_cfg, strings get cloned.
|
||||
* local and remote are comma separated lists of IP addresses, DNS names,
|
||||
* IP ranges or subnets. When initiating, the first non-range/subnet address is
|
||||
* used as address. When responding, a match is performed against all items in
|
||||
* the list.
|
||||
*/
|
||||
struct ike_cfg_create_t {
|
||||
/** IKE major version to use for this config */
|
||||
ike_version_t version;
|
||||
/** Address/DNS name of local peer (cloned) */
|
||||
char *local;
|
||||
/** IKE port to use as source, 500 uses IKEv2 port floating */
|
||||
uint16_t local_port;
|
||||
/** Address/DNS name of remote peer (cloned) */
|
||||
char *remote;
|
||||
/** IKE port to use as dest, 500 uses IKEv2 port floating */
|
||||
uint16_t remote_port;
|
||||
/** TRUE to not send any certificate requests */
|
||||
bool no_certreq;
|
||||
/** Enforce UDP encapsulation by faking NATD notify */
|
||||
bool force_encap;
|
||||
/** Use IKE fragmentation */
|
||||
fragmentation_t fragmentation;
|
||||
/** DSCP value to send IKE packets with */
|
||||
uint8_t dscp;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an ike_cfg_t object.
|
||||
*
|
||||
* me and other are comma separated lists of IP addresses, DNS names, IP ranges
|
||||
* or subnets. When initiating, the first non-range/subnet address is used
|
||||
* as address. When responding, a match is performed against all items in the
|
||||
* list.
|
||||
*
|
||||
* @param version IKE major version to use for this config
|
||||
* @param certreq TRUE to send a certificate request
|
||||
* @param force_encap enforce UDP encapsulation by faking NATD notify
|
||||
* @param me address/DNS name of local peer
|
||||
* @param my_port IKE port to use as source, 500 uses IKEv2 port floating
|
||||
* @param other address/DNS name of remote peer
|
||||
* @param other_port IKE port to use as dest, 500 uses IKEv2 port floating
|
||||
* @param fragmentation use IKEv1 fragmentation
|
||||
* @param dscp DSCP value to send IKE packets with
|
||||
* @param data data for this ike_cfg
|
||||
* @return ike_cfg_t object.
|
||||
*/
|
||||
ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
|
||||
char *me, uint16_t my_port,
|
||||
char *other, uint16_t other_port,
|
||||
fragmentation_t fragmentation, uint8_t dscp);
|
||||
ike_cfg_t *ike_cfg_create(ike_cfg_create_t *data);
|
||||
|
||||
/**
|
||||
* Determine the address family of the local or remote address(es). If multiple
|
||||
|
||||
Reference in New Issue
Block a user