merging kernel_klips plugin back into trunk
This commit is contained in:
@@ -468,6 +468,14 @@ AC_ARG_ENABLE(
|
||||
fi]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[kernel-klips],
|
||||
AS_HELP_STRING([--enable-kernel-klips],[enable the KLIPS kernel interface. (default is NO).]),
|
||||
[if test x$enableval = xyes; then
|
||||
kernel_klips=true
|
||||
fi]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[nat-transport],
|
||||
AS_HELP_STRING([--enable-nat-transport],[enable NAT traversal with IPsec transport mode (default is NO).]),
|
||||
@@ -901,6 +909,7 @@ AM_CONDITIONAL(USE_EAP_GTC, test x$eap_gtc = xtrue)
|
||||
AM_CONDITIONAL(USE_EAP_AKA, test x$eap_aka = xtrue)
|
||||
AM_CONDITIONAL(USE_KERNEL_NETLINK, test x$kernel_netlink = xtrue)
|
||||
AM_CONDITIONAL(USE_KERNEL_PFKEY, test x$kernel_pfkey = xtrue)
|
||||
AM_CONDITIONAL(USE_KERNEL_KLIPS, test x$kernel_klips = xtrue)
|
||||
|
||||
dnl other options
|
||||
dnl =============
|
||||
@@ -977,6 +986,7 @@ AC_OUTPUT(
|
||||
src/charon/plugins/eap_sim_file/Makefile
|
||||
src/charon/plugins/kernel_netlink/Makefile
|
||||
src/charon/plugins/kernel_pfkey/Makefile
|
||||
src/charon/plugins/kernel_klips/Makefile
|
||||
src/charon/plugins/smp/Makefile
|
||||
src/charon/plugins/sql/Makefile
|
||||
src/charon/plugins/medsrv/Makefile
|
||||
|
||||
@@ -156,6 +156,11 @@ if USE_KERNEL_PFKEY
|
||||
PLUGINS += kernel-pfkey
|
||||
endif
|
||||
|
||||
if USE_KERNEL_KLIPS
|
||||
SUBDIRS += plugins/kernel_klips
|
||||
PLUGINS += kernel-klips
|
||||
endif
|
||||
|
||||
if USE_KERNEL_NETLINK
|
||||
SUBDIRS += plugins/kernel_netlink
|
||||
PLUGINS += kernel-netlink
|
||||
|
||||
@@ -62,9 +62,6 @@ ENUM_NEXT(payload_type_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, N
|
||||
ENUM_NEXT(payload_type_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
|
||||
"ID_PEER");
|
||||
ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, ID_PEER,
|
||||
#else
|
||||
ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
|
||||
#endif /* ME */
|
||||
"HEADER",
|
||||
"PROPOSAL_SUBSTRUCTURE",
|
||||
"TRANSFORM_SUBSTRUCTURE",
|
||||
@@ -72,6 +69,16 @@ ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION
|
||||
"TRAFFIC_SELECTOR_SUBSTRUCTURE",
|
||||
"CONFIGURATION_ATTRIBUTE",
|
||||
"UNKNOWN_PAYLOAD");
|
||||
#else
|
||||
ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
|
||||
"HEADER",
|
||||
"PROPOSAL_SUBSTRUCTURE",
|
||||
"TRANSFORM_SUBSTRUCTURE",
|
||||
"TRANSFORM_ATTRIBUTE",
|
||||
"TRAFFIC_SELECTOR_SUBSTRUCTURE",
|
||||
"CONFIGURATION_ATTRIBUTE",
|
||||
"UNKNOWN_PAYLOAD");
|
||||
#endif /* ME */
|
||||
ENUM_END(payload_type_names, UNKNOWN_PAYLOAD);
|
||||
|
||||
/* short forms of payload names */
|
||||
@@ -98,9 +105,6 @@ ENUM_NEXT(payload_type_short_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICAT
|
||||
ENUM_NEXT(payload_type_short_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
|
||||
"IDp");
|
||||
ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, ID_PEER,
|
||||
#else
|
||||
ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
|
||||
#endif /* ME */
|
||||
"HDR",
|
||||
"PROP",
|
||||
"TRANS",
|
||||
@@ -108,6 +112,16 @@ ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTI
|
||||
"TSSUB",
|
||||
"CPATTR",
|
||||
"??");
|
||||
#else
|
||||
ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
|
||||
"HDR",
|
||||
"PROP",
|
||||
"TRANS",
|
||||
"TRANSATTR",
|
||||
"TSSUB",
|
||||
"CPATTR",
|
||||
"??");
|
||||
#endif /* ME */
|
||||
ENUM_END(payload_type_short_names, UNKNOWN_PAYLOAD);
|
||||
|
||||
/*
|
||||
|
||||
@@ -87,31 +87,32 @@ static status_t add_sa(private_kernel_interface_t *this, host_t *src, host_t *ds
|
||||
u_int64_t expire_soft, u_int64_t expire_hard,
|
||||
u_int16_t enc_alg, chunk_t enc_key,
|
||||
u_int16_t int_alg, chunk_t int_key,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, bool encap, bool update)
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi, bool encap,
|
||||
bool inbound)
|
||||
{
|
||||
return this->ipsec->add_sa(this->ipsec, src, dst, spi, protocol, reqid,
|
||||
expire_soft, expire_hard, enc_alg, enc_key, int_alg, int_key,
|
||||
mode, ipcomp, encap, update);
|
||||
mode, ipcomp, cpi, encap, inbound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of kernel_interface_t.update_sa
|
||||
*/
|
||||
static status_t update_sa(private_kernel_interface_t *this, u_int32_t spi,
|
||||
protocol_id_t protocol, host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap)
|
||||
protocol_id_t protocol, u_int16_t cpi, host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap, bool new_encap)
|
||||
{
|
||||
return this->ipsec->update_sa(this->ipsec, spi, protocol, src, dst, new_src,
|
||||
new_dst, encap);
|
||||
return this->ipsec->update_sa(this->ipsec, spi, protocol, cpi, src, dst,
|
||||
new_src, new_dst, encap, new_encap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of kernel_interface_t.del_sa
|
||||
*/
|
||||
static status_t del_sa(private_kernel_interface_t *this, host_t *dst, u_int32_t spi,
|
||||
protocol_id_t protocol)
|
||||
protocol_id_t protocol, u_int16_t cpi)
|
||||
{
|
||||
return this->ipsec->del_sa(this->ipsec, dst, spi, protocol);
|
||||
return this->ipsec->del_sa(this->ipsec, dst, spi, protocol, cpi);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,12 +120,12 @@ static status_t del_sa(private_kernel_interface_t *this, host_t *dst, u_int32_t
|
||||
*/
|
||||
static status_t add_policy(private_kernel_interface_t *this, host_t *src, host_t *dst,
|
||||
traffic_selector_t *src_ts, traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction, protocol_id_t protocol,
|
||||
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
|
||||
u_int16_t ipcomp)
|
||||
policy_dir_t direction, u_int32_t spi, protocol_id_t protocol,
|
||||
u_int32_t reqid, ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool routed)
|
||||
{
|
||||
return this->ipsec->add_policy(this->ipsec, src, dst, src_ts, dst_ts,
|
||||
direction, protocol, reqid, high_prio, mode, ipcomp);
|
||||
direction, spi, protocol, reqid, mode, ipcomp, cpi, routed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,9 +143,9 @@ static status_t query_policy(private_kernel_interface_t *this,
|
||||
*/
|
||||
static status_t del_policy(private_kernel_interface_t *this,
|
||||
traffic_selector_t *src_ts, traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction)
|
||||
policy_dir_t direction, bool unrouted)
|
||||
{
|
||||
return this->ipsec->del_policy(this->ipsec, src_ts, dst_ts, direction);
|
||||
return this->ipsec->del_policy(this->ipsec, src_ts, dst_ts, direction, unrouted);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,12 +371,12 @@ kernel_interface_t *kernel_interface_create()
|
||||
|
||||
this->public.get_spi = (status_t(*)(kernel_interface_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
|
||||
this->public.get_cpi = (status_t(*)(kernel_interface_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
|
||||
this->public.add_sa = (status_t(*)(kernel_interface_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.update_sa = (status_t(*)(kernel_interface_t*,u_int32_t,protocol_id_t,host_t*,host_t*,host_t*,host_t*,bool))update_sa;
|
||||
this->public.del_sa = (status_t(*)(kernel_interface_t*,host_t*,u_int32_t,protocol_id_t))del_sa;
|
||||
this->public.add_policy = (status_t(*)(kernel_interface_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,protocol_id_t,u_int32_t,bool,ipsec_mode_t,u_int16_t))add_policy;
|
||||
this->public.add_sa = (status_t(*)(kernel_interface_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.update_sa = (status_t(*)(kernel_interface_t*,u_int32_t,protocol_id_t,u_int16_t,host_t*,host_t*,host_t*,host_t*,bool,bool))update_sa;
|
||||
this->public.del_sa = (status_t(*)(kernel_interface_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
|
||||
this->public.add_policy = (status_t(*)(kernel_interface_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
|
||||
this->public.query_policy = (status_t(*)(kernel_interface_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
|
||||
this->public.del_policy = (status_t(*)(kernel_interface_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t))del_policy;
|
||||
this->public.del_policy = (status_t(*)(kernel_interface_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
|
||||
|
||||
this->public.get_source_addr = (host_t*(*)(kernel_interface_t*, host_t *dest, host_t *src))get_source_addr;
|
||||
this->public.get_nexthop = (host_t*(*)(kernel_interface_t*, host_t *dest))get_nexthop;
|
||||
|
||||
@@ -56,10 +56,6 @@ struct kernel_interface_t {
|
||||
/**
|
||||
* Get a SPI from the kernel.
|
||||
*
|
||||
* @warning get_spi() implicitly creates an SA with
|
||||
* the allocated SPI, therefore the replace flag
|
||||
* in add_sa() must be set when installing this SA.
|
||||
*
|
||||
* @param src source address of SA
|
||||
* @param dst destination address of SA
|
||||
* @param protocol protocol for SA (ESP/AH)
|
||||
@@ -106,8 +102,9 @@ struct kernel_interface_t {
|
||||
* @param int_key key to use for integrity protection
|
||||
* @param mode mode of the SA (tunnel, transport)
|
||||
* @param ipcomp IPComp transform to use
|
||||
* @param cpi CPI for IPComp
|
||||
* @param encap enable UDP encapsulation for NAT traversal
|
||||
* @param replace Should an already installed SA be updated?
|
||||
* @param inbound TRUE if this is an inbound SA
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*add_sa) (kernel_interface_t *this,
|
||||
@@ -116,8 +113,8 @@ struct kernel_interface_t {
|
||||
u_int64_t expire_soft, u_int64_t expire_hard,
|
||||
u_int16_t enc_alg, chunk_t enc_key,
|
||||
u_int16_t int_alg, chunk_t int_key,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, bool encap,
|
||||
bool update);
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool encap, bool inbound);
|
||||
|
||||
/**
|
||||
* Update the hosts on an installed SA.
|
||||
@@ -129,17 +126,21 @@ struct kernel_interface_t {
|
||||
*
|
||||
* @param spi SPI of the SA
|
||||
* @param protocol protocol for this SA (ESP/AH)
|
||||
* @param cpi CPI for IPComp, 0 if no IPComp is used
|
||||
* @param src current source address
|
||||
* @param dst current destination address
|
||||
* @param new_src new source address
|
||||
* @param new_dst new destination address
|
||||
* @param encap use UDP encapsulation
|
||||
* @return SUCCESS if operation completed
|
||||
* @param encap current use of UDP encapsulation
|
||||
* @param new_encap new use of UDP encapsulation
|
||||
* @return SUCCESS if operation completed, NOT_SUPPORTED if
|
||||
* the kernel interface can't update the SA
|
||||
*/
|
||||
status_t (*update_sa)(kernel_interface_t *this,
|
||||
u_int32_t spi, protocol_id_t protocol,
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
|
||||
host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap);
|
||||
host_t *new_src, host_t *new_dst,
|
||||
bool encap, bool new_encap);
|
||||
|
||||
/**
|
||||
* Delete a previously installed SA from the SAD.
|
||||
@@ -147,10 +148,11 @@ struct kernel_interface_t {
|
||||
* @param dst destination address for this SA
|
||||
* @param spi SPI allocated by us or remote peer
|
||||
* @param protocol protocol for this SA (ESP/AH)
|
||||
* @param cpi CPI for IPComp or 0
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*del_sa) (kernel_interface_t *this, host_t *dst, u_int32_t spi,
|
||||
protocol_id_t protocol);
|
||||
protocol_id_t protocol, u_int16_t cpi);
|
||||
|
||||
/**
|
||||
* Add a policy to the SPD.
|
||||
@@ -163,20 +165,23 @@ struct kernel_interface_t {
|
||||
* @param src_ts traffic selector to match traffic source
|
||||
* @param dst_ts traffic selector to match traffic dest
|
||||
* @param direction direction of traffic, POLICY_IN, POLICY_OUT, POLICY_FWD
|
||||
* @param spi SPI of SA
|
||||
* @param protocol protocol to use to protect traffic (AH/ESP)
|
||||
* @param reqid unique ID of an SA to use to enforce policy
|
||||
* @param high_prio if TRUE, uses a higher priority than any with FALSE
|
||||
* @param mode mode of SA (tunnel, transport)
|
||||
* @param ipcomp the IPComp transform used
|
||||
* @param cpi CPI for IPComp
|
||||
* @param routed TRUE, if this policy is routed in the kernel
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*add_policy) (kernel_interface_t *this,
|
||||
host_t *src, host_t *dst,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction, protocol_id_t protocol,
|
||||
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
|
||||
u_int16_t ipcomp);
|
||||
policy_dir_t direction, u_int32_t spi,
|
||||
protocol_id_t protocol, u_int32_t reqid,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool routed);
|
||||
|
||||
/**
|
||||
* Query the use time of a policy.
|
||||
@@ -206,12 +211,14 @@ struct kernel_interface_t {
|
||||
* @param src_ts traffic selector to match traffic source
|
||||
* @param dst_ts traffic selector to match traffic dest
|
||||
* @param direction direction of traffic, POLICY_IN, POLICY_OUT, POLICY_FWD
|
||||
* @param unrouted TRUE, if this policy is unrouted from the kernel
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*del_policy) (kernel_interface_t *this,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction);
|
||||
policy_dir_t direction,
|
||||
bool unrouted);
|
||||
|
||||
/**
|
||||
* Get our outgoing source address for a destination.
|
||||
|
||||
@@ -88,10 +88,6 @@ struct kernel_ipsec_t {
|
||||
/**
|
||||
* Get a SPI from the kernel.
|
||||
*
|
||||
* @warning get_spi() implicitly creates an SA with
|
||||
* the allocated SPI, therefore the replace flag
|
||||
* in add_sa() must be set when installing this SA.
|
||||
*
|
||||
* @param src source address of SA
|
||||
* @param dst destination address of SA
|
||||
* @param protocol protocol for SA (ESP/AH)
|
||||
@@ -138,8 +134,9 @@ struct kernel_ipsec_t {
|
||||
* @param int_key key to use for integrity protection
|
||||
* @param mode mode of the SA (tunnel, transport)
|
||||
* @param ipcomp IPComp transform to use
|
||||
* @param cpi CPI for IPComp
|
||||
* @param encap enable UDP encapsulation for NAT traversal
|
||||
* @param replace Should an already installed SA be updated?
|
||||
* @param inbound TRUE if this is an inbound SA
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*add_sa) (kernel_ipsec_t *this,
|
||||
@@ -148,8 +145,8 @@ struct kernel_ipsec_t {
|
||||
u_int64_t expire_soft, u_int64_t expire_hard,
|
||||
u_int16_t enc_alg, chunk_t enc_key,
|
||||
u_int16_t int_alg, chunk_t int_key,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, bool encap,
|
||||
bool update);
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool encap, bool inbound);
|
||||
|
||||
/**
|
||||
* Update the hosts on an installed SA.
|
||||
@@ -161,17 +158,21 @@ struct kernel_ipsec_t {
|
||||
*
|
||||
* @param spi SPI of the SA
|
||||
* @param protocol protocol for this SA (ESP/AH)
|
||||
* @param cpi CPI for IPComp, 0 if no IPComp is used
|
||||
* @param src current source address
|
||||
* @param dst current destination address
|
||||
* @param new_src new source address
|
||||
* @param new_dst new destination address
|
||||
* @param encap use UDP encapsulation
|
||||
* @return SUCCESS if operation completed
|
||||
* @param encap current use of UDP encapsulation
|
||||
* @param new_encap new use of UDP encapsulation
|
||||
* @return SUCCESS if operation completed, NOT_SUPPORTED if
|
||||
* the kernel interface can't update the SA
|
||||
*/
|
||||
status_t (*update_sa)(kernel_ipsec_t *this,
|
||||
u_int32_t spi, protocol_id_t protocol,
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
|
||||
host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap);
|
||||
host_t *new_src, host_t *new_dst,
|
||||
bool encap, bool new_encap);
|
||||
|
||||
/**
|
||||
* Delete a previusly installed SA from the SAD.
|
||||
@@ -179,10 +180,11 @@ struct kernel_ipsec_t {
|
||||
* @param dst destination address for this SA
|
||||
* @param spi SPI allocated by us or remote peer
|
||||
* @param protocol protocol for this SA (ESP/AH)
|
||||
* @param cpi CPI for IPComp or 0
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*del_sa) (kernel_ipsec_t *this, host_t *dst, u_int32_t spi,
|
||||
protocol_id_t protocol);
|
||||
protocol_id_t protocol, u_int16_t cpi);
|
||||
|
||||
/**
|
||||
* Add a policy to the SPD.
|
||||
@@ -195,20 +197,23 @@ struct kernel_ipsec_t {
|
||||
* @param src_ts traffic selector to match traffic source
|
||||
* @param dst_ts traffic selector to match traffic dest
|
||||
* @param direction direction of traffic, POLICY_IN, POLICY_OUT, POLICY_FWD
|
||||
* @param spi SPI of SA
|
||||
* @param protocol protocol to use to protect traffic (AH/ESP)
|
||||
* @param reqid unique ID of an SA to use to enforce policy
|
||||
* @param high_prio if TRUE, uses a higher priority than any with FALSE
|
||||
* @param mode mode of SA (tunnel, transport)
|
||||
* @param ipcomp the IPComp transform used
|
||||
* @param cpi CPI for IPComp
|
||||
* @param routed TRUE, if this policy is routed in the kernel
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*add_policy) (kernel_ipsec_t *this,
|
||||
host_t *src, host_t *dst,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction, protocol_id_t protocol,
|
||||
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
|
||||
u_int16_t ipcomp);
|
||||
policy_dir_t direction, u_int32_t spi,
|
||||
protocol_id_t protocol, u_int32_t reqid,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool routed);
|
||||
|
||||
/**
|
||||
* Query the use time of a policy.
|
||||
@@ -238,12 +243,14 @@ struct kernel_ipsec_t {
|
||||
* @param src_ts traffic selector to match traffic source
|
||||
* @param dst_ts traffic selector to match traffic dest
|
||||
* @param direction direction of traffic, POLICY_IN, POLICY_OUT, POLICY_FWD
|
||||
* @param unrouted TRUE, if this policy is unrouted from the kernel
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*del_policy) (kernel_ipsec_t *this,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction);
|
||||
policy_dir_t direction,
|
||||
bool unrouted);
|
||||
|
||||
/**
|
||||
* Destroy the implementation.
|
||||
|
||||
+64
-44
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
||||
* Copyright (C) 2006-2008 Tobias Brunner
|
||||
* Copyright (C) 2006 Daniel Roethlisberger
|
||||
* Copyright (C) 2005-2007 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
@@ -33,7 +34,7 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <linux/ipsec.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/filter.h>
|
||||
#include <net/if.h>
|
||||
|
||||
@@ -44,11 +45,6 @@
|
||||
/* length of non-esp marker */
|
||||
#define MARKER_LEN sizeof(u_int32_t)
|
||||
|
||||
/* from linux/in.h */
|
||||
#ifndef IP_IPSEC_POLICY
|
||||
#define IP_IPSEC_POLICY 16
|
||||
#endif /*IP_IPSEC_POLICY*/
|
||||
|
||||
/* from linux/udp.h */
|
||||
#ifndef UDP_ENCAP
|
||||
#define UDP_ENCAP 100
|
||||
@@ -100,6 +96,18 @@ struct private_socket_t {
|
||||
int ipv6_natt;
|
||||
};
|
||||
|
||||
/**
|
||||
* enumerator for underlying sockets
|
||||
*/
|
||||
typedef struct {
|
||||
/** implements enumerator_t */
|
||||
enumerator_t public;
|
||||
/** sockets we enumerate */
|
||||
private_socket_t *socket;
|
||||
/** counter */
|
||||
u_int8_t index;
|
||||
} socket_enumerator_t;
|
||||
|
||||
/**
|
||||
* implementation of socket_t.receive
|
||||
*/
|
||||
@@ -405,8 +413,7 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
|
||||
int on = TRUE;
|
||||
int type = UDP_ENCAP_ESPINUDP;
|
||||
struct sockaddr_storage addr;
|
||||
u_int sol, ipsec_policy, pktinfo;
|
||||
struct sadb_x_policy policy;
|
||||
u_int sol, pktinfo;
|
||||
int skt;
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
@@ -420,7 +427,6 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
|
||||
sin->sin_addr.s_addr = INADDR_ANY;
|
||||
sin->sin_port = htons(port);
|
||||
sol = SOL_IP;
|
||||
ipsec_policy = IP_IPSEC_POLICY;
|
||||
pktinfo = IP_PKTINFO;
|
||||
break;
|
||||
}
|
||||
@@ -431,7 +437,6 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
|
||||
memcpy(&sin6->sin6_addr, &in6addr_any, sizeof(in6addr_any));
|
||||
sin6->sin6_port = htons(port);
|
||||
sol = SOL_IPV6;
|
||||
ipsec_policy = IPV6_IPSEC_POLICY;
|
||||
pktinfo = IPV6_2292PKTINFO;
|
||||
break;
|
||||
}
|
||||
@@ -452,29 +457,6 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* bypass IKE traffic on socket */
|
||||
memset(&policy, 0, sizeof(policy));
|
||||
policy.sadb_x_policy_len = sizeof(policy) / sizeof(u_int64_t);
|
||||
policy.sadb_x_policy_exttype = SADB_X_EXT_POLICY;
|
||||
policy.sadb_x_policy_type = IPSEC_POLICY_BYPASS;
|
||||
|
||||
policy.sadb_x_policy_dir = IPSEC_DIR_OUTBOUND;
|
||||
if (setsockopt(skt, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
|
||||
{
|
||||
DBG1(DBG_NET, "unable to set IPSEC_POLICY on socket: %s",
|
||||
strerror(errno));
|
||||
close(skt);
|
||||
return 0;
|
||||
}
|
||||
policy.sadb_x_policy_dir = IPSEC_DIR_INBOUND;
|
||||
if (setsockopt(skt, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
|
||||
{
|
||||
DBG1(DBG_NET, "unable to set IPSEC_POLICY on socket: %s",
|
||||
strerror(errno));
|
||||
close(skt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* bind the send socket */
|
||||
if (bind(skt, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
{
|
||||
@@ -500,6 +482,53 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
|
||||
return skt;
|
||||
}
|
||||
|
||||
/**
|
||||
* enumerate function for socket_enumerator_t
|
||||
*/
|
||||
static bool enumerate(socket_enumerator_t *this, int *fd, int *family, int *port)
|
||||
{
|
||||
static const struct {
|
||||
int fd_offset;
|
||||
int family;
|
||||
int port;
|
||||
} sockets[] = {
|
||||
{ 0, 0, 0 },
|
||||
{ offsetof(private_socket_t, ipv4), AF_INET, IKEV2_UDP_PORT },
|
||||
{ offsetof(private_socket_t, ipv6), AF_INET6, IKEV2_UDP_PORT },
|
||||
{ offsetof(private_socket_t, ipv4_natt), AF_INET, IKEV2_NATT_PORT },
|
||||
{ offsetof(private_socket_t, ipv6_natt), AF_INET6, IKEV2_NATT_PORT }
|
||||
};
|
||||
|
||||
while(++this->index <= 4)
|
||||
{
|
||||
int sock = *(int*)((char*)this->socket + sockets[this->index].fd_offset);
|
||||
if (!sock)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*fd = sock;
|
||||
*family = sockets[this->index].family;
|
||||
*port = sockets[this->index].port;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* implementation of socket_t.create_enumerator
|
||||
*/
|
||||
static enumerator_t *create_enumerator(private_socket_t *this)
|
||||
{
|
||||
socket_enumerator_t *enumerator;
|
||||
|
||||
enumerator = malloc_thing(socket_enumerator_t);
|
||||
enumerator->index = 0;
|
||||
enumerator->socket = this;
|
||||
enumerator->public.enumerate = (void*)enumerate;
|
||||
enumerator->public.destroy = (void*)free;
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
/**
|
||||
* implementation of socket_t.destroy
|
||||
*/
|
||||
@@ -529,12 +558,12 @@ static void destroy(private_socket_t *this)
|
||||
*/
|
||||
socket_t *socket_create()
|
||||
{
|
||||
int key;
|
||||
private_socket_t *this = malloc_thing(private_socket_t);
|
||||
|
||||
/* public functions */
|
||||
this->public.send = (status_t(*)(socket_t*, packet_t*))sender;
|
||||
this->public.receive = (status_t(*)(socket_t*, packet_t**))receiver;
|
||||
this->public.create_enumerator = (enumerator_t*(*)(socket_t*))create_enumerator;
|
||||
this->public.destroy = (void(*)(socket_t*)) destroy;
|
||||
|
||||
this->ipv4 = 0;
|
||||
@@ -542,15 +571,6 @@ socket_t *socket_create()
|
||||
this->ipv4_natt = 0;
|
||||
this->ipv6_natt = 0;
|
||||
|
||||
/* we open a AF_KEY socket to autoload the af_key module. Otherwise
|
||||
* setsockopt(IPSEC_POLICY) won't work. */
|
||||
key = socket(AF_KEY, SOCK_RAW, PF_KEY_V2);
|
||||
if (key == 0)
|
||||
{
|
||||
charon->kill(charon, "could not open AF_KEY socket");
|
||||
}
|
||||
close(key);
|
||||
|
||||
this->ipv4 = open_socket(this, AF_INET, IKEV2_UDP_PORT);
|
||||
if (this->ipv4 == 0)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct socket_t socket_t;
|
||||
#include <library.h>
|
||||
#include <network/packet.h>
|
||||
#include <utils/host.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <utils/enumerator.h>
|
||||
|
||||
/**
|
||||
* Maximum size of a packet.
|
||||
@@ -84,6 +84,13 @@ struct socket_t {
|
||||
*/
|
||||
status_t (*send) (socket_t *this, packet_t *packet);
|
||||
|
||||
/**
|
||||
* Enumerate the underlying sockets.
|
||||
*
|
||||
* @return enumerator_t object
|
||||
*/
|
||||
enumerator_t *(*create_enumerator) (socket_t *this);
|
||||
|
||||
/**
|
||||
* Destroy socket.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
INCLUDES = -I${linuxdir} -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
|
||||
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
plugin_LTLIBRARIES = libstrongswan-kernel-klips.la
|
||||
|
||||
libstrongswan_kernel_klips_la_SOURCES = kernel_klips_plugin.h kernel_klips_plugin.c \
|
||||
kernel_klips_ipsec.h kernel_klips_ipsec.c pfkeyv2.h
|
||||
libstrongswan_kernel_klips_la_LDFLAGS = -module
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* 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
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup kernel_klips_ipsec_i kernel_klips_ipsec
|
||||
* @{ @ingroup kernel_klips
|
||||
*/
|
||||
|
||||
#ifndef KERNEL_KLIPS_IPSEC_H_
|
||||
#define KERNEL_KLIPS_IPSEC_H_
|
||||
|
||||
#include <kernel/kernel_ipsec.h>
|
||||
|
||||
typedef struct kernel_klips_ipsec_t kernel_klips_ipsec_t;
|
||||
|
||||
/**
|
||||
* Implementation of the kernel ipsec interface using PF_KEY.
|
||||
*/
|
||||
struct kernel_klips_ipsec_t {
|
||||
|
||||
/**
|
||||
* Implements kernel_ipsec_t interface
|
||||
*/
|
||||
kernel_ipsec_t interface;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a PF_KEY kernel ipsec interface instance.
|
||||
*
|
||||
* @return kernel_klips_ipsec_t instance
|
||||
*/
|
||||
kernel_klips_ipsec_t *kernel_klips_ipsec_create();
|
||||
|
||||
#endif /* KERNEL_KLIPS_IPSEC_H_ @} */
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* 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
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "kernel_klips_plugin.h"
|
||||
|
||||
#include "kernel_klips_ipsec.h"
|
||||
|
||||
#include <daemon.h>
|
||||
|
||||
typedef struct private_kernel_klips_plugin_t private_kernel_klips_plugin_t;
|
||||
|
||||
/**
|
||||
* private data of kernel PF_KEY plugin
|
||||
*/
|
||||
struct private_kernel_klips_plugin_t {
|
||||
/**
|
||||
* implements plugin interface
|
||||
*/
|
||||
kernel_klips_plugin_t public;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of plugin_t.destroy
|
||||
*/
|
||||
static void destroy(private_kernel_klips_plugin_t *this)
|
||||
{
|
||||
charon->kernel_interface->remove_ipsec_interface(charon->kernel_interface, (kernel_ipsec_constructor_t)kernel_klips_ipsec_create);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* see header file
|
||||
*/
|
||||
plugin_t *plugin_create()
|
||||
{
|
||||
private_kernel_klips_plugin_t *this = malloc_thing(private_kernel_klips_plugin_t);
|
||||
|
||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
||||
|
||||
charon->kernel_interface->add_ipsec_interface(charon->kernel_interface, (kernel_ipsec_constructor_t)kernel_klips_ipsec_create);
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* 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
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup kernel_klips kernel_klips
|
||||
* @ingroup cplugins
|
||||
*
|
||||
* @defgroup kernel_klips_plugin kernel_klips_plugin
|
||||
* @{ @ingroup kernel_klips
|
||||
*/
|
||||
|
||||
#ifndef KERNEL_KLIPS_PLUGIN_H_
|
||||
#define KERNEL_KLIPS_PLUGIN_H_
|
||||
|
||||
#include <plugins/plugin.h>
|
||||
|
||||
typedef struct kernel_klips_plugin_t kernel_klips_plugin_t;
|
||||
|
||||
/**
|
||||
* PF_KEY kernel interface plugin
|
||||
*/
|
||||
struct kernel_klips_plugin_t {
|
||||
|
||||
/**
|
||||
* implements plugin interface
|
||||
*/
|
||||
plugin_t plugin;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a kernel_klips_plugin instance.
|
||||
*/
|
||||
plugin_t *plugin_create();
|
||||
|
||||
#endif /* KERNEL_KLIPS_PLUGIN_H_ @} */
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
RFC 2367 PF_KEY Key Management API July 1998
|
||||
|
||||
|
||||
Appendix D: Sample Header File
|
||||
|
||||
This file defines structures and symbols for the PF_KEY Version 2
|
||||
key management interface. It was written at the U.S. Naval Research
|
||||
Laboratory. This file is in the public domain. The authors ask that
|
||||
you leave this credit intact on any copies of this file.
|
||||
*/
|
||||
#ifndef __PFKEY_V2_H
|
||||
#define __PFKEY_V2_H 1
|
||||
|
||||
#define PF_KEY_V2 2
|
||||
#define PFKEYV2_REVISION 199806L
|
||||
|
||||
#define SADB_RESERVED 0
|
||||
#define SADB_GETSPI 1
|
||||
#define SADB_UPDATE 2
|
||||
#define SADB_ADD 3
|
||||
#define SADB_DELETE 4
|
||||
#define SADB_GET 5
|
||||
#define SADB_ACQUIRE 6
|
||||
#define SADB_REGISTER 7
|
||||
#define SADB_EXPIRE 8
|
||||
#define SADB_FLUSH 9
|
||||
#define SADB_DUMP 10
|
||||
#define SADB_X_PROMISC 11
|
||||
#define SADB_X_PCHANGE 12
|
||||
#define SADB_X_GRPSA 13
|
||||
#define SADB_X_ADDFLOW 14
|
||||
#define SADB_X_DELFLOW 15
|
||||
#define SADB_X_DEBUG 16
|
||||
#define SADB_X_NAT_T_NEW_MAPPING 17
|
||||
#define SADB_MAX 17
|
||||
|
||||
struct sadb_msg {
|
||||
uint8_t sadb_msg_version;
|
||||
uint8_t sadb_msg_type;
|
||||
uint8_t sadb_msg_errno;
|
||||
uint8_t sadb_msg_satype;
|
||||
uint16_t sadb_msg_len;
|
||||
uint16_t sadb_msg_reserved;
|
||||
uint32_t sadb_msg_seq;
|
||||
uint32_t sadb_msg_pid;
|
||||
};
|
||||
|
||||
struct sadb_ext {
|
||||
uint16_t sadb_ext_len;
|
||||
uint16_t sadb_ext_type;
|
||||
};
|
||||
|
||||
struct sadb_sa {
|
||||
uint16_t sadb_sa_len;
|
||||
uint16_t sadb_sa_exttype;
|
||||
uint32_t sadb_sa_spi;
|
||||
uint8_t sadb_sa_replay;
|
||||
uint8_t sadb_sa_state;
|
||||
uint8_t sadb_sa_auth;
|
||||
uint8_t sadb_sa_encrypt;
|
||||
uint32_t sadb_sa_flags;
|
||||
};
|
||||
|
||||
struct sadb_lifetime {
|
||||
uint16_t sadb_lifetime_len;
|
||||
uint16_t sadb_lifetime_exttype;
|
||||
uint32_t sadb_lifetime_allocations;
|
||||
uint64_t sadb_lifetime_bytes;
|
||||
uint64_t sadb_lifetime_addtime;
|
||||
uint64_t sadb_lifetime_usetime;
|
||||
uint32_t sadb_x_lifetime_packets;
|
||||
uint32_t sadb_x_lifetime_reserved;
|
||||
};
|
||||
|
||||
struct sadb_address {
|
||||
uint16_t sadb_address_len;
|
||||
uint16_t sadb_address_exttype;
|
||||
uint8_t sadb_address_proto;
|
||||
uint8_t sadb_address_prefixlen;
|
||||
uint16_t sadb_address_reserved;
|
||||
};
|
||||
|
||||
struct sadb_key {
|
||||
uint16_t sadb_key_len;
|
||||
uint16_t sadb_key_exttype;
|
||||
uint16_t sadb_key_bits;
|
||||
uint16_t sadb_key_reserved;
|
||||
};
|
||||
|
||||
struct sadb_ident {
|
||||
uint16_t sadb_ident_len;
|
||||
uint16_t sadb_ident_exttype;
|
||||
uint16_t sadb_ident_type;
|
||||
uint16_t sadb_ident_reserved;
|
||||
uint64_t sadb_ident_id;
|
||||
};
|
||||
|
||||
struct sadb_sens {
|
||||
uint16_t sadb_sens_len;
|
||||
uint16_t sadb_sens_exttype;
|
||||
uint32_t sadb_sens_dpd;
|
||||
uint8_t sadb_sens_sens_level;
|
||||
uint8_t sadb_sens_sens_len;
|
||||
uint8_t sadb_sens_integ_level;
|
||||
uint8_t sadb_sens_integ_len;
|
||||
uint32_t sadb_sens_reserved;
|
||||
};
|
||||
|
||||
struct sadb_prop {
|
||||
uint16_t sadb_prop_len;
|
||||
uint16_t sadb_prop_exttype;
|
||||
uint8_t sadb_prop_replay;
|
||||
uint8_t sadb_prop_reserved[3];
|
||||
};
|
||||
|
||||
struct sadb_comb {
|
||||
uint8_t sadb_comb_auth;
|
||||
uint8_t sadb_comb_encrypt;
|
||||
uint16_t sadb_comb_flags;
|
||||
uint16_t sadb_comb_auth_minbits;
|
||||
uint16_t sadb_comb_auth_maxbits;
|
||||
uint16_t sadb_comb_encrypt_minbits;
|
||||
uint16_t sadb_comb_encrypt_maxbits;
|
||||
uint32_t sadb_comb_reserved;
|
||||
uint32_t sadb_comb_soft_allocations;
|
||||
uint32_t sadb_comb_hard_allocations;
|
||||
uint64_t sadb_comb_soft_bytes;
|
||||
uint64_t sadb_comb_hard_bytes;
|
||||
uint64_t sadb_comb_soft_addtime;
|
||||
uint64_t sadb_comb_hard_addtime;
|
||||
uint64_t sadb_comb_soft_usetime;
|
||||
uint64_t sadb_comb_hard_usetime;
|
||||
uint32_t sadb_x_comb_soft_packets;
|
||||
uint32_t sadb_x_comb_hard_packets;
|
||||
};
|
||||
|
||||
struct sadb_supported {
|
||||
uint16_t sadb_supported_len;
|
||||
uint16_t sadb_supported_exttype;
|
||||
uint32_t sadb_supported_reserved;
|
||||
};
|
||||
|
||||
struct sadb_alg {
|
||||
uint8_t sadb_alg_id;
|
||||
uint8_t sadb_alg_ivlen;
|
||||
uint16_t sadb_alg_minbits;
|
||||
uint16_t sadb_alg_maxbits;
|
||||
uint16_t sadb_alg_reserved;
|
||||
};
|
||||
|
||||
struct sadb_spirange {
|
||||
uint16_t sadb_spirange_len;
|
||||
uint16_t sadb_spirange_exttype;
|
||||
uint32_t sadb_spirange_min;
|
||||
uint32_t sadb_spirange_max;
|
||||
uint32_t sadb_spirange_reserved;
|
||||
};
|
||||
|
||||
struct sadb_x_kmprivate {
|
||||
uint16_t sadb_x_kmprivate_len;
|
||||
uint16_t sadb_x_kmprivate_exttype;
|
||||
uint32_t sadb_x_kmprivate_reserved;
|
||||
};
|
||||
|
||||
struct sadb_x_satype {
|
||||
uint16_t sadb_x_satype_len;
|
||||
uint16_t sadb_x_satype_exttype;
|
||||
uint8_t sadb_x_satype_satype;
|
||||
uint8_t sadb_x_satype_reserved[3];
|
||||
};
|
||||
|
||||
struct sadb_x_debug {
|
||||
uint16_t sadb_x_debug_len;
|
||||
uint16_t sadb_x_debug_exttype;
|
||||
uint32_t sadb_x_debug_tunnel;
|
||||
uint32_t sadb_x_debug_netlink;
|
||||
uint32_t sadb_x_debug_xform;
|
||||
uint32_t sadb_x_debug_eroute;
|
||||
uint32_t sadb_x_debug_spi;
|
||||
uint32_t sadb_x_debug_radij;
|
||||
uint32_t sadb_x_debug_esp;
|
||||
uint32_t sadb_x_debug_ah;
|
||||
uint32_t sadb_x_debug_rcv;
|
||||
uint32_t sadb_x_debug_pfkey;
|
||||
uint32_t sadb_x_debug_ipcomp;
|
||||
uint32_t sadb_x_debug_verbose;
|
||||
uint8_t sadb_x_debug_reserved[4];
|
||||
};
|
||||
|
||||
struct sadb_x_nat_t_type {
|
||||
uint16_t sadb_x_nat_t_type_len;
|
||||
uint16_t sadb_x_nat_t_type_exttype;
|
||||
uint8_t sadb_x_nat_t_type_type;
|
||||
uint8_t sadb_x_nat_t_type_reserved[3];
|
||||
};
|
||||
struct sadb_x_nat_t_port {
|
||||
uint16_t sadb_x_nat_t_port_len;
|
||||
uint16_t sadb_x_nat_t_port_exttype;
|
||||
uint16_t sadb_x_nat_t_port_port;
|
||||
uint16_t sadb_x_nat_t_port_reserved;
|
||||
};
|
||||
|
||||
/*
|
||||
* A protocol structure for passing through the transport level
|
||||
* protocol. It contains more fields than are actually used/needed
|
||||
* but it is this way to be compatible with the structure used in
|
||||
* OpenBSD (http://www.openbsd.org/cgi-bin/cvsweb/src/sys/net/pfkeyv2.h)
|
||||
*/
|
||||
struct sadb_protocol {
|
||||
uint16_t sadb_protocol_len;
|
||||
uint16_t sadb_protocol_exttype;
|
||||
uint8_t sadb_protocol_proto;
|
||||
uint8_t sadb_protocol_direction;
|
||||
uint8_t sadb_protocol_flags;
|
||||
uint8_t sadb_protocol_reserved2;
|
||||
};
|
||||
|
||||
#define SADB_EXT_RESERVED 0
|
||||
#define SADB_EXT_SA 1
|
||||
#define SADB_EXT_LIFETIME_CURRENT 2
|
||||
#define SADB_EXT_LIFETIME_HARD 3
|
||||
#define SADB_EXT_LIFETIME_SOFT 4
|
||||
#define SADB_EXT_ADDRESS_SRC 5
|
||||
#define SADB_EXT_ADDRESS_DST 6
|
||||
#define SADB_EXT_ADDRESS_PROXY 7
|
||||
#define SADB_EXT_KEY_AUTH 8
|
||||
#define SADB_EXT_KEY_ENCRYPT 9
|
||||
#define SADB_EXT_IDENTITY_SRC 10
|
||||
#define SADB_EXT_IDENTITY_DST 11
|
||||
#define SADB_EXT_SENSITIVITY 12
|
||||
#define SADB_EXT_PROPOSAL 13
|
||||
#define SADB_EXT_SUPPORTED_AUTH 14
|
||||
#define SADB_EXT_SUPPORTED_ENCRYPT 15
|
||||
#define SADB_EXT_SPIRANGE 16
|
||||
#define SADB_X_EXT_KMPRIVATE 17
|
||||
#define SADB_X_EXT_SATYPE2 18
|
||||
#define SADB_X_EXT_SA2 19
|
||||
#define SADB_X_EXT_ADDRESS_DST2 20
|
||||
#define SADB_X_EXT_ADDRESS_SRC_FLOW 21
|
||||
#define SADB_X_EXT_ADDRESS_DST_FLOW 22
|
||||
#define SADB_X_EXT_ADDRESS_SRC_MASK 23
|
||||
#define SADB_X_EXT_ADDRESS_DST_MASK 24
|
||||
#define SADB_X_EXT_DEBUG 25
|
||||
#define SADB_X_EXT_PROTOCOL 26
|
||||
#define SADB_X_EXT_NAT_T_TYPE 27
|
||||
#define SADB_X_EXT_NAT_T_SPORT 28
|
||||
#define SADB_X_EXT_NAT_T_DPORT 29
|
||||
#define SADB_X_EXT_NAT_T_OA 30
|
||||
#define SADB_EXT_MAX 30
|
||||
|
||||
/* SADB_X_DELFLOW required over and above SADB_X_SAFLAGS_CLEARFLOW */
|
||||
#define SADB_X_EXT_ADDRESS_DELFLOW \
|
||||
( (1<<SADB_X_EXT_ADDRESS_SRC_FLOW) \
|
||||
| (1<<SADB_X_EXT_ADDRESS_DST_FLOW) \
|
||||
| (1<<SADB_X_EXT_ADDRESS_SRC_MASK) \
|
||||
| (1<<SADB_X_EXT_ADDRESS_DST_MASK))
|
||||
|
||||
#define SADB_SATYPE_UNSPEC 0
|
||||
#define SADB_SATYPE_AH 2
|
||||
#define SADB_SATYPE_ESP 3
|
||||
#define SADB_SATYPE_RSVP 5
|
||||
#define SADB_SATYPE_OSPFV2 6
|
||||
#define SADB_SATYPE_RIPV2 7
|
||||
#define SADB_SATYPE_MIP 8
|
||||
#define SADB_X_SATYPE_IPIP 9
|
||||
#define SADB_X_SATYPE_COMP 10
|
||||
#define SADB_X_SATYPE_INT 11
|
||||
#define SADB_SATYPE_MAX 11
|
||||
|
||||
#define SADB_SASTATE_LARVAL 0
|
||||
#define SADB_SASTATE_MATURE 1
|
||||
#define SADB_SASTATE_DYING 2
|
||||
#define SADB_SASTATE_DEAD 3
|
||||
#define SADB_SASTATE_MAX 3
|
||||
|
||||
#define SADB_SAFLAGS_PFS 1
|
||||
#define SADB_X_SAFLAGS_REPLACEFLOW 2
|
||||
#define SADB_X_SAFLAGS_CLEARFLOW 4
|
||||
#define SADB_X_SAFLAGS_INFLOW 8
|
||||
|
||||
#define SADB_AALG_NONE 0
|
||||
#define SADB_AALG_MD5HMAC 2
|
||||
#define SADB_AALG_SHA1HMAC 3
|
||||
#define SADB_AALG_SHA256_HMAC 5
|
||||
#define SADB_AALG_SHA384_HMAC 6
|
||||
#define SADB_AALG_SHA512_HMAC 7
|
||||
#define SADB_AALG_RIPEMD160HMAC 8
|
||||
#define SADB_AALG_MAX 15
|
||||
|
||||
#define SADB_EALG_NONE 0
|
||||
#define SADB_EALG_DESCBC 2
|
||||
#define SADB_EALG_3DESCBC 3
|
||||
#define SADB_EALG_BFCBC 7
|
||||
#define SADB_EALG_NULL 11
|
||||
#define SADB_EALG_AESCBC 12
|
||||
#define SADB_EALG_MAX 255
|
||||
|
||||
#define SADB_X_CALG_NONE 0
|
||||
#define SADB_X_CALG_OUI 1
|
||||
#define SADB_X_CALG_DEFLATE 2
|
||||
#define SADB_X_CALG_LZS 3
|
||||
#define SADB_X_CALG_V42BIS 4
|
||||
#define SADB_X_CALG_MAX 4
|
||||
|
||||
#define SADB_X_TALG_NONE 0
|
||||
#define SADB_X_TALG_IPv4_in_IPv4 1
|
||||
#define SADB_X_TALG_IPv6_in_IPv4 2
|
||||
#define SADB_X_TALG_IPv4_in_IPv6 3
|
||||
#define SADB_X_TALG_IPv6_in_IPv6 4
|
||||
#define SADB_X_TALG_MAX 4
|
||||
|
||||
|
||||
#define SADB_IDENTTYPE_RESERVED 0
|
||||
#define SADB_IDENTTYPE_PREFIX 1
|
||||
#define SADB_IDENTTYPE_FQDN 2
|
||||
#define SADB_IDENTTYPE_USERFQDN 3
|
||||
#define SADB_X_IDENTTYPE_CONNECTION 4
|
||||
#define SADB_IDENTTYPE_MAX 4
|
||||
|
||||
#define SADB_KEY_FLAGS_MAX 0
|
||||
#endif /* __PFKEY_V2_H */
|
||||
@@ -23,11 +23,12 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <linux/ipsec.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/xfrm.h>
|
||||
#include <linux/udp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
@@ -51,6 +52,11 @@
|
||||
#define XFRM_STATE_AF_UNSPEC 32
|
||||
#endif
|
||||
|
||||
/** from linux/in.h */
|
||||
#ifndef IP_IPSEC_POLICY
|
||||
#define IP_IPSEC_POLICY 16
|
||||
#endif
|
||||
|
||||
/** default priority of installed policies */
|
||||
#define PRIO_LOW 3000
|
||||
#define PRIO_HIGH 2000
|
||||
@@ -849,8 +855,8 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
|
||||
u_int64_t expire_soft, u_int64_t expire_hard,
|
||||
u_int16_t enc_alg, chunk_t enc_key,
|
||||
u_int16_t int_alg, chunk_t int_key,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, bool encap,
|
||||
bool replace)
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool encap, bool inbound)
|
||||
{
|
||||
unsigned char request[NETLINK_BUFFER_SIZE];
|
||||
char *alg_name;
|
||||
@@ -858,6 +864,17 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
|
||||
struct xfrm_usersa_info *sa;
|
||||
u_int16_t icv_size = 64;
|
||||
|
||||
/* if IPComp is used, we install an additional IPComp SA. if the cpi is 0
|
||||
* we are in the recursive call below */
|
||||
if (ipcomp != IPCOMP_NONE && cpi != 0)
|
||||
{
|
||||
this->public.interface.add_sa(&this->public.interface,
|
||||
src, dst, htonl(ntohs(cpi)), IPPROTO_COMP, reqid, 0, 0,
|
||||
ENCR_UNDEFINED, chunk_empty, AUTH_UNDEFINED, chunk_empty,
|
||||
mode, ipcomp, 0, FALSE, inbound);
|
||||
ipcomp = IPCOMP_NONE;
|
||||
}
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
|
||||
DBG2(DBG_KNL, "adding SAD entry with SPI %.8x and reqid {%u}",
|
||||
@@ -865,7 +882,7 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
|
||||
|
||||
hdr = (struct nlmsghdr*)request;
|
||||
hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
|
||||
hdr->nlmsg_type = replace ? XFRM_MSG_UPDSA : XFRM_MSG_NEWSA;
|
||||
hdr->nlmsg_type = inbound ? XFRM_MSG_UPDSA : XFRM_MSG_NEWSA;
|
||||
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_info));
|
||||
|
||||
sa = (struct xfrm_usersa_info*)NLMSG_DATA(hdr);
|
||||
@@ -1149,9 +1166,10 @@ static status_t get_replay_state(private_kernel_netlink_ipsec_t *this,
|
||||
* Implementation of kernel_interface_t.update_sa.
|
||||
*/
|
||||
static status_t update_sa(private_kernel_netlink_ipsec_t *this,
|
||||
u_int32_t spi, protocol_id_t protocol,
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
|
||||
host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap)
|
||||
host_t *new_src, host_t *new_dst,
|
||||
bool encap, bool new_encap)
|
||||
{
|
||||
unsigned char request[NETLINK_BUFFER_SIZE], *pos;
|
||||
struct nlmsghdr *hdr, *out = NULL;
|
||||
@@ -1164,6 +1182,14 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
|
||||
bool got_replay_state;
|
||||
struct xfrm_replay_state replay;
|
||||
|
||||
/* if IPComp is used, we first update the IPComp SA */
|
||||
if (cpi)
|
||||
{
|
||||
this->public.interface.update_sa(&this->public.interface,
|
||||
htonl(ntohs(cpi)), IPPROTO_COMP, 0,
|
||||
src, dst, new_src, new_dst, FALSE, FALSE);
|
||||
}
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
|
||||
DBG2(DBG_KNL, "querying SAD entry with SPI %.8x for update", ntohl(spi));
|
||||
@@ -1219,8 +1245,9 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
|
||||
got_replay_state = (get_replay_state(
|
||||
this, spi, protocol, dst, &replay) == SUCCESS);
|
||||
|
||||
/* delete the old SA */
|
||||
if (this->public.interface.del_sa(&this->public.interface, dst, spi, protocol) != SUCCESS)
|
||||
/* delete the old SA (without affecting the IPComp SA) */
|
||||
if (this->public.interface.del_sa(&this->public.interface, dst, spi,
|
||||
protocol, 0) != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to delete old SAD entry with SPI %.8x", ntohl(spi));
|
||||
free(out);
|
||||
@@ -1320,12 +1347,19 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
|
||||
* Implementation of kernel_interface_t.del_sa.
|
||||
*/
|
||||
static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *dst,
|
||||
u_int32_t spi, protocol_id_t protocol)
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi)
|
||||
{
|
||||
unsigned char request[NETLINK_BUFFER_SIZE];
|
||||
struct nlmsghdr *hdr;
|
||||
struct xfrm_usersa_id *sa_id;
|
||||
|
||||
/* if IPComp was used, we first delete the additional IPComp SA */
|
||||
if (cpi)
|
||||
{
|
||||
this->public.interface.del_sa(&this->public.interface, dst,
|
||||
htonl(ntohs(cpi)), IPPROTO_COMP, 0);
|
||||
}
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
|
||||
DBG2(DBG_KNL, "deleting SAD entry with SPI %.8x", ntohl(spi));
|
||||
@@ -1357,9 +1391,10 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
|
||||
host_t *src, host_t *dst,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction, protocol_id_t protocol,
|
||||
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
|
||||
u_int16_t ipcomp)
|
||||
policy_dir_t direction, u_int32_t spi,
|
||||
protocol_id_t protocol, u_int32_t reqid,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool routed)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
policy_entry_t *current, *policy;
|
||||
@@ -1413,7 +1448,7 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
|
||||
policy_info->sel = policy->sel;
|
||||
policy_info->dir = policy->direction;
|
||||
/* calculate priority based on source selector size, small size = high prio */
|
||||
policy_info->priority = high_prio ? PRIO_HIGH : PRIO_LOW;
|
||||
policy_info->priority = routed ? PRIO_LOW : PRIO_HIGH;
|
||||
policy_info->priority -= policy->sel.prefixlen_s * 10;
|
||||
policy_info->priority -= policy->sel.proto ? 2 : 0;
|
||||
policy_info->priority -= policy->sel.sport_mask ? 1 : 0;
|
||||
@@ -1617,7 +1652,7 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
|
||||
static status_t del_policy(private_kernel_netlink_ipsec_t *this,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction)
|
||||
policy_dir_t direction, bool unrouted)
|
||||
{
|
||||
policy_entry_t *current, policy, *to_delete = NULL;
|
||||
route_entry_t *route;
|
||||
@@ -1714,6 +1749,67 @@ static void destroy(private_kernel_netlink_ipsec_t *this)
|
||||
free(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add bypass policies for IKE on the sockets used by charon
|
||||
*/
|
||||
static bool add_bypass_policies()
|
||||
{
|
||||
int fd, family, port;
|
||||
enumerator_t *sockets;
|
||||
|
||||
/* we open an AF_KEY socket to autoload the af_key module. Otherwise
|
||||
* setsockopt(IPSEC_POLICY) won't work. */
|
||||
fd = socket(AF_KEY, SOCK_RAW, PF_KEY_V2);
|
||||
if (fd == 0)
|
||||
{
|
||||
DBG1(DBG_KNL, "could not open AF_KEY socket");
|
||||
return FALSE;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
sockets = charon->socket->create_enumerator(charon->socket);
|
||||
while (sockets->enumerate(sockets, &fd, &family, &port))
|
||||
{
|
||||
struct sadb_x_policy policy;
|
||||
u_int sol, ipsec_policy;
|
||||
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
sol = SOL_IP;
|
||||
ipsec_policy = IP_IPSEC_POLICY;
|
||||
break;
|
||||
case AF_INET6:
|
||||
{
|
||||
sol = SOL_IPV6;
|
||||
ipsec_policy = IPV6_IPSEC_POLICY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&policy, 0, sizeof(policy));
|
||||
policy.sadb_x_policy_len = sizeof(policy) / sizeof(u_int64_t);
|
||||
policy.sadb_x_policy_exttype = SADB_X_EXT_POLICY;
|
||||
policy.sadb_x_policy_type = IPSEC_POLICY_BYPASS;
|
||||
|
||||
policy.sadb_x_policy_dir = IPSEC_DIR_OUTBOUND;
|
||||
if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
policy.sadb_x_policy_dir = IPSEC_DIR_INBOUND;
|
||||
if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
@@ -1725,12 +1821,12 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
|
||||
/* public functions */
|
||||
this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
|
||||
this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,host_t*,host_t*,host_t*,host_t*,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,protocol_id_t,u_int32_t,bool,ipsec_mode_t,u_int16_t))add_policy;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,u_int16_t,host_t*,host_t*,host_t*,host_t*,bool,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
|
||||
this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t))del_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
|
||||
this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
|
||||
|
||||
/* private members */
|
||||
@@ -1739,6 +1835,12 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
|
||||
this->install_routes = lib->settings->get_bool(lib->settings,
|
||||
"charon.install_routes", TRUE);
|
||||
|
||||
/* add bypass policies on the sockets used by charon */
|
||||
if (!add_bypass_policies())
|
||||
{
|
||||
charon->kill(charon, "unable to add bypass policies on sockets");
|
||||
}
|
||||
|
||||
this->socket_xfrm = netlink_socket_create(NETLINK_XFRM);
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
#include <processing/jobs/delete_child_sa_job.h>
|
||||
#include <processing/jobs/update_sa_job.h>
|
||||
|
||||
/** from linux/in.h */
|
||||
#ifndef IP_IPSEC_POLICY
|
||||
#define IP_IPSEC_POLICY 16
|
||||
#endif
|
||||
|
||||
/** default priority of installed policies */
|
||||
#define PRIO_LOW 3000
|
||||
#define PRIO_HIGH 2000
|
||||
@@ -920,12 +925,12 @@ static void process_mapping(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in*)sa;
|
||||
sin->sin_port = response.x_natt_dport->sadb_x_nat_t_port_port;
|
||||
sin->sin_port = htons(response.x_natt_dport->sadb_x_nat_t_port_port);
|
||||
}
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
|
||||
sin6->sin6_port = response.x_natt_dport->sadb_x_nat_t_port_port;
|
||||
sin6->sin6_port = htons(response.x_natt_dport->sadb_x_nat_t_port_port);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -1098,8 +1103,8 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
u_int64_t expire_soft, u_int64_t expire_hard,
|
||||
u_int16_t enc_alg, chunk_t enc_key,
|
||||
u_int16_t int_alg, chunk_t int_key,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, bool encap,
|
||||
bool replace)
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool encap, bool inbound)
|
||||
{
|
||||
unsigned char request[PFKEY_BUFFER_SIZE];
|
||||
struct sadb_msg *msg, *out;
|
||||
@@ -1116,7 +1121,7 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
|
||||
msg = (struct sadb_msg*)request;
|
||||
msg->sadb_msg_version = PF_KEY_V2;
|
||||
msg->sadb_msg_type = replace ? SADB_UPDATE : SADB_ADD;
|
||||
msg->sadb_msg_type = inbound ? SADB_UPDATE : SADB_ADD;
|
||||
msg->sadb_msg_satype = proto_ike2satype(protocol);
|
||||
msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
|
||||
|
||||
@@ -1229,9 +1234,10 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
* Implementation of kernel_interface_t.update_sa.
|
||||
*/
|
||||
static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
u_int32_t spi, protocol_id_t protocol,
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
|
||||
host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap)
|
||||
host_t *new_src, host_t *new_dst,
|
||||
bool encap, bool new_encap)
|
||||
{
|
||||
unsigned char request[PFKEY_BUFFER_SIZE];
|
||||
struct sadb_msg *msg, *out;
|
||||
@@ -1240,6 +1246,17 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
pfkey_msg_t response;
|
||||
size_t len;
|
||||
|
||||
/* we can't update the SA if any of the ip addresses have changed.
|
||||
* that's because we can't use SADB_UPDATE and by deleting and readding the
|
||||
* SA the sequence numbers would get lost */
|
||||
if (!src->ip_equals(src, new_src) ||
|
||||
!dst->ip_equals(dst, new_dst))
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to update SAD entry with SPI %.8x: address changes"
|
||||
" are not supported", ntohl(spi));
|
||||
return NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
|
||||
DBG2(DBG_KNL, "querying SAD entry with SPI %.8x", ntohl(spi));
|
||||
@@ -1289,14 +1306,6 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
/* delete the old SA */
|
||||
if (this->public.interface.del_sa(&this->public.interface, dst, spi, protocol) != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to delete old SAD entry with SPI %.8x", ntohl(spi));
|
||||
free(out);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
DBG2(DBG_KNL, "updating SAD entry with SPI %.8x from %#H..%#H to %#H..%#H",
|
||||
ntohl(spi), src, dst, new_src, new_dst);
|
||||
|
||||
@@ -1304,22 +1313,15 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
|
||||
msg = (struct sadb_msg*)request;
|
||||
msg->sadb_msg_version = PF_KEY_V2;
|
||||
msg->sadb_msg_type = SADB_ADD;
|
||||
msg->sadb_msg_type = SADB_UPDATE;
|
||||
msg->sadb_msg_satype = proto_ike2satype(protocol);
|
||||
msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
|
||||
|
||||
PFKEY_EXT_COPY(msg, response.sa);
|
||||
PFKEY_EXT_COPY(msg, response.x_sa2);
|
||||
|
||||
addr = (struct sadb_address*)PFKEY_EXT_ADD_NEXT(msg);
|
||||
addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
|
||||
host2ext(new_src, addr);
|
||||
PFKEY_EXT_ADD(msg, addr);
|
||||
|
||||
addr = (struct sadb_address*)PFKEY_EXT_ADD_NEXT(msg);
|
||||
addr->sadb_address_exttype = SADB_EXT_ADDRESS_DST;
|
||||
host2ext(new_dst, addr);
|
||||
PFKEY_EXT_ADD(msg, addr);
|
||||
PFKEY_EXT_COPY(msg, response.src);
|
||||
PFKEY_EXT_COPY(msg, response.dst);
|
||||
|
||||
PFKEY_EXT_COPY(msg, response.lft_soft);
|
||||
PFKEY_EXT_COPY(msg, response.lft_hard);
|
||||
@@ -1362,7 +1364,7 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
|
||||
* Implementation of kernel_interface_t.del_sa.
|
||||
*/
|
||||
static status_t del_sa(private_kernel_pfkey_ipsec_t *this, host_t *dst,
|
||||
u_int32_t spi, protocol_id_t protocol)
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi)
|
||||
{
|
||||
unsigned char request[PFKEY_BUFFER_SIZE];
|
||||
struct sadb_msg *msg, *out;
|
||||
@@ -1423,9 +1425,10 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
|
||||
host_t *src, host_t *dst,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction, protocol_id_t protocol,
|
||||
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
|
||||
u_int16_t ipcomp)
|
||||
policy_dir_t direction, u_int32_t spi,
|
||||
protocol_id_t protocol, u_int32_t reqid,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool routed)
|
||||
{
|
||||
unsigned char request[PFKEY_BUFFER_SIZE];
|
||||
struct sadb_msg *msg, *out;
|
||||
@@ -1476,7 +1479,7 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
|
||||
pol->sadb_x_policy_id = 0;
|
||||
pol->sadb_x_policy_dir = dir2kernel(direction);
|
||||
/* calculate priority based on source selector size, small size = high prio */
|
||||
pol->sadb_x_policy_priority = high_prio ? PRIO_HIGH : PRIO_LOW;
|
||||
pol->sadb_x_policy_priority = routed ? PRIO_LOW : PRIO_HIGH;
|
||||
pol->sadb_x_policy_priority -= policy->src.mask * 10;
|
||||
pol->sadb_x_policy_priority -= policy->src.proto != IPSEC_PROTO_ANY ? 2 : 0;
|
||||
pol->sadb_x_policy_priority -= policy->src.net->get_port(policy->src.net) ? 1 : 0;
|
||||
@@ -1713,7 +1716,7 @@ static status_t query_policy(private_kernel_pfkey_ipsec_t *this,
|
||||
static status_t del_policy(private_kernel_pfkey_ipsec_t *this,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction)
|
||||
policy_dir_t direction, bool unrouted)
|
||||
{
|
||||
unsigned char request[PFKEY_BUFFER_SIZE];
|
||||
struct sadb_msg *msg, *out;
|
||||
@@ -1869,6 +1872,57 @@ static void destroy(private_kernel_pfkey_ipsec_t *this)
|
||||
free(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add bypass policies for IKE on the sockets of charon
|
||||
*/
|
||||
static bool add_bypass_policies(private_kernel_pfkey_ipsec_t *this)
|
||||
{
|
||||
int fd, family, port;
|
||||
enumerator_t *sockets;
|
||||
|
||||
sockets = charon->socket->create_enumerator(charon->socket);
|
||||
while (sockets->enumerate(sockets, &fd, &family, &port))
|
||||
{
|
||||
struct sadb_x_policy policy;
|
||||
u_int sol, ipsec_policy;
|
||||
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
sol = SOL_IP;
|
||||
ipsec_policy = IP_IPSEC_POLICY;
|
||||
break;
|
||||
case AF_INET6:
|
||||
{
|
||||
sol = SOL_IPV6;
|
||||
ipsec_policy = IPV6_IPSEC_POLICY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&policy, 0, sizeof(policy));
|
||||
policy.sadb_x_policy_len = sizeof(policy) / sizeof(u_int64_t);
|
||||
policy.sadb_x_policy_exttype = SADB_X_EXT_POLICY;
|
||||
policy.sadb_x_policy_type = IPSEC_POLICY_BYPASS;
|
||||
|
||||
policy.sadb_x_policy_dir = IPSEC_DIR_OUTBOUND;
|
||||
if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
policy.sadb_x_policy_dir = IPSEC_DIR_INBOUND;
|
||||
if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
@@ -1879,12 +1933,12 @@ kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
|
||||
/* public functions */
|
||||
this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
|
||||
this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,host_t*,host_t*,host_t*,host_t*,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,protocol_id_t,u_int32_t,bool,ipsec_mode_t,u_int16_t))add_policy;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,u_int16_t,host_t*,host_t*,host_t*,host_t*,bool,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
|
||||
this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t))del_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
|
||||
|
||||
this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
|
||||
|
||||
@@ -1910,6 +1964,12 @@ kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
|
||||
charon->kill(charon, "unable to create PF_KEY event socket");
|
||||
}
|
||||
|
||||
/* add bypass policies on the sockets used by charon */
|
||||
if (!add_bypass_policies(this))
|
||||
{
|
||||
charon->kill(charon, "unable to add bypass policies on sockets");
|
||||
}
|
||||
|
||||
/* register the event socket */
|
||||
if (register_pfkey_socket(this, SADB_SATYPE_ESP) != SUCCESS ||
|
||||
register_pfkey_socket(this, SADB_SATYPE_AH) != SUCCESS)
|
||||
|
||||
@@ -67,8 +67,8 @@ static status_t add_sa(private_load_tester_ipsec_t *this,
|
||||
u_int64_t expire_soft, u_int64_t expire_hard,
|
||||
u_int16_t enc_alg, chunk_t enc_key,
|
||||
u_int16_t int_alg, chunk_t int_key,
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, bool encap,
|
||||
bool replace)
|
||||
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
|
||||
bool encap, bool inbound)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -77,9 +77,10 @@ static status_t add_sa(private_load_tester_ipsec_t *this,
|
||||
* Implementation of kernel_interface_t.update_sa.
|
||||
*/
|
||||
static status_t update_sa(private_load_tester_ipsec_t *this,
|
||||
u_int32_t spi, protocol_id_t protocol,
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
|
||||
host_t *src, host_t *dst,
|
||||
host_t *new_src, host_t *new_dst, bool encap)
|
||||
host_t *new_src, host_t *new_dst,
|
||||
bool encap, bool new_encap)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -88,7 +89,7 @@ static status_t update_sa(private_load_tester_ipsec_t *this,
|
||||
* Implementation of kernel_interface_t.del_sa.
|
||||
*/
|
||||
static status_t del_sa(private_load_tester_ipsec_t *this, host_t *dst,
|
||||
u_int32_t spi, protocol_id_t protocol)
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -101,8 +102,8 @@ static status_t add_policy(private_load_tester_ipsec_t *this,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction, protocol_id_t protocol,
|
||||
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
|
||||
u_int16_t ipcomp)
|
||||
u_int32_t reqid, ipsec_mode_t mode, u_int16_t ipcomp,
|
||||
u_int16_t cpi, bool routed)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -125,7 +126,7 @@ static status_t query_policy(private_load_tester_ipsec_t *this,
|
||||
static status_t del_policy(private_load_tester_ipsec_t *this,
|
||||
traffic_selector_t *src_ts,
|
||||
traffic_selector_t *dst_ts,
|
||||
policy_dir_t direction)
|
||||
policy_dir_t direction, bool unrouted)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -148,12 +149,12 @@ load_tester_ipsec_t *load_tester_ipsec_create()
|
||||
/* public functions */
|
||||
this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
|
||||
this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,host_t*,host_t*,host_t*,host_t*,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,protocol_id_t,u_int32_t,bool,ipsec_mode_t,u_int16_t))add_policy;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,u_int16_t,host_t*,host_t*,host_t*,host_t*,bool,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
|
||||
this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t))del_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
|
||||
this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
|
||||
|
||||
this->spi = 0;
|
||||
|
||||
@@ -25,4 +25,4 @@ EXTRA_DIST = gnome/configure gnome/po/LINGUAS gnome/po/POTFILES.in gnome/po/Make
|
||||
gnome/config.sub gnome/missing
|
||||
|
||||
gnome/configure : gnome/configure.in
|
||||
cd gnome && ./autogen.sh; cd ..
|
||||
(cd `dirname $<` && ./autogen.sh)
|
||||
|
||||
+52
-66
@@ -30,6 +30,7 @@
|
||||
ENUM(child_sa_state_names, CHILD_CREATED, CHILD_DESTROYING,
|
||||
"CREATED",
|
||||
"ROUTED",
|
||||
"INSTALLING",
|
||||
"INSTALLED",
|
||||
"UPDATING",
|
||||
"REKEYING",
|
||||
@@ -444,7 +445,7 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal,
|
||||
ipsec_mode_t mode, chunk_t integ, chunk_t encr, bool in)
|
||||
{
|
||||
u_int16_t enc_alg = ENCR_UNDEFINED, int_alg = AUTH_UNDEFINED, size;
|
||||
u_int32_t spi, cpi, soft, hard, now;
|
||||
u_int32_t spi, soft, hard, now;
|
||||
host_t *src, *dst;
|
||||
status_t status;
|
||||
|
||||
@@ -461,7 +462,7 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal,
|
||||
if (this->alloc_ah_spi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->my_addr, this->alloc_ah_spi, PROTO_AH);
|
||||
this->my_addr, this->alloc_ah_spi, 0, PROTO_AH);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -470,7 +471,7 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal,
|
||||
if (this->alloc_esp_spi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->my_addr, this->alloc_esp_spi, PROTO_ESP);
|
||||
this->my_addr, this->alloc_esp_spi, 0, PROTO_ESP);
|
||||
}
|
||||
}
|
||||
spi = this->my_spi;
|
||||
@@ -491,16 +492,6 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal,
|
||||
/* send SA down to the kernel */
|
||||
DBG2(DBG_CHD, " SPI 0x%.8x, src %H dst %H", ntohl(spi), src, dst);
|
||||
|
||||
if (this->ipcomp != IPCOMP_NONE)
|
||||
{
|
||||
/* we install an additional IPComp SA */
|
||||
cpi = htonl(ntohs(in ? this->my_cpi : this->other_cpi));
|
||||
charon->kernel_interface->add_sa(charon->kernel_interface,
|
||||
src, dst, cpi, IPPROTO_COMP, this->reqid, 0, 0,
|
||||
ENCR_UNDEFINED, chunk_empty, AUTH_UNDEFINED, chunk_empty,
|
||||
mode, this->ipcomp, FALSE, in);
|
||||
}
|
||||
|
||||
proposal->get_algorithm(proposal, ENCRYPTION_ALGORITHM, &enc_alg, &size);
|
||||
proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM, &int_alg, &size);
|
||||
|
||||
@@ -509,7 +500,8 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal,
|
||||
status = charon->kernel_interface->add_sa(charon->kernel_interface,
|
||||
src, dst, spi, this->protocol, this->reqid,
|
||||
in ? soft : 0, hard, enc_alg, encr, int_alg, integ,
|
||||
mode, IPCOMP_NONE, this->encap, in);
|
||||
mode, this->ipcomp, in ? this->my_cpi : this->other_cpi,
|
||||
this->encap, in);
|
||||
|
||||
now = time(NULL);
|
||||
this->rekey_time = now + soft;
|
||||
@@ -588,12 +580,8 @@ static status_t add_policies(private_child_sa_t *this,
|
||||
enumerator_t *enumerator;
|
||||
traffic_selector_t *my_ts, *other_ts;
|
||||
status_t status = SUCCESS;
|
||||
bool high_prio = TRUE;
|
||||
bool routed = (this->state == CHILD_CREATED);
|
||||
|
||||
if (this->state == CHILD_CREATED)
|
||||
{ /* use low prio for ROUTED policies */
|
||||
high_prio = FALSE;
|
||||
}
|
||||
if (this->protocol == PROTO_NONE)
|
||||
{ /* update if not set yet */
|
||||
this->protocol = proto;
|
||||
@@ -622,17 +610,20 @@ static status_t add_policies(private_child_sa_t *this,
|
||||
/* install 3 policies: out, in and forward */
|
||||
status |= charon->kernel_interface->add_policy(charon->kernel_interface,
|
||||
this->my_addr, this->other_addr, my_ts, other_ts, POLICY_OUT,
|
||||
this->protocol, this->reqid, high_prio, mode, this->ipcomp);
|
||||
|
||||
this->other_spi, this->protocol, this->reqid, mode, this->ipcomp,
|
||||
this->other_cpi, routed);
|
||||
|
||||
status |= charon->kernel_interface->add_policy(charon->kernel_interface,
|
||||
this->other_addr, this->my_addr, other_ts, my_ts, POLICY_IN,
|
||||
this->protocol, this->reqid, high_prio, mode, this->ipcomp);
|
||||
this->my_spi, this->protocol, this->reqid, mode, this->ipcomp,
|
||||
this->my_cpi, routed);
|
||||
|
||||
if (mode == MODE_TUNNEL)
|
||||
{
|
||||
status |= charon->kernel_interface->add_policy(charon->kernel_interface,
|
||||
this->other_addr, this->my_addr, other_ts, my_ts, POLICY_FWD,
|
||||
this->protocol, this->reqid, high_prio, mode, this->ipcomp);
|
||||
this->other_addr, this->my_addr, other_ts, my_ts, POLICY_FWD,
|
||||
this->my_spi, this->protocol, this->reqid, mode, this->ipcomp,
|
||||
this->my_cpi, routed);
|
||||
}
|
||||
|
||||
if (status != SUCCESS)
|
||||
@@ -682,26 +673,23 @@ static status_t update_hosts(private_child_sa_t *this,
|
||||
old = this->state;
|
||||
set_state(this, CHILD_UPDATING);
|
||||
|
||||
this->encap = encap;
|
||||
|
||||
if (this->ipcomp != IPCOMP_NONE)
|
||||
/* update our (initator) SA */
|
||||
if (charon->kernel_interface->update_sa(charon->kernel_interface, this->my_spi,
|
||||
this->protocol, this->ipcomp != IPCOMP_NONE ? this->my_cpi : 0,
|
||||
this->other_addr, this->my_addr, other, me,
|
||||
this->encap, encap) == NOT_SUPPORTED)
|
||||
{
|
||||
/* update our (initator) IPComp SA */
|
||||
charon->kernel_interface->update_sa(charon->kernel_interface,
|
||||
htonl(ntohs(this->my_cpi)), IPPROTO_COMP,
|
||||
this->other_addr, this->my_addr, other, me, FALSE);
|
||||
/* update his (responder) IPComp SA */
|
||||
charon->kernel_interface->update_sa(charon->kernel_interface,
|
||||
htonl(ntohs(this->other_cpi)), IPPROTO_COMP,
|
||||
this->my_addr, this->other_addr, me, other, FALSE);
|
||||
return NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* update our (initator) SA */
|
||||
charon->kernel_interface->update_sa(charon->kernel_interface, this->my_spi,
|
||||
this->protocol, this->other_addr, this->my_addr, other, me, encap);
|
||||
/* update his (responder) SA */
|
||||
charon->kernel_interface->update_sa(charon->kernel_interface, this->other_spi,
|
||||
this->protocol, this->my_addr, this->other_addr, me, other, encap);
|
||||
if (charon->kernel_interface->update_sa(charon->kernel_interface, this->other_spi,
|
||||
this->protocol, this->ipcomp != IPCOMP_NONE ? this->other_cpi : 0,
|
||||
this->my_addr, this->other_addr, me, other,
|
||||
this->encap, encap) == NOT_SUPPORTED)
|
||||
{
|
||||
return NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (this->config->install_policy(this->config))
|
||||
{
|
||||
@@ -718,13 +706,13 @@ static status_t update_hosts(private_child_sa_t *this,
|
||||
{
|
||||
/* remove old policies first */
|
||||
charon->kernel_interface->del_policy(charon->kernel_interface,
|
||||
my_ts, other_ts, POLICY_OUT);
|
||||
my_ts, other_ts, POLICY_OUT, FALSE);
|
||||
charon->kernel_interface->del_policy(charon->kernel_interface,
|
||||
other_ts, my_ts, POLICY_IN);
|
||||
other_ts, my_ts, POLICY_IN, FALSE);
|
||||
if (this->mode == MODE_TUNNEL)
|
||||
{
|
||||
charon->kernel_interface->del_policy(charon->kernel_interface,
|
||||
other_ts, my_ts, POLICY_FWD);
|
||||
other_ts, my_ts, POLICY_FWD, FALSE);
|
||||
}
|
||||
|
||||
/* check whether we have to update a "dynamic" traffic selector */
|
||||
@@ -749,16 +737,19 @@ static status_t update_hosts(private_child_sa_t *this,
|
||||
|
||||
/* reinstall updated policies */
|
||||
charon->kernel_interface->add_policy(charon->kernel_interface,
|
||||
me, other, my_ts, other_ts, POLICY_OUT, this->protocol,
|
||||
this->reqid, TRUE, this->mode, this->ipcomp);
|
||||
me, other, my_ts, other_ts, POLICY_OUT, this->other_spi,
|
||||
this->protocol, this->reqid, this->mode, this->ipcomp,
|
||||
this->other_cpi, FALSE);
|
||||
charon->kernel_interface->add_policy(charon->kernel_interface,
|
||||
other, me, other_ts, my_ts, POLICY_IN, this->protocol,
|
||||
this->reqid, TRUE, this->mode, this->ipcomp);
|
||||
other, me, other_ts, my_ts, POLICY_IN, this->my_spi,
|
||||
this->protocol, this->reqid, this->mode, this->ipcomp,
|
||||
this->my_cpi, FALSE);
|
||||
if (this->mode == MODE_TUNNEL)
|
||||
{
|
||||
charon->kernel_interface->add_policy(charon->kernel_interface,
|
||||
other, me, other_ts, my_ts, POLICY_FWD, this->protocol,
|
||||
this->reqid, TRUE, this->mode, this->ipcomp);
|
||||
other, me, other_ts, my_ts, POLICY_FWD, this->my_spi,
|
||||
this->protocol, this->reqid, this->mode, this->ipcomp,
|
||||
this->my_cpi, FALSE);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
@@ -779,6 +770,8 @@ static status_t update_hosts(private_child_sa_t *this,
|
||||
this->other_addr = other->clone(other);
|
||||
}
|
||||
}
|
||||
this->encap = encap;
|
||||
|
||||
set_state(this, old);
|
||||
|
||||
return SUCCESS;
|
||||
@@ -815,6 +808,7 @@ static void destroy(private_child_sa_t *this)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
traffic_selector_t *my_ts, *other_ts;
|
||||
bool unrouted = (this->state == CHILD_ROUTED);
|
||||
|
||||
set_state(this, CHILD_DESTROYING);
|
||||
|
||||
@@ -822,32 +816,24 @@ static void destroy(private_child_sa_t *this)
|
||||
if (this->my_spi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->my_addr, this->my_spi, this->protocol);
|
||||
this->my_addr, this->my_spi, this->protocol,
|
||||
this->my_cpi);
|
||||
}
|
||||
if (this->alloc_esp_spi && this->alloc_esp_spi != this->my_spi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->my_addr, this->alloc_esp_spi, PROTO_ESP);
|
||||
this->my_addr, this->alloc_esp_spi, PROTO_ESP, 0);
|
||||
}
|
||||
if (this->alloc_ah_spi && this->alloc_ah_spi != this->my_spi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->my_addr, this->alloc_ah_spi, PROTO_AH);
|
||||
this->my_addr, this->alloc_ah_spi, PROTO_AH, 0);
|
||||
}
|
||||
if (this->other_spi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->other_addr, this->other_spi, this->protocol);
|
||||
}
|
||||
if (this->my_cpi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->my_addr, htonl(ntohs(this->my_cpi)), IPPROTO_COMP);
|
||||
}
|
||||
if (this->other_cpi)
|
||||
{
|
||||
charon->kernel_interface->del_sa(charon->kernel_interface,
|
||||
this->other_addr, htonl(ntohs(this->other_cpi)), IPPROTO_COMP);
|
||||
this->other_addr, this->other_spi, this->protocol,
|
||||
this->other_cpi);
|
||||
}
|
||||
|
||||
if (this->config->install_policy(this->config))
|
||||
@@ -857,13 +843,13 @@ static void destroy(private_child_sa_t *this)
|
||||
while (enumerator->enumerate(enumerator, &my_ts, &other_ts))
|
||||
{
|
||||
charon->kernel_interface->del_policy(charon->kernel_interface,
|
||||
my_ts, other_ts, POLICY_OUT);
|
||||
my_ts, other_ts, POLICY_OUT, unrouted);
|
||||
charon->kernel_interface->del_policy(charon->kernel_interface,
|
||||
other_ts, my_ts, POLICY_IN);
|
||||
other_ts, my_ts, POLICY_IN, unrouted);
|
||||
if (this->mode == MODE_TUNNEL)
|
||||
{
|
||||
charon->kernel_interface->del_policy(charon->kernel_interface,
|
||||
other_ts, my_ts, POLICY_FWD);
|
||||
other_ts, my_ts, POLICY_FWD, unrouted);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
@@ -49,6 +49,11 @@ enum child_sa_state_t {
|
||||
*/
|
||||
CHILD_ROUTED,
|
||||
|
||||
/**
|
||||
* Installing an in-use CHILD_SA
|
||||
*/
|
||||
CHILD_INSTALLING,
|
||||
|
||||
/**
|
||||
* Installed an in-use CHILD_SA
|
||||
*/
|
||||
|
||||
@@ -898,8 +898,14 @@ static void update_hosts(private_ike_sa_t *this, host_t *me, host_t *other)
|
||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||
{
|
||||
child_sa->update_hosts(child_sa, this->my_host, this->other_host,
|
||||
this->my_virtual_ip, has_condition(this, COND_NAT_ANY));
|
||||
if (child_sa->update_hosts(child_sa, this->my_host,
|
||||
this->other_host, this->my_virtual_ip,
|
||||
has_condition(this, COND_NAT_ANY)) == NOT_SUPPORTED)
|
||||
{
|
||||
this->public.rekey_child_sa(&this->public,
|
||||
child_sa->get_protocol(child_sa),
|
||||
child_sa->get_spi(child_sa, TRUE));
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
}
|
||||
@@ -1314,6 +1320,7 @@ static status_t route(private_ike_sa_t *this, child_cfg_t *child_cfg)
|
||||
}
|
||||
else
|
||||
{
|
||||
child_sa->destroy(child_sa);
|
||||
DBG1(DBG_IKE, "routing CHILD_SA failed");
|
||||
}
|
||||
return status;
|
||||
|
||||
@@ -327,20 +327,14 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
|
||||
}
|
||||
}
|
||||
|
||||
this->child_sa->set_state(this->child_sa, CHILD_INSTALLING);
|
||||
|
||||
if (this->ipcomp != IPCOMP_NONE)
|
||||
{
|
||||
this->child_sa->activate_ipcomp(this->child_sa, this->ipcomp,
|
||||
this->other_cpi);
|
||||
}
|
||||
|
||||
status = this->child_sa->add_policies(this->child_sa, my_ts, other_ts,
|
||||
this->mode, this->proposal->get_protocol(this->proposal));
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to install IPsec policies (SPD) in kernel");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
|
||||
status = FAILED;
|
||||
if (this->keymat->derive_child_keys(this->keymat, this->proposal,
|
||||
this->dh, nonce_i, nonce_r, &encr_i, &integ_i, &encr_r, &integ_r))
|
||||
@@ -367,6 +361,14 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
status = this->child_sa->add_policies(this->child_sa, my_ts, other_ts,
|
||||
this->mode, this->proposal->get_protocol(this->proposal));
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to install IPsec policies (SPD) in kernel");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
|
||||
charon->bus->child_keys(charon->bus, this->child_sa, this->dh,
|
||||
nonce_i, nonce_r);
|
||||
|
||||
|
||||
@@ -251,11 +251,16 @@ static void update_children(private_ike_mobike_t *this)
|
||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||
{
|
||||
child_sa->update_hosts(child_sa,
|
||||
this->ike_sa->get_my_host(this->ike_sa),
|
||||
this->ike_sa->get_other_host(this->ike_sa),
|
||||
this->ike_sa->get_virtual_ip(this->ike_sa, TRUE),
|
||||
this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY));
|
||||
if (child_sa->update_hosts(child_sa,
|
||||
this->ike_sa->get_my_host(this->ike_sa),
|
||||
this->ike_sa->get_other_host(this->ike_sa),
|
||||
this->ike_sa->get_virtual_ip(this->ike_sa, TRUE),
|
||||
this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY)) == NOT_SUPPORTED)
|
||||
{
|
||||
this->ike_sa->rekey_child_sa(this->ike_sa,
|
||||
child_sa->get_protocol(child_sa),
|
||||
child_sa->get_spi(child_sa, TRUE));
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "task.h"
|
||||
|
||||
#ifdef ME
|
||||
ENUM(task_type_names, IKE_INIT, CHILD_REKEY,
|
||||
"IKE_INIT",
|
||||
"IKE_NATD",
|
||||
@@ -31,11 +32,27 @@ ENUM(task_type_names, IKE_INIT, CHILD_REKEY,
|
||||
"IKE_REAUTH",
|
||||
"IKE_DELETE",
|
||||
"IKE_DPD",
|
||||
#ifdef ME
|
||||
"IKE_ME",
|
||||
#endif /* ME */
|
||||
"CHILD_CREATE",
|
||||
"CHILD_DELETE",
|
||||
"CHILD_REKEY",
|
||||
);
|
||||
|
||||
#else
|
||||
ENUM(task_type_names, IKE_INIT, CHILD_REKEY,
|
||||
"IKE_INIT",
|
||||
"IKE_NATD",
|
||||
"IKE_MOBIKE",
|
||||
"IKE_AUTHENTICATE",
|
||||
"IKE_AUTH_LIFETIME",
|
||||
"IKE_CERT_PRE",
|
||||
"IKE_CERT_POST",
|
||||
"IKE_CONFIG",
|
||||
"IKE_REKEY",
|
||||
"IKE_REAUTH",
|
||||
"IKE_DELETE",
|
||||
"IKE_DPD",
|
||||
"CHILD_CREATE",
|
||||
"CHILD_DELETE",
|
||||
"CHILD_REKEY",
|
||||
);
|
||||
#endif /* ME */
|
||||
|
||||
@@ -173,7 +173,7 @@ host_t *host_create_from_dns(char *string, int family, u_int16_t port);
|
||||
* Constructor to create a host_t object from an address chunk
|
||||
*
|
||||
* @param family Address family, such as AF_INET or AF_INET6
|
||||
* @param address address as chunk_t in networ order
|
||||
* @param address address as chunk_t in network order
|
||||
* @param port port number
|
||||
* @return host_t, NULL if family not supported/chunk invalid
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
ipsec_PROGRAMS = starter
|
||||
starter_SOURCES = y.tab.c netkey.c y.tab.h parser.h args.h netkey.h \
|
||||
starterwhack.c starterwhack.h starterstroke.c invokepluto.c confread.c \
|
||||
starterstroke.h interfaces.c invokepluto.h confread.h interfaces.h args.c \
|
||||
starterstroke.h interfaces.c invokepluto.h confread.h interfaces.h args.c \
|
||||
keywords.c files.h keywords.h cmp.c starter.c cmp.h exec.c invokecharon.c \
|
||||
exec.h invokecharon.h lex.yy.c loglite.c
|
||||
exec.h invokecharon.h lex.yy.c loglite.c klips.c klips.h
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libfreeswan -I$(top_srcdir)/src/pluto -I$(top_srcdir)/src/whack -I$(top_srcdir)/src/stroke
|
||||
AM_CFLAGS = -DIPSEC_DIR=\"${ipsecdir}\" -DIPSEC_CONFDIR=\"${confdir}\" -DIPSEC_PIDDIR=\"${piddir}\" -DIPSEC_EAPDIR=\"${eapdir}\" -DDEBUG
|
||||
|
||||
+2
-1
@@ -19,7 +19,8 @@
|
||||
|
||||
#define STARTER_PID_FILE IPSEC_PIDDIR "/starter.pid"
|
||||
|
||||
#define PROC_NETKEY "/proc/net/pfkey"
|
||||
#define PROC_NETKEY "/proc/net/pfkey"
|
||||
#define PROC_KLIPS "/proc/net/pf_key"
|
||||
#define PROC_MODULES "/proc/modules"
|
||||
|
||||
#define CONFIG_FILE IPSEC_CONFDIR "/ipsec.conf"
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/* strongSwan KLIPS starter
|
||||
* Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* RCSID $Id$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <freeswan.h>
|
||||
|
||||
#include "../pluto/constants.h"
|
||||
#include "../pluto/defs.h"
|
||||
#include "../pluto/log.h"
|
||||
|
||||
#include "files.h"
|
||||
|
||||
bool
|
||||
starter_klips_init(void)
|
||||
{
|
||||
struct stat stb;
|
||||
|
||||
if (stat(PROC_KLIPS, &stb) != 0)
|
||||
{
|
||||
/* ipsec module makes the pf_key proc interface visible */
|
||||
if (stat(PROC_MODULES, &stb) == 0)
|
||||
{
|
||||
system("modprobe -qv ipsec");
|
||||
}
|
||||
|
||||
/* now test again */
|
||||
if (stat(PROC_KLIPS, &stb) != 0)
|
||||
{
|
||||
DBG(DBG_CONTROL,
|
||||
DBG_log("kernel appears to lack the KLIPS IPsec stack")
|
||||
)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* load crypto algorithm modules */
|
||||
system("modprobe -qv ipsec_aes");
|
||||
system("modprobe -qv ipsec_blowfish");
|
||||
system("modprobe -qv ipsec_sha2");
|
||||
|
||||
DBG(DBG_CONTROL,
|
||||
DBG_log("Found KLIPS IPsec stack")
|
||||
)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
starter_klips_cleanup(void)
|
||||
{
|
||||
if (system("type eroute > /dev/null 2>&1") == 0)
|
||||
{
|
||||
system("spi --clear");
|
||||
system("eroute --clear");
|
||||
}
|
||||
else if (system("type setkey > /dev/null 2>&1") == 0)
|
||||
{
|
||||
system("setkey -F");
|
||||
system("setkey -FP");
|
||||
}
|
||||
else
|
||||
{
|
||||
plog("WARNING: cannot flush IPsec state/policy database");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/* strongSwan KLIPS initialization and cleanup
|
||||
* Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* RCSID $Id$
|
||||
*/
|
||||
|
||||
#ifndef _STARTER_KLIPS_H_
|
||||
#define _STARTER_KLIPS_H_
|
||||
|
||||
extern bool starter_klips_init (void);
|
||||
extern void starter_klips_cleanup (void);
|
||||
|
||||
#endif /* _STARTER_KLIPS_H_ */
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "invokepluto.h"
|
||||
#include "invokecharon.h"
|
||||
#include "netkey.h"
|
||||
#include "klips.h"
|
||||
#include "cmp.h"
|
||||
#include "interfaces.h"
|
||||
|
||||
@@ -324,7 +325,11 @@ int main (int argc, char **argv)
|
||||
if (!starter_netkey_init())
|
||||
{
|
||||
plog("no netkey IPSec stack detected");
|
||||
exit(LSB_RC_FAILURE);
|
||||
if (!starter_klips_init())
|
||||
{
|
||||
plog("no KLIPS IPSec stack detected");
|
||||
exit(LSB_RC_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
last_reload = time(NULL);
|
||||
|
||||
Reference in New Issue
Block a user