7c2a27147a70582bf61cc8de850ec64f33c35620
[strongswan.git] / Source / charon / threads / kernel_interface.h
1 /**
2 * @file kernel_interface.h
3 *
4 * @brief Interface of kernel_interface_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef KERNEL_INTERFACE_H_
24 #define KERNEL_INTERFACE_H_
25
26 #include <linux/xfrm.h>
27
28 #include <network/host.h>
29 #include <encoding/payloads/proposal_substructure.h>
30
31 typedef struct kernel_interface_t kernel_interface_t;
32
33 /**
34 * @brief Interface to the kernel.
35 *
36 * @b Constructors:
37 * - kernel_interface_create()
38 *
39 * @ingroup threads
40 */
41 struct kernel_interface_t {
42
43 /**
44 * @brief Get a SPI from the kernel
45 *
46 * @todo Fix spi range
47 */
48 status_t (*get_spi) (kernel_interface_t *this,
49 host_t *src, host_t *dest,
50 protocol_id_t protocol,
51 u_int32_t reqid,
52 u_int32_t *spi);
53
54 /**
55 * @brief Create an SA.
56 *
57 * @todo Fix reqid and replay_window params
58 *
59 * @todo Cleanup method params
60 */
61 status_t (*add_sa)(kernel_interface_t *this,
62 host_t *src, host_t *dst,
63 u_int32_t spi,
64 protocol_id_t protocol,
65 u_int32_t reqid,
66 encryption_algorithm_t enc_alg,
67 chunk_t encryption_key,
68 integrity_algorithm_t int_alg,
69 chunk_t integrity_key,
70 bool replace);
71
72 status_t (*del_sa) (kernel_interface_t *this,
73 host_t *dst,
74 u_int32_t spi,
75 protocol_id_t protocol);
76
77 status_t (*add_policy) (kernel_interface_t *this,
78 host_t *me, host_t *other,
79 host_t *src, host_t *dst,
80 u_int8_t src_hostbits, u_int8_t dst_hostbits,
81 int direction, int upper_proto,
82 bool ah, bool esp,
83 u_int32_t reqid);
84
85 status_t (*del_policy) (kernel_interface_t *this,
86 host_t *me, host_t *other,
87 host_t *src, host_t *dst,
88 u_int8_t src_hostbits, u_int8_t dst_hostbits,
89 int direction, int upper_proto);
90
91 /**
92 * @brief Destroys a kernel_interface object.
93 *
94 * @param kernel_interface_t calling object
95 */
96 void (*destroy) (kernel_interface_t *kernel_interface);
97 };
98
99 /**
100 * @brief Creates an object of type kernel_interface_t.
101 *
102 * @ingroup threads
103 */
104 kernel_interface_t *kernel_interface_create();
105
106 #endif /*KERNEL_INTERFACE_H_*/