]>
Commit | Line | Data |
---|---|---|
0fd6e955 MW |
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. | |
0fd6e955 MW |
14 | */ |
15 | ||
16 | #include "load_tester_ipsec.h" | |
17 | ||
e13389a7 MW |
18 | #include <time.h> |
19 | ||
0fd6e955 MW |
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; | |
7daf5226 | 30 | |
0fd6e955 MW |
31 | /** |
32 | * faked SPI counter | |
33 | */ | |
34 | u_int32_t spi; | |
35 | }; | |
36 | ||
f395f28e TB |
37 | METHOD(kernel_ipsec_t, get_spi, status_t, |
38 | private_load_tester_ipsec_t *this, host_t *src, host_t *dst, | |
9f166d9a | 39 | u_int8_t protocol, u_int32_t reqid, u_int32_t *spi) |
0fd6e955 MW |
40 | { |
41 | *spi = ++this->spi; | |
42 | return SUCCESS; | |
43 | } | |
44 | ||
f395f28e TB |
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) | |
0fd6e955 MW |
48 | { |
49 | return FAILED; | |
50 | } | |
51 | ||
f395f28e TB |
52 | METHOD(kernel_ipsec_t, add_sa, status_t, |
53 | private_load_tester_ipsec_t *this, host_t *src, host_t *dst, | |
9f166d9a | 54 | u_int32_t spi, u_int8_t protocol, u_int32_t reqid, mark_t mark, |
f395f28e TB |
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) | |
0fd6e955 MW |
59 | { |
60 | return SUCCESS; | |
61 | } | |
62 | ||
f395f28e | 63 | METHOD(kernel_ipsec_t, update_sa, status_t, |
9f166d9a | 64 | private_load_tester_ipsec_t *this, u_int32_t spi, u_int8_t protocol, |
f395f28e TB |
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) | |
0fd6e955 MW |
67 | { |
68 | return SUCCESS; | |
69 | } | |
70 | ||
f395f28e TB |
71 | METHOD(kernel_ipsec_t, query_sa, status_t, |
72 | private_load_tester_ipsec_t *this, host_t *src, host_t *dst, | |
9f166d9a | 73 | u_int32_t spi, u_int8_t protocol, mark_t mark, u_int64_t *bytes) |
2ad51539 AS |
74 | { |
75 | return NOT_SUPPORTED; | |
76 | } | |
77 | ||
f395f28e TB |
78 | METHOD(kernel_ipsec_t, del_sa, status_t, |
79 | private_load_tester_ipsec_t *this, host_t *src, host_t *dst, | |
9f166d9a | 80 | u_int32_t spi, u_int8_t protocol, u_int16_t cpi, mark_t mark) |
0fd6e955 MW |
81 | { |
82 | return SUCCESS; | |
83 | } | |
84 | ||
f395f28e TB |
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, | |
9f166d9a | 88 | policy_dir_t direction, u_int32_t spi, u_int8_t protocol, |
f395f28e TB |
89 | u_int32_t reqid, mark_t mark, ipsec_mode_t mode, u_int16_t ipcomp, |
90 | u_int16_t cpi, bool routed) | |
0fd6e955 MW |
91 | { |
92 | return SUCCESS; | |
93 | } | |
94 | ||
f395f28e TB |
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) | |
0fd6e955 | 99 | { |
6180a558 | 100 | *use_time = time_monotonic(NULL); |
0fd6e955 MW |
101 | return SUCCESS; |
102 | } | |
103 | ||
f395f28e TB |
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) | |
0fd6e955 MW |
108 | { |
109 | return SUCCESS; | |
110 | } | |
111 | ||
6c4cd8fa MW |
112 | METHOD(kernel_ipsec_t, bypass_socket, bool, |
113 | private_load_tester_ipsec_t *this, int fd, int family) | |
114 | { | |
115 | return TRUE; | |
116 | } | |
117 | ||
f395f28e TB |
118 | METHOD(kernel_ipsec_t, destroy, void, |
119 | private_load_tester_ipsec_t *this) | |
0fd6e955 MW |
120 | { |
121 | free(this); | |
122 | } | |
123 | ||
124 | /* | |
125 | * Described in header. | |
126 | */ | |
127 | load_tester_ipsec_t *load_tester_ipsec_create() | |
128 | { | |
f395f28e TB |
129 | private_load_tester_ipsec_t *this; |
130 | ||
131 | INIT(this, | |
132 | .public = { | |
133 | .interface = { | |
134 | .get_spi = _get_spi, | |
135 | .get_cpi = _get_cpi, | |
136 | .add_sa = _add_sa, | |
137 | .update_sa = _update_sa, | |
138 | .query_sa = _query_sa, | |
139 | .del_sa = _del_sa, | |
140 | .add_policy = _add_policy, | |
141 | .query_policy = _query_policy, | |
142 | .del_policy = _del_policy, | |
6c4cd8fa | 143 | .bypass_socket = _bypass_socket, |
f395f28e TB |
144 | .destroy = _destroy, |
145 | }, | |
146 | }, | |
147 | .spi = 0, | |
148 | ); | |
7daf5226 | 149 | |
0fd6e955 MW |
150 | return &this->public; |
151 | } | |
152 |