Removed strayed code fragment
[strongswan.git] / src / charon / plugins / load_tester / load_tester_ipsec.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 #include "load_tester_ipsec.h"
17
18 #include <time.h>
19
20 typedef struct private_load_tester_ipsec_t private_load_tester_ipsec_t;
21
22 /**
23 * Private variables and functions of kernel_pfkey class.
24 */
25 struct private_load_tester_ipsec_t {
26 /**
27 * Public interface.
28 */
29 load_tester_ipsec_t public;
30
31 /**
32 * faked SPI counter
33 */
34 u_int32_t spi;
35 };
36
37 /**
38 * Implementation of kernel_interface_t.get_spi.
39 */
40 static status_t get_spi(private_load_tester_ipsec_t *this,
41 host_t *src, host_t *dst,
42 protocol_id_t protocol, u_int32_t reqid,
43 u_int32_t *spi)
44 {
45 *spi = ++this->spi;
46 return SUCCESS;
47 }
48
49 /**
50 * Implementation of kernel_interface_t.get_cpi.
51 */
52 static status_t get_cpi(private_load_tester_ipsec_t *this,
53 host_t *src, host_t *dst,
54 u_int32_t reqid, u_int16_t *cpi)
55 {
56 return FAILED;
57 }
58
59 /**
60 * Implementation of kernel_interface_t.add_sa.
61 */
62 static status_t add_sa(private_load_tester_ipsec_t *this,
63 host_t *src, host_t *dst, u_int32_t spi,
64 protocol_id_t protocol, u_int32_t reqid,
65 lifetime_cfg_t *lifetime,
66 u_int16_t enc_alg, chunk_t enc_key,
67 u_int16_t int_alg, chunk_t int_key,
68 ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
69 bool encap, bool inbound, traffic_selector_t *src_ts,
70 traffic_selector_t *dst_ts)
71 {
72 return SUCCESS;
73 }
74
75 /**
76 * Implementation of kernel_interface_t.update_sa.
77 */
78 static status_t update_sa(private_load_tester_ipsec_t *this,
79 u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
80 host_t *src, host_t *dst,
81 host_t *new_src, host_t *new_dst,
82 bool encap, bool new_encap)
83 {
84 return SUCCESS;
85 }
86
87 /**
88 * Implementation of kernel_interface_t.query_sa.
89 */
90 static status_t query_sa(private_load_tester_ipsec_t *this, host_t *src,
91 host_t *dst, u_int32_t spi, protocol_id_t protocol,
92 u_int64_t *bytes)
93 {
94 return NOT_SUPPORTED;
95 }
96
97 /**
98 * Implementation of kernel_interface_t.del_sa.
99 */
100 static status_t del_sa(private_load_tester_ipsec_t *this, host_t *src,
101 host_t *dst, u_int32_t spi, protocol_id_t protocol,
102 u_int16_t cpi)
103 {
104 return SUCCESS;
105 }
106
107 /**
108 * Implementation of kernel_interface_t.add_policy.
109 */
110 static status_t add_policy(private_load_tester_ipsec_t *this,
111 host_t *src, host_t *dst,
112 traffic_selector_t *src_ts,
113 traffic_selector_t *dst_ts,
114 policy_dir_t direction, u_int32_t spi,
115 protocol_id_t protocol, u_int32_t reqid,
116 ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
117 bool routed)
118 {
119 return SUCCESS;
120 }
121
122 /**
123 * Implementation of kernel_interface_t.query_policy.
124 */
125 static status_t query_policy(private_load_tester_ipsec_t *this,
126 traffic_selector_t *src_ts,
127 traffic_selector_t *dst_ts,
128 policy_dir_t direction, u_int32_t *use_time)
129 {
130 *use_time = time_monotonic(NULL);
131 return SUCCESS;
132 }
133
134 /**
135 * Implementation of kernel_interface_t.del_policy.
136 */
137 static status_t del_policy(private_load_tester_ipsec_t *this,
138 traffic_selector_t *src_ts,
139 traffic_selector_t *dst_ts,
140 policy_dir_t direction, bool unrouted)
141 {
142 return SUCCESS;
143 }
144
145 /**
146 * Implementation of kernel_interface_t.destroy.
147 */
148 static void destroy(private_load_tester_ipsec_t *this)
149 {
150 free(this);
151 }
152
153 /*
154 * Described in header.
155 */
156 load_tester_ipsec_t *load_tester_ipsec_create()
157 {
158 private_load_tester_ipsec_t *this = malloc_thing(private_load_tester_ipsec_t);
159
160 /* public functions */
161 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;
162 this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
163 this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,lifetime_cfg_t*,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool,traffic_selector_t*,traffic_selector_t*))add_sa;
164 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;
165 this->public.interface.query_sa = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,protocol_id_t,u_int64_t*))query_sa;
166 this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
167 this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t *this,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;
168 this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
169 this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
170 this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
171
172 this->spi = 0;
173
174 return &this->public;
175 }
176