2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "load_tester_ipsec.h"
22 typedef struct private_load_tester_ipsec_t private_load_tester_ipsec_t
;
25 * Private variables and functions of kernel_pfkey class.
27 struct private_load_tester_ipsec_t
{
31 load_tester_ipsec_t
public;
40 * Implementation of kernel_interface_t.get_spi.
42 static status_t
get_spi(private_load_tester_ipsec_t
*this,
43 host_t
*src
, host_t
*dst
,
44 protocol_id_t protocol
, u_int32_t reqid
,
52 * Implementation of kernel_interface_t.get_cpi.
54 static status_t
get_cpi(private_load_tester_ipsec_t
*this,
55 host_t
*src
, host_t
*dst
,
56 u_int32_t reqid
, u_int16_t
*cpi
)
62 * Implementation of kernel_interface_t.add_sa.
64 static status_t
add_sa(private_load_tester_ipsec_t
*this,
65 host_t
*src
, host_t
*dst
, u_int32_t spi
,
66 protocol_id_t protocol
, u_int32_t reqid
,
67 u_int64_t expire_soft
, u_int64_t expire_hard
,
68 u_int16_t enc_alg
, chunk_t enc_key
,
69 u_int16_t int_alg
, chunk_t int_key
,
70 ipsec_mode_t mode
, u_int16_t ipcomp
, u_int16_t cpi
,
71 bool encap
, bool inbound
)
77 * Implementation of kernel_interface_t.update_sa.
79 static status_t
update_sa(private_load_tester_ipsec_t
*this,
80 u_int32_t spi
, protocol_id_t protocol
, u_int16_t cpi
,
81 host_t
*src
, host_t
*dst
,
82 host_t
*new_src
, host_t
*new_dst
,
83 bool encap
, bool new_encap
)
89 * Implementation of kernel_interface_t.del_sa.
91 static status_t
del_sa(private_load_tester_ipsec_t
*this, host_t
*dst
,
92 u_int32_t spi
, protocol_id_t protocol
, u_int16_t cpi
)
98 * Implementation of kernel_interface_t.add_policy.
100 static status_t
add_policy(private_load_tester_ipsec_t
*this,
101 host_t
*src
, host_t
*dst
,
102 traffic_selector_t
*src_ts
,
103 traffic_selector_t
*dst_ts
,
104 policy_dir_t direction
, protocol_id_t protocol
,
105 u_int32_t reqid
, ipsec_mode_t mode
, u_int16_t ipcomp
,
106 u_int16_t cpi
, bool routed
)
112 * Implementation of kernel_interface_t.query_policy.
114 static status_t
query_policy(private_load_tester_ipsec_t
*this,
115 traffic_selector_t
*src_ts
,
116 traffic_selector_t
*dst_ts
,
117 policy_dir_t direction
, u_int32_t
*use_time
)
119 *use_time
= time(NULL
);
124 * Implementation of kernel_interface_t.del_policy.
126 static status_t
del_policy(private_load_tester_ipsec_t
*this,
127 traffic_selector_t
*src_ts
,
128 traffic_selector_t
*dst_ts
,
129 policy_dir_t direction
, bool unrouted
)
135 * Implementation of kernel_interface_t.destroy.
137 static void destroy(private_load_tester_ipsec_t
*this)
143 * Described in header.
145 load_tester_ipsec_t
*load_tester_ipsec_create()
147 private_load_tester_ipsec_t
*this = malloc_thing(private_load_tester_ipsec_t
);
149 /* public functions */
150 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
;
151 this->public.interface
.get_cpi
= (status_t(*)(kernel_ipsec_t
*,host_t
*,host_t
*,u_int32_t
,u_int16_t
*))get_cpi
;
152 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
;
153 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
;
154 this->public.interface
.del_sa
= (status_t(*)(kernel_ipsec_t
*,host_t
*,u_int32_t
,protocol_id_t
,u_int16_t
))del_sa
;
155 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
;
156 this->public.interface
.query_policy
= (status_t(*)(kernel_ipsec_t
*,traffic_selector_t
*,traffic_selector_t
*,policy_dir_t
,u_int32_t
*))query_policy
;
157 this->public.interface
.del_policy
= (status_t(*)(kernel_ipsec_t
*,traffic_selector_t
*,traffic_selector_t
*,policy_dir_t
,bool))del_policy
;
158 this->public.interface
.destroy
= (void(*)(kernel_ipsec_t
*)) destroy
;
162 return &this->public;