blob: 9208f5469cddf8c6d5b688556efc970aef0b148a [file] [log] [blame]
Nathan Harold1a371532017-01-30 12:30:48 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef _XFRM_CONTROLLER_H
17#define _XFRM_CONTROLLER_H
18
19#include <atomic>
20#include <list>
21#include <map>
22#include <string>
23#include <utility> // for pair
24
Benedict Wong319f17e2018-05-15 17:06:44 -070025#include <linux/if.h>
manojboopathi8707f232018-01-02 14:45:47 -080026#include <linux/if_link.h>
27#include <linux/if_tunnel.h>
Nathan Harold1a371532017-01-30 12:30:48 -080028#include <linux/netlink.h>
Nathan Harold420ceac2017-04-05 19:36:59 -070029#include <linux/udp.h>
Nathan Harold1a371532017-01-30 12:30:48 -080030#include <linux/xfrm.h>
Bernie Innocenti97f388f2018-10-16 19:17:08 +090031#include <unistd.h>
Nathan Harold1a371532017-01-30 12:30:48 -080032
33#include "NetdConstants.h"
Bernie Innocenti97f388f2018-10-16 19:17:08 +090034#include "android-base/unique_fd.h"
manojboopathi8707f232018-01-02 14:45:47 -080035#include "netdutils/Slice.h"
ludi6e8eccd2017-08-14 14:40:37 -070036#include "netdutils/Status.h"
Bernie Innocenti97f388f2018-10-16 19:17:08 +090037#include "sysutils/SocketClient.h"
Nathan Harold1a371532017-01-30 12:30:48 -080038
39namespace android {
40namespace net {
41
Nathan Harold39b5df42017-08-02 18:45:25 -070042// Exposed for testing
43extern const uint32_t ALGO_MASK_AUTH_ALL;
44// Exposed for testing
45extern const uint32_t ALGO_MASK_CRYPT_ALL;
46// Exposed for testing
Benedict Wongbe65b432017-08-22 21:43:14 -070047extern const uint32_t ALGO_MASK_AEAD_ALL;
48// Exposed for testing
Nathan Harold39b5df42017-08-02 18:45:25 -070049extern const uint8_t REPLAY_WINDOW_SIZE;
50
Nathan Harold1a371532017-01-30 12:30:48 -080051// Suggest we avoid the smallest and largest ints
52class XfrmMessage;
53class TransportModeSecurityAssociation;
54
55class XfrmSocket {
56public:
57 virtual void close() {
Nathan Harold420ceac2017-04-05 19:36:59 -070058 if (mSock >= 0) {
Nathan Harold1a371532017-01-30 12:30:48 -080059 ::close(mSock);
60 }
61 mSock = -1;
62 }
63
ludi6e8eccd2017-08-14 14:40:37 -070064 virtual netdutils::Status open() = 0;
Nathan Harold1a371532017-01-30 12:30:48 -080065
66 virtual ~XfrmSocket() { close(); }
67
ludie51e3862017-08-15 19:28:12 -070068 // Sends the netlink message contained in iovecs. This populates iovecs[0] with
69 // a valid netlink message header.
ludi6e8eccd2017-08-14 14:40:37 -070070 virtual netdutils::Status sendMessage(uint16_t nlMsgType, uint16_t nlMsgFlags,
71 uint16_t nlMsgSeqNum,
72 std::vector<iovec>* iovecs) const = 0;
Nathan Harold1a371532017-01-30 12:30:48 -080073
74protected:
75 int mSock;
76};
77
78enum struct XfrmDirection : uint8_t {
79 IN = XFRM_POLICY_IN,
80 OUT = XFRM_POLICY_OUT,
81 FORWARD = XFRM_POLICY_FWD,
82 MASK = XFRM_POLICY_MASK,
83};
84
85enum struct XfrmMode : uint8_t {
86 TRANSPORT = XFRM_MODE_TRANSPORT,
87 TUNNEL = XFRM_MODE_TUNNEL,
88};
89
Nathan Harold420ceac2017-04-05 19:36:59 -070090enum struct XfrmEncapType : uint16_t {
91 NONE = 0,
92 ESPINUDP_NON_IKE = UDP_ENCAP_ESPINUDP_NON_IKE,
93 ESPINUDP = UDP_ENCAP_ESPINUDP
94};
95
Nathan Harold1a371532017-01-30 12:30:48 -080096struct XfrmAlgo {
97 std::string name;
98 std::vector<uint8_t> key;
99 uint16_t truncLenBits;
100};
101
Nathan Harold420ceac2017-04-05 19:36:59 -0700102struct XfrmEncap {
103 XfrmEncapType type;
104 uint16_t srcPort;
105 uint16_t dstPort;
106};
107
Nathan Harold7441c692017-12-12 21:25:01 -0800108// minimally sufficient structure to match either an SA or a Policy
Benedict Wonga04ffa72018-05-09 21:42:42 -0700109struct XfrmCommonInfo {
Nathan Harold1a371532017-01-30 12:30:48 -0800110 xfrm_address_t dstAddr; // network order
111 xfrm_address_t srcAddr;
112 int addrFamily; // AF_INET or AF_INET6
113 int transformId; // requestId
114 int spi;
Di Lu2ccb3e52018-01-03 16:19:20 -0800115 xfrm_mark mark;
Benedict Wonga450e722018-05-07 10:29:02 -0700116 int xfrm_if_id;
Nathan Harold1a371532017-01-30 12:30:48 -0800117};
118
Benedict Wonga04ffa72018-05-09 21:42:42 -0700119struct XfrmSaInfo : XfrmCommonInfo {
Nathan Harold1a371532017-01-30 12:30:48 -0800120 XfrmAlgo auth;
121 XfrmAlgo crypt;
Benedict Wongbe65b432017-08-22 21:43:14 -0700122 XfrmAlgo aead;
Nathan Harold1a371532017-01-30 12:30:48 -0800123 int netId;
124 XfrmMode mode;
Nathan Harold420ceac2017-04-05 19:36:59 -0700125 XfrmEncap encap;
Nathan Harold1a371532017-01-30 12:30:48 -0800126};
127
Benedict Wonga04ffa72018-05-09 21:42:42 -0700128struct XfrmSpInfo : XfrmSaInfo {
129 // Address family in XfrmCommonInfo used for template/SA matching, need separate addrFamily
130 // for selectors
131 int selAddrFamily; // AF_INET or AF_INET6
132};
133
Nathan Harold1a371532017-01-30 12:30:48 -0800134class XfrmController {
135public:
136 XfrmController();
137
Nathan Harold21299f72018-03-16 20:13:03 -0700138 static netdutils::Status Init();
Benedict Wongb2daefb2017-12-06 22:05:46 -0800139
Nathan Harold21299f72018-03-16 20:13:03 -0700140 static netdutils::Status ipSecSetEncapSocketOwner(const android::base::unique_fd& socket,
141 int newUid, uid_t callerUid);
Nathan Harold1a371532017-01-30 12:30:48 -0800142
Nathan Harold21299f72018-03-16 20:13:03 -0700143 static netdutils::Status ipSecAllocateSpi(int32_t transformId, const std::string& localAddress,
144 const std::string& remoteAddress, int32_t inSpi,
145 int32_t* outSpi);
146
147 static netdutils::Status ipSecAddSecurityAssociation(
Benedict Wonga450e722018-05-07 10:29:02 -0700148 int32_t transformId, int32_t mode, const std::string& sourceAddress,
149 const std::string& destinationAddress, int32_t underlyingNetId, int32_t spi,
150 int32_t markValue, int32_t markMask, const std::string& authAlgo,
151 const std::vector<uint8_t>& authKey, int32_t authTruncBits,
152 const std::string& cryptAlgo, const std::vector<uint8_t>& cryptKey,
153 int32_t cryptTruncBits, const std::string& aeadAlgo,
154 const std::vector<uint8_t>& aeadKey, int32_t aeadIcvBits, int32_t encapType,
155 int32_t encapLocalPort, int32_t encapRemotePort, int32_t xfrmInterfaceId);
Nathan Harold1a371532017-01-30 12:30:48 -0800156
Nathan Harold21299f72018-03-16 20:13:03 -0700157 static netdutils::Status ipSecDeleteSecurityAssociation(int32_t transformId,
158 const std::string& sourceAddress,
159 const std::string& destinationAddress,
160 int32_t spi, int32_t markValue,
Benedict Wonga450e722018-05-07 10:29:02 -0700161 int32_t markMask,
162 int32_t xfrmInterfaceId);
Nathan Harold1a371532017-01-30 12:30:48 -0800163
Nathan Harold21299f72018-03-16 20:13:03 -0700164 static netdutils::Status
165 ipSecApplyTransportModeTransform(const android::base::unique_fd& socket, int32_t transformId,
166 int32_t direction, const std::string& localAddress,
167 const std::string& remoteAddress, int32_t spi);
Nathan Harold1a371532017-01-30 12:30:48 -0800168
Nathan Harold21299f72018-03-16 20:13:03 -0700169 static netdutils::Status
170 ipSecRemoveTransportModeTransform(const android::base::unique_fd& socket);
Nathan Harold1a371532017-01-30 12:30:48 -0800171
Benedict Wonga04ffa72018-05-09 21:42:42 -0700172 static netdutils::Status ipSecAddSecurityPolicy(int32_t transformId, int32_t selAddrFamily,
173 int32_t direction,
Benedict Wongad600cb2018-05-14 17:22:35 -0700174 const std::string& tmplSrcAddress,
175 const std::string& tmplDstAddress, int32_t spi,
Benedict Wonga450e722018-05-07 10:29:02 -0700176 int32_t markValue, int32_t markMask,
177 int32_t xfrmInterfaceId);
ludi771b8002017-11-20 15:09:05 -0800178
Benedict Wonga04ffa72018-05-09 21:42:42 -0700179 static netdutils::Status ipSecUpdateSecurityPolicy(int32_t transformId, int32_t selAddrFamily,
180 int32_t direction,
Benedict Wongad600cb2018-05-14 17:22:35 -0700181 const std::string& tmplSrcAddress,
182 const std::string& tmplDstAddress,
Nathan Harold21299f72018-03-16 20:13:03 -0700183 int32_t spi, int32_t markValue,
Benedict Wonga450e722018-05-07 10:29:02 -0700184 int32_t markMask, int32_t xfrmInterfaceId);
ludi771b8002017-11-20 15:09:05 -0800185
Benedict Wonga04ffa72018-05-09 21:42:42 -0700186 static netdutils::Status ipSecDeleteSecurityPolicy(int32_t transformId, int32_t selAddrFamily,
187 int32_t direction, int32_t markValue,
Benedict Wonga450e722018-05-07 10:29:02 -0700188 int32_t markMask, int32_t xfrmInterfaceId);
ludi771b8002017-11-20 15:09:05 -0800189
Benedict Wong319f17e2018-05-15 17:06:44 -0700190 static netdutils::Status ipSecAddTunnelInterface(const std::string& deviceName,
191 const std::string& localAddress,
192 const std::string& remoteAddress, int32_t ikey,
Benedict Wonga450e722018-05-07 10:29:02 -0700193 int32_t okey, int32_t interfaceId,
194 bool isUpdate);
manojboopathi8707f232018-01-02 14:45:47 -0800195
Benedict Wong319f17e2018-05-15 17:06:44 -0700196 static netdutils::Status ipSecRemoveTunnelInterface(const std::string& deviceName);
manojboopathi8707f232018-01-02 14:45:47 -0800197
Jonathan Basseric6461a62017-08-31 14:47:33 -0700198 // Some XFRM netlink attributes comprise a header, a struct, and some data
199 // after the struct. We wrap all of those in one struct for easier
200 // marshalling. The structs below must be ABI compatible with the kernel and
201 // are composed from kernel structures; thus, they use the kernel naming
202 // convention.
203
Nathan Harold39b5df42017-08-02 18:45:25 -0700204 // Exposed for testing
Benedict Wong4f60ee12017-10-10 12:27:25 -0700205 static constexpr size_t MAX_KEY_LENGTH = 128;
Nathan Harold39b5df42017-08-02 18:45:25 -0700206
Jonathan Basseric6461a62017-08-31 14:47:33 -0700207 // Container for the content of an XFRMA_ALG_CRYPT netlink attribute.
Nathan Harold39b5df42017-08-02 18:45:25 -0700208 // Exposed for testing
209 struct nlattr_algo_crypt {
210 nlattr hdr;
211 xfrm_algo crypt;
Benedict Wong4f60ee12017-10-10 12:27:25 -0700212 uint8_t key[MAX_KEY_LENGTH];
Nathan Harold39b5df42017-08-02 18:45:25 -0700213 };
214
Jonathan Basseric6461a62017-08-31 14:47:33 -0700215 // Container for the content of an XFRMA_ALG_AUTH_TRUNC netlink attribute.
Nathan Harold39b5df42017-08-02 18:45:25 -0700216 // Exposed for testing
217 struct nlattr_algo_auth {
218 nlattr hdr;
219 xfrm_algo_auth auth;
Benedict Wong4f60ee12017-10-10 12:27:25 -0700220 uint8_t key[MAX_KEY_LENGTH];
Nathan Harold39b5df42017-08-02 18:45:25 -0700221 };
222
Jonathan Basseric6461a62017-08-31 14:47:33 -0700223 // Container for the content of an XFRMA_TMPL netlink attribute.
Nathan Harold39b5df42017-08-02 18:45:25 -0700224 // Exposed for testing
Benedict Wongbe65b432017-08-22 21:43:14 -0700225 struct nlattr_algo_aead {
226 nlattr hdr;
227 xfrm_algo_aead aead;
Benedict Wong4f60ee12017-10-10 12:27:25 -0700228 uint8_t key[MAX_KEY_LENGTH];
Benedict Wongbe65b432017-08-22 21:43:14 -0700229 };
230
231 // Exposed for testing
Nathan Harold39b5df42017-08-02 18:45:25 -0700232 struct nlattr_user_tmpl {
233 nlattr hdr;
234 xfrm_user_tmpl tmpl;
235 };
236
Jonathan Basseric6461a62017-08-31 14:47:33 -0700237 // Container for the content of an XFRMA_ENCAP netlink attribute.
Nathan Harold39b5df42017-08-02 18:45:25 -0700238 // Exposed for testing
239 struct nlattr_encap_tmpl {
240 nlattr hdr;
241 xfrm_encap_tmpl tmpl;
242 };
243
Di Lu2ccb3e52018-01-03 16:19:20 -0800244 // Container for the content of an XFRMA_MARK netlink attribute.
245 // Exposed for testing
246 struct nlattr_xfrm_mark {
247 nlattr hdr;
248 xfrm_mark mark;
249 };
250
Benedict Wong96abf482018-01-22 13:56:41 -0800251 // Container for the content of an XFRMA_OUTPUT_MARK netlink attribute.
252 // Exposed for testing
253 struct nlattr_xfrm_output_mark {
254 nlattr hdr;
255 __u32 outputMark;
256 };
257
Benedict Wong319f17e2018-05-15 17:06:44 -0700258 // Container for the content of an XFRMA_IF_ID netlink attribute.
259 // Exposed for testing
260 struct nlattr_xfrm_interface_id {
261 nlattr hdr;
262 __u32 if_id;
263 };
264
265 // Exposed for testing
266 struct nlattr_payload_u32 {
267 nlattr hdr;
268 uint32_t value;
269 };
270
271 private:
Nathan Harolde2dd4c72017-04-19 11:09:11 -0700272/*
Bernie Innocentiedf68352018-07-05 17:50:38 +0900273 * This is a workaround for a kernel bug in the 32bit netlink compat layer
274 * that has been present on x86_64 kernels since 2010 with no fix on the
275 * horizon.
276 *
Nathan Harolde2dd4c72017-04-19 11:09:11 -0700277 * Below is a redefinition of the xfrm_usersa_info struct that is part
278 * of the Linux uapi <linux/xfrm.h> to align the structures to a 64-bit
279 * boundary.
Bernie Innocentiedf68352018-07-05 17:50:38 +0900280 *
281 * Note that we turn this on for all x86 32bit targets, under the assumption
282 * that nowadays all x86 targets are running 64bit kernels.
Nathan Harolde2dd4c72017-04-19 11:09:11 -0700283 */
Bernie Innocentiedf68352018-07-05 17:50:38 +0900284#if defined(__i386__)
Nathan Harolde2dd4c72017-04-19 11:09:11 -0700285 // Shadow the kernel definition of xfrm_usersa_info with a 64-bit aligned version
286 struct xfrm_usersa_info : ::xfrm_usersa_info {
287 } __attribute__((aligned(8)));
288 // Shadow the kernel's version, using the aligned version of xfrm_usersa_info
289 struct xfrm_userspi_info {
290 struct xfrm_usersa_info info;
291 __u32 min;
292 __u32 max;
293 };
Bjoern Johansson83977442018-05-25 16:55:28 -0700294 struct xfrm_userpolicy_info : ::xfrm_userpolicy_info {
295 } __attribute__((aligned(8)));
Nathan Harolde2dd4c72017-04-19 11:09:11 -0700296
297 /*
298 * Anyone who encounters a failure when sending netlink messages should look here
299 * first. Hitting the static_assert() below should be a strong hint that Android
300 * IPsec will probably not work with your current settings.
301 *
302 * Again, experimentally determined, the "flags" field should be the first byte in
303 * the final word of the xfrm_usersa_info struct. The check validates the size of
304 * the padding to be 7.
305 *
306 * This padding is verified to be correct on gcc/x86_64 kernel, and clang/x86 userspace.
307 */
308 static_assert(sizeof(::xfrm_usersa_info) % 8 != 0, "struct xfrm_usersa_info has changed "
309 "alignment. Please consider whether this "
310 "patch is needed.");
311 static_assert(sizeof(xfrm_usersa_info) - offsetof(xfrm_usersa_info, flags) == 8,
312 "struct xfrm_usersa_info probably misaligned with kernel struct.");
313 static_assert(sizeof(xfrm_usersa_info) % 8 == 0, "struct xfrm_usersa_info_t is not 64-bit "
314 "aligned. Please consider whether this patch "
315 "is needed.");
316 static_assert(sizeof(::xfrm_userspi_info) - sizeof(::xfrm_usersa_info) ==
317 sizeof(xfrm_userspi_info) - sizeof(xfrm_usersa_info),
318 "struct xfrm_userspi_info has changed and does not match the kernel struct.");
Bjoern Johansson83977442018-05-25 16:55:28 -0700319 static_assert(sizeof(::xfrm_userpolicy_info) % 8 != 0,
320 "struct xfrm_userpolicy_info has changed "
321 "alignment. Please consider whether this "
322 "patch is needed.");
323 static_assert(sizeof(xfrm_userpolicy_info) - offsetof(xfrm_userpolicy_info, share) == 5,
324 "struct xfrm_userpolicy_info probably misaligned with kernel struct.");
325 static_assert(sizeof(xfrm_userpolicy_info) % 8 == 0,
326 "struct xfrm_userpolicy_info is not 64-bit "
327 "aligned. Please consider whether this patch "
328 "is needed.");
Nathan Harolde2dd4c72017-04-19 11:09:11 -0700329#endif
330
Benedict Wonga04ffa72018-05-09 21:42:42 -0700331 // helper functions for filling in the XfrmCommonInfo (and XfrmSaInfo) structure
332 static netdutils::Status fillXfrmCommonInfo(const std::string& sourceAddress,
333 const std::string& destinationAddress, int32_t spi,
334 int32_t markValue, int32_t markMask,
Benedict Wonga450e722018-05-07 10:29:02 -0700335 int32_t transformId, int32_t xfrmInterfaceId,
336 XfrmCommonInfo* info);
Benedict Wonga04ffa72018-05-09 21:42:42 -0700337 static netdutils::Status fillXfrmCommonInfo(int32_t spi, int32_t markValue, int32_t markMask,
Benedict Wonga450e722018-05-07 10:29:02 -0700338 int32_t transformId, int32_t xfrmInterfaceId,
339 XfrmCommonInfo* info);
Nathan Harold1a371532017-01-30 12:30:48 -0800340
341 // Top level functions for managing a Transport Mode Transform
ludi6e8eccd2017-08-14 14:40:37 -0700342 static netdutils::Status addTransportModeTransform(const XfrmSaInfo& record);
Nathan Harold1a371532017-01-30 12:30:48 -0800343 static int removeTransportModeTransform(const XfrmSaInfo& record);
344
345 // TODO(messagerefactor): FACTOR OUT ALL MESSAGE BUILDING CODE BELOW HERE
346 // Shared between SA and SP
Benedict Wonga04ffa72018-05-09 21:42:42 -0700347 static void fillXfrmSelector(const int record, xfrm_selector* selector);
Nathan Harold1a371532017-01-30 12:30:48 -0800348
349 // Shared between Transport and Tunnel Mode
350 static int fillNlAttrXfrmAlgoEnc(const XfrmAlgo& in_algo, nlattr_algo_crypt* algo);
351 static int fillNlAttrXfrmAlgoAuth(const XfrmAlgo& in_algo, nlattr_algo_auth* algo);
Benedict Wongbe65b432017-08-22 21:43:14 -0700352 static int fillNlAttrXfrmAlgoAead(const XfrmAlgo& in_algo, nlattr_algo_aead* algo);
Nathan Harold420ceac2017-04-05 19:36:59 -0700353 static int fillNlAttrXfrmEncapTmpl(const XfrmSaInfo& record, nlattr_encap_tmpl* tmpl);
Nathan Harold1a371532017-01-30 12:30:48 -0800354
Di Lu0e16b5e2018-01-12 10:37:53 -0800355 // Functions for updating a Transport Mode SA
356 static netdutils::Status updateSecurityAssociation(const XfrmSaInfo& record,
manojboopathi4d2d6f12017-12-06 11:11:31 -0800357 const XfrmSocket& sock);
Nathan Harold1a371532017-01-30 12:30:48 -0800358 static int fillUserSaInfo(const XfrmSaInfo& record, xfrm_usersa_info* usersa);
359
360 // Functions for deleting a Transport Mode SA
Benedict Wonga04ffa72018-05-09 21:42:42 -0700361 static netdutils::Status deleteSecurityAssociation(const XfrmCommonInfo& record,
ludi6e8eccd2017-08-14 14:40:37 -0700362 const XfrmSocket& sock);
Benedict Wonga04ffa72018-05-09 21:42:42 -0700363 static int fillUserSaId(const XfrmCommonInfo& record, xfrm_usersa_id* said);
364 static int fillUserTemplate(const XfrmSpInfo& record, xfrm_user_tmpl* tmpl);
ludi771b8002017-11-20 15:09:05 -0800365
Benedict Wonga04ffa72018-05-09 21:42:42 -0700366 static int fillUserSpInfo(const XfrmSpInfo& record, XfrmDirection direction,
367 xfrm_userpolicy_info* usersp);
368 static int fillNlAttrUserTemplate(const XfrmSpInfo& record, nlattr_user_tmpl* tmpl);
369 static int fillUserPolicyId(const XfrmSpInfo& record, XfrmDirection direction,
ludi771b8002017-11-20 15:09:05 -0800370 xfrm_userpolicy_id* policy_id);
Benedict Wonga04ffa72018-05-09 21:42:42 -0700371 static int fillNlAttrXfrmMark(const XfrmCommonInfo& record, nlattr_xfrm_mark* mark);
Benedict Wongd8b6a382018-09-18 17:16:10 -0700372 static int fillNlAttrXfrmOutputMark(const __u32 underlyingNetId,
Benedict Wong96abf482018-01-22 13:56:41 -0800373 nlattr_xfrm_output_mark* output_mark);
Benedict Wong319f17e2018-05-15 17:06:44 -0700374 static int fillNlAttrXfrmIntfId(const __u32 intf_id_value, nlattr_xfrm_interface_id* intf_id);
Nathan Harold1a371532017-01-30 12:30:48 -0800375
ludi6e8eccd2017-08-14 14:40:37 -0700376 static netdutils::Status allocateSpi(const XfrmSaInfo& record, uint32_t minSpi, uint32_t maxSpi,
377 uint32_t* outSpi, const XfrmSocket& sock);
Nathan Harold1a371532017-01-30 12:30:48 -0800378
Benedict Wonga04ffa72018-05-09 21:42:42 -0700379 static netdutils::Status processSecurityPolicy(int32_t transformId, int32_t selAddrFamily,
380 int32_t direction,
Benedict Wongad600cb2018-05-14 17:22:35 -0700381 const std::string& tmplSrcAddress,
382 const std::string& tmplDstAddress, int32_t spi,
Nathan Harold21299f72018-03-16 20:13:03 -0700383 int32_t markValue, int32_t markMask,
Benedict Wonga450e722018-05-07 10:29:02 -0700384 int32_t xfrmInterfaceId, int32_t msgType);
Benedict Wonga04ffa72018-05-09 21:42:42 -0700385 static netdutils::Status updateTunnelModeSecurityPolicy(const XfrmSpInfo& record,
ludi771b8002017-11-20 15:09:05 -0800386 const XfrmSocket& sock,
387 XfrmDirection direction,
388 uint16_t msgType);
Benedict Wonga04ffa72018-05-09 21:42:42 -0700389 static netdutils::Status deleteTunnelModeSecurityPolicy(const XfrmSpInfo& record,
ludi771b8002017-11-20 15:09:05 -0800390 const XfrmSocket& sock,
391 XfrmDirection direction);
Nathan Harold21299f72018-03-16 20:13:03 -0700392 static netdutils::Status flushInterfaces();
393 static netdutils::Status flushSaDb(const XfrmSocket& s);
394 static netdutils::Status flushPolicyDb(const XfrmSocket& s);
395
Benedict Wong319f17e2018-05-15 17:06:44 -0700396 static netdutils::Status ipSecAddXfrmInterface(const std::string& deviceName,
397 int32_t underlyingInterface, int32_t interfaceId,
398 uint16_t flags);
399 static netdutils::Status ipSecAddVirtualTunnelInterface(const std::string& deviceName,
400 const std::string& localAddress,
401 const std::string& remoteAddress,
402 int32_t ikey, int32_t okey,
403 uint16_t flags);
Nathan Harold1a371532017-01-30 12:30:48 -0800404 // END TODO(messagerefactor)
405};
406
407} // namespace net
408} // namespace android
409
410#endif /* !defined(XFRM_CONTROLLER_H) */