62d43e302b2a9e4e537e220f49f6fa221f8e1dee
[strongswan.git] / src / libcharon / 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 refcount_t spi;
35 };
36
37 METHOD(kernel_ipsec_t, get_spi, status_t,
38 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
39 u_int8_t protocol, u_int32_t *spi)
40 {
41 *spi = (uint32_t)ref_get(&this->spi);
42 return SUCCESS;
43 }
44
45 METHOD(kernel_ipsec_t, get_cpi, status_t,
46 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
47 u_int16_t *cpi)
48 {
49 return FAILED;
50 }
51
52 METHOD(kernel_ipsec_t, add_sa, status_t,
53 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
54 u_int32_t spi, u_int8_t protocol, u_int32_t reqid, mark_t mark,
55 u_int32_t tfc, lifetime_cfg_t *lifetime, u_int16_t enc_alg, chunk_t enc_key,
56 u_int16_t int_alg, chunk_t int_key, ipsec_mode_t mode,
57 u_int16_t ipcomp, u_int16_t cpi, u_int32_t replay_window,
58 bool initiator, bool encap, bool esn, bool inbound, bool update,
59 linked_list_t *src_ts, linked_list_t *dst_ts)
60 {
61 return SUCCESS;
62 }
63
64 METHOD(kernel_ipsec_t, update_sa, status_t,
65 private_load_tester_ipsec_t *this, u_int32_t spi, u_int8_t protocol,
66 u_int16_t cpi, host_t *src, host_t *dst, host_t *new_src,
67 host_t *new_dst, bool encap, bool new_encap, mark_t mark)
68 {
69 return SUCCESS;
70 }
71
72 METHOD(kernel_ipsec_t, query_sa, status_t,
73 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
74 u_int32_t spi, u_int8_t protocol, mark_t mark,
75 u_int64_t *bytes, u_int64_t *packets, time_t *time)
76 {
77 return NOT_SUPPORTED;
78 }
79
80 METHOD(kernel_ipsec_t, del_sa, status_t,
81 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
82 u_int32_t spi, u_int8_t protocol, u_int16_t cpi, mark_t mark)
83 {
84 return SUCCESS;
85 }
86
87 METHOD(kernel_ipsec_t, add_policy, status_t,
88 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
89 traffic_selector_t *src_ts, traffic_selector_t *dst_ts,
90 policy_dir_t direction, policy_type_t type, ipsec_sa_cfg_t *sa,
91 mark_t mark, policy_priority_t priority)
92 {
93 return SUCCESS;
94 }
95
96 METHOD(kernel_ipsec_t, query_policy, status_t,
97 private_load_tester_ipsec_t *this, traffic_selector_t *src_ts,
98 traffic_selector_t *dst_ts, policy_dir_t direction, mark_t mark,
99 time_t *use_time)
100 {
101 *use_time = 1;
102 return SUCCESS;
103 }
104
105 METHOD(kernel_ipsec_t, del_policy, status_t,
106 private_load_tester_ipsec_t *this, traffic_selector_t *src_ts,
107 traffic_selector_t *dst_ts, policy_dir_t direction, u_int32_t reqid,
108 mark_t mark, policy_priority_t priority)
109 {
110 return SUCCESS;
111 }
112
113 METHOD(kernel_ipsec_t, destroy, void,
114 private_load_tester_ipsec_t *this)
115 {
116 free(this);
117 }
118
119 /*
120 * Described in header.
121 */
122 load_tester_ipsec_t *load_tester_ipsec_create()
123 {
124 private_load_tester_ipsec_t *this;
125
126 INIT(this,
127 .public = {
128 .interface = {
129 .get_spi = _get_spi,
130 .get_cpi = _get_cpi,
131 .add_sa = _add_sa,
132 .update_sa = _update_sa,
133 .query_sa = _query_sa,
134 .del_sa = _del_sa,
135 .flush_sas = (void*)return_failed,
136 .add_policy = _add_policy,
137 .query_policy = _query_policy,
138 .del_policy = _del_policy,
139 .flush_policies = (void*)return_failed,
140 .bypass_socket = (void*)return_true,
141 .enable_udp_decap = (void*)return_true,
142 .destroy = _destroy,
143 },
144 },
145 .spi = 0,
146 );
147
148 return &this->public;
149 }