Added missing markt_t in load tester, also migrated to INIT/METHOD macros.
[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 u_int32_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 protocol_id_t protocol, u_int32_t reqid, u_int32_t *spi)
40 {
41 *spi = ++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_int32_t reqid, 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, protocol_id_t protocol, u_int32_t reqid, mark_t mark,
55 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, u_int16_t ipcomp,
57 u_int16_t cpi, bool encap, bool inbound, traffic_selector_t *src_ts,
58 traffic_selector_t *dst_ts)
59 {
60 return SUCCESS;
61 }
62
63 METHOD(kernel_ipsec_t, update_sa, status_t,
64 private_load_tester_ipsec_t *this, u_int32_t spi, protocol_id_t protocol,
65 u_int16_t cpi, host_t *src, host_t *dst, host_t *new_src,
66 host_t *new_dst, bool encap, bool new_encap, mark_t mark)
67 {
68 return SUCCESS;
69 }
70
71 METHOD(kernel_ipsec_t, query_sa, status_t,
72 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
73 u_int32_t spi, protocol_id_t protocol, mark_t mark, u_int64_t *bytes)
74 {
75 return NOT_SUPPORTED;
76 }
77
78 METHOD(kernel_ipsec_t, del_sa, status_t,
79 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
80 u_int32_t spi, protocol_id_t protocol, u_int16_t cpi, mark_t mark)
81 {
82 return SUCCESS;
83 }
84
85 METHOD(kernel_ipsec_t, add_policy, status_t,
86 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
87 traffic_selector_t *src_ts, traffic_selector_t *dst_ts,
88 policy_dir_t direction, u_int32_t spi, protocol_id_t protocol,
89 u_int32_t reqid, mark_t mark, ipsec_mode_t mode, u_int16_t ipcomp,
90 u_int16_t cpi, bool routed)
91 {
92 return SUCCESS;
93 }
94
95 METHOD(kernel_ipsec_t, query_policy, status_t,
96 private_load_tester_ipsec_t *this, traffic_selector_t *src_ts,
97 traffic_selector_t *dst_ts, policy_dir_t direction, mark_t mark,
98 u_int32_t *use_time)
99 {
100 *use_time = time_monotonic(NULL);
101 return SUCCESS;
102 }
103
104 METHOD(kernel_ipsec_t, del_policy, status_t,
105 private_load_tester_ipsec_t *this, traffic_selector_t *src_ts,
106 traffic_selector_t *dst_ts, policy_dir_t direction, mark_t mark,
107 bool unrouted)
108 {
109 return SUCCESS;
110 }
111
112 METHOD(kernel_ipsec_t, destroy, void,
113 private_load_tester_ipsec_t *this)
114 {
115 free(this);
116 }
117
118 /*
119 * Described in header.
120 */
121 load_tester_ipsec_t *load_tester_ipsec_create()
122 {
123 private_load_tester_ipsec_t *this;
124
125 INIT(this,
126 .public = {
127 .interface = {
128 .get_spi = _get_spi,
129 .get_cpi = _get_cpi,
130 .add_sa = _add_sa,
131 .update_sa = _update_sa,
132 .query_sa = _query_sa,
133 .del_sa = _del_sa,
134 .add_policy = _add_policy,
135 .query_policy = _query_policy,
136 .del_policy = _del_policy,
137 .destroy = _destroy,
138 },
139 },
140 .spi = 0,
141 );
142
143 return &this->public;
144 }
145