]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libcharon/plugins/load_tester/load_tester_ipsec.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libcharon / plugins / load_tester / load_tester_ipsec.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include "load_tester_ipsec.h"
18
19 #include <time.h>
20
21 typedef struct private_load_tester_ipsec_t private_load_tester_ipsec_t;
22
23 /**
24 * Private variables and functions of kernel_pfkey class.
25 */
26 struct private_load_tester_ipsec_t {
27 /**
28 * Public interface.
29 */
30 load_tester_ipsec_t public;
31
32 /**
33 * faked SPI counter
34 */
35 refcount_t spi;
36 };
37
38 METHOD(kernel_ipsec_t, get_spi, status_t,
39 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
40 uint8_t protocol, uint32_t *spi)
41 {
42 *spi = (uint32_t)ref_get(&this->spi);
43 return SUCCESS;
44 }
45
46 METHOD(kernel_ipsec_t, get_cpi, status_t,
47 private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
48 uint16_t *cpi)
49 {
50 return FAILED;
51 }
52
53 METHOD(kernel_ipsec_t, add_sa, status_t,
54 private_load_tester_ipsec_t *this, kernel_ipsec_sa_id_t *id,
55 kernel_ipsec_add_sa_t *data)
56 {
57 return SUCCESS;
58 }
59
60 METHOD(kernel_ipsec_t, update_sa, status_t,
61 private_load_tester_ipsec_t *this, kernel_ipsec_sa_id_t *id,
62 kernel_ipsec_update_sa_t *data)
63 {
64 return SUCCESS;
65 }
66
67 METHOD(kernel_ipsec_t, query_sa, status_t,
68 private_load_tester_ipsec_t *this, kernel_ipsec_sa_id_t *id,
69 kernel_ipsec_query_sa_t *data, uint64_t *bytes, uint64_t *packets,
70 time_t *time)
71 {
72 return NOT_SUPPORTED;
73 }
74
75 METHOD(kernel_ipsec_t, del_sa, status_t,
76 private_load_tester_ipsec_t *this, kernel_ipsec_sa_id_t *id,
77 kernel_ipsec_del_sa_t *data)
78 {
79 return SUCCESS;
80 }
81
82 METHOD(kernel_ipsec_t, add_policy, status_t,
83 private_load_tester_ipsec_t *this, kernel_ipsec_policy_id_t *id,
84 kernel_ipsec_manage_policy_t *data)
85 {
86 return SUCCESS;
87 }
88
89 METHOD(kernel_ipsec_t, query_policy, status_t,
90 private_load_tester_ipsec_t *this, kernel_ipsec_policy_id_t *id,
91 kernel_ipsec_query_policy_t *data, time_t *use_time)
92 {
93 *use_time = 1;
94 return SUCCESS;
95 }
96
97 METHOD(kernel_ipsec_t, del_policy, status_t,
98 private_load_tester_ipsec_t *this, kernel_ipsec_policy_id_t *id,
99 kernel_ipsec_manage_policy_t *data)
100 {
101 return SUCCESS;
102 }
103
104 METHOD(kernel_ipsec_t, destroy, void,
105 private_load_tester_ipsec_t *this)
106 {
107 free(this);
108 }
109
110 /*
111 * Described in header.
112 */
113 load_tester_ipsec_t *load_tester_ipsec_create()
114 {
115 private_load_tester_ipsec_t *this;
116
117 INIT(this,
118 .public = {
119 .interface = {
120 .get_spi = _get_spi,
121 .get_cpi = _get_cpi,
122 .add_sa = _add_sa,
123 .update_sa = _update_sa,
124 .query_sa = _query_sa,
125 .del_sa = _del_sa,
126 .flush_sas = (void*)return_failed,
127 .add_policy = _add_policy,
128 .query_policy = _query_policy,
129 .del_policy = _del_policy,
130 .flush_policies = (void*)return_failed,
131 .bypass_socket = (void*)return_true,
132 .enable_udp_decap = (void*)return_true,
133 .destroy = _destroy,
134 },
135 },
136 .spi = 0,
137 );
138
139 return &this->public;
140 }